Bug 54988 - Re-create StructureTransitionTable class, encapsulate transition table
Summary: Re-create StructureTransitionTable class, encapsulate transition table
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 528+ (Nightly build)
Hardware: PC OS X 10.5
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-02-22 12:56 PST by Gavin Barraclough
Modified: 2011-02-22 13:54 PST (History)
1 user (show)

See Also:


Attachments
The patch (24.37 KB, patch)
2011-02-22 12:59 PST, Gavin Barraclough
sam: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Gavin Barraclough 2011-02-22 12:56:20 PST
The Structure class keeps a table of transitions to derived Structure types.  Since this table commonly contains a single entry we employ an optimization where instead of holding a map, we may hold a pointer directly to a single instance of the mapped type.  We use an additional bit of data to flag whether the pointer is currently pointing to a table of transitions, or a singleton transition.  Previously we had commonly used a pattern of storing data in the low bits of pointers, but had moved away from this since it causes false leaks to be reported by the leaks tool.  However in this case, the entries in the map are weak links - this pointer will never be responsible for keeping an object alive.  As such we can use this approach provided that the bit is set when a table is not in use (otherwise the table would appear to be leaked).

Additionally, the transition table currently allows to entries to exist for a given key - one specialized to a particular value, and one not specialized.  This is unnecessary, wasteful, and a little inconsistent.  (If you create an entry for a specialized value, then a non-specialized entry, both will exist.  If you create an entry for a non-specialized value, then try to create a specialized entry, only a non-specialized form will be allowed.)

This shows a small progression on v8.
Comment 1 Gavin Barraclough 2011-02-22 12:59:15 PST
Created attachment 83371 [details]
The patch
Comment 2 Build Bot 2011-02-22 13:19:41 PST
Attachment 83371 [details] did not build on win:
Build output: http://queues.webkit.org/results/7942469
Comment 3 Gavin Barraclough 2011-02-22 13:54:35 PST
Fixed in r79355.