Bug 41055

Summary: Simplify hash lookups at RegExp caching
Product: WebKit Reporter: Renata Hodovan <rhodovan.u-szeged>
Component: JavaScriptCoreAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: abarth, commit-queue, eric, ggaren, oliver, ossy, webkit.review.bot, zherczeg
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: PC   
OS: Linux   
Bug Depends on: 41205, 41240    
Bug Blocks:    
Attachments:
Description Flags
Simplify hash lookups in RegExp caching
none
Simplify hash lookups in RegExp caching
none
Patch
none
Patch oliver: review+

Renata Hodovan
Reported 2010-06-23 02:46:12 PDT
1) With giving to RegExpCache::create an extra iterator parameter we can simplify some hash lookups. 2) We can collapse the two version of RegExp::create into one, in which we check whether flags are given or not.
Attachments
Simplify hash lookups in RegExp caching (3.82 KB, patch)
2010-06-23 02:52 PDT, Renata Hodovan
no flags
Simplify hash lookups in RegExp caching (6.07 KB, patch)
2010-06-24 08:45 PDT, Renata Hodovan
no flags
Patch (7.30 KB, patch)
2010-06-28 12:15 PDT, Geoffrey Garen
no flags
Patch (6.71 KB, patch)
2010-06-28 12:18 PDT, Geoffrey Garen
oliver: review+
Renata Hodovan
Comment 1 2010-06-23 02:52:02 PDT
Created attachment 59496 [details] Simplify hash lookups in RegExp caching
Gabor Loki
Comment 2 2010-06-24 01:55:35 PDT
Comment on attachment 59496 [details] Simplify hash lookups in RegExp caching > +PassRefPtr<RegExp> RegExpCache::create(const UString& patternString, const UString& flags, HashMap<RegExpKey, RefPtr<RegExp> >::iterator iterator) The RegExpCacheMap::iterator will look better. > -PassRefPtr<RegExp> RegExp::create(JSGlobalData* globalData, const UString& pattern) > -{ > - return adoptRef(new RegExp(globalData, pattern)); > -} > - > PassRefPtr<RegExp> RegExp::create(JSGlobalData* globalData, const UString& pattern, const UString& flags) > { > + if (flags.isNull()) > + return adoptRef(new RegExp(globalData, pattern)); > return adoptRef(new RegExp(globalData, pattern, flags)); > } If you propose this merge, what is the reason not to merge the RegExp constructors and create functions?
Renata Hodovan
Comment 3 2010-06-24 08:44:32 PDT
> The RegExpCacheMap::iterator will look better. You're right. This way is really better. > > -PassRefPtr<RegExp> RegExp::create(JSGlobalData* globalData, const UString& pattern) > > -{ > > - return adoptRef(new RegExp(globalData, pattern)); > > -} > > - > > PassRefPtr<RegExp> RegExp::create(JSGlobalData* globalData, const UString& pattern, const UString& flags) > > { > > + if (flags.isNull()) > > + return adoptRef(new RegExp(globalData, pattern)); > > return adoptRef(new RegExp(globalData, pattern, flags)); > > } > > If you propose this merge, what is the reason not to merge the RegExp constructors and create functions? I agree that we should merge RegExp constructors. But I think it's more prefered to call the public RegExp constructor from the public create function. I have seen examples for this, but maybe I'm wrong. Any comments?
Renata Hodovan
Comment 4 2010-06-24 08:45:12 PDT
Created attachment 59657 [details] Simplify hash lookups in RegExp caching
Renata Hodovan
Comment 5 2010-06-24 11:59:00 PDT
> ... to call the public RegExp constructor from the public create function. ... to call the *private* RegExp constructor from the public create function.
Geoffrey Garen
Comment 6 2010-06-24 14:12:27 PDT
Comment on attachment 59657 [details] Simplify hash lookups in RegExp caching r=me Nice cleanup.
WebKit Review Bot
Comment 7 2010-06-25 00:22:43 PDT
http://trac.webkit.org/changeset/61833 might have broken GTK Linux 64-bit Debug
Csaba Osztrogonác
Comment 8 2010-06-25 03:21:31 PDT
Reopen because it was rolled out by http://trac.webkit.org/changeset/61845
WebKit Commit Bot
Comment 9 2010-06-25 17:42:03 PDT
Comment on attachment 59657 [details] Simplify hash lookups in RegExp caching Clearing flags on attachment: 59657 Committed r61924: <http://trac.webkit.org/changeset/61924>
WebKit Commit Bot
Comment 10 2010-06-25 17:42:08 PDT
All reviewed patches have been landed. Closing bug.
Csaba Osztrogonác
Comment 11 2010-06-25 17:49:25 PDT
Rolled out and reopened again. Sorry, I missed to remove cq+ after the previous roll-out. :( Zoltan, if you would like to land cq+ -ed patch manually, next time please set cq- before it, and add comment to the bug with the revision number.
Adam Barth
Comment 12 2010-06-25 18:03:19 PDT
Or you can use "webkit-patch land" which will take care of all that for you.
Geoffrey Garen
Comment 13 2010-06-28 11:59:35 PDT
The reason this patch was crashing: In the case where the cache is full, it reuses the insertion iterator after evicting an item. You can't modify the table while maintaining an iterator into the table.
Geoffrey Garen
Comment 14 2010-06-28 12:15:44 PDT
Geoffrey Garen
Comment 15 2010-06-28 12:18:13 PDT
Oliver Hunt
Comment 16 2010-07-02 12:40:53 PDT
Comment on attachment 59921 [details] Patch r=me
Geoffrey Garen
Comment 17 2010-07-02 14:34:55 PDT
Committed revision 62405.
Note You need to log in before you can comment on or make changes to this bug.