Bug 80654

Summary: Allocate the RegExpObject's data with the Cell
Product: WebKit Reporter: Benjamin Poulain <benjamin>
Component: JavaScriptCoreAssignee: Benjamin Poulain <benjamin>
Status: RESOLVED FIXED    
Severity: Normal CC: barraclough, oliver
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch barraclough: review+

Description Benjamin Poulain 2012-03-08 16:26:17 PST
Currently, RegExpObject's data is allocated with new() in the constructor.

This is a problem in peacekeeper. In that case, the tests repeatedly create very small and simple regexp, and use them only one. Currently, the allocation and destruction of RegExpObjectData take more time than the math() itself.
Comment 1 Benjamin Poulain 2012-03-08 16:34:53 PST
Created attachment 130938 [details]
Patch
Comment 2 Benjamin Poulain 2012-03-08 16:37:56 PST
I also tried Sunspider but there is no change.

While trying this, I also noticed JSNonFinalObject has some spare memory:
   WriteBarrierBase<Unknown> m_inlineStorage[JSFinalObject_inlineStorageCapacity];
Since I am not familiar with that, I did not abuse it to store anything from RegExp. I don't know if anything could be done there?
Comment 3 Gavin Barraclough 2012-03-08 17:14:06 PST
(In reply to comment #2)
> I also tried Sunspider but there is no change.
> 
> While trying this, I also noticed JSNonFinalObject has some spare memory:
>    WriteBarrierBase<Unknown> m_inlineStorage[JSFinalObject_inlineStorageCapacity];
> Since I am not familiar with that, I did not abuse it to store anything from RegExp. I don't know if anything could be done there?

We used to have a concept of 'anonymous slots', to allocate storage within the object's property storage, but I think that has been removed.  ES6 will require support for 'private names', we may be able to use these to store internal values (e.g. the regexp) – once we have a mechanism to support this implemented!  Right now, no obvious clean way to use the internal property storage springs to mind.
Comment 4 Benjamin Poulain 2012-03-08 22:50:51 PST
Committed r110266: <http://trac.webkit.org/changeset/110266>