[Webkit-unassigned] [Bug 144001] Make FunctionRareData allocation thread-safe

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Wed Apr 22 11:19:41 PDT 2015


https://bugs.webkit.org/show_bug.cgi?id=144001

--- Comment #3 from Basile Clement <basile_clement at apple.com> ---
I think the current fences are enough, here is my reasoning.

The two things we want to prevent are:

 1. A thread seeing a pointer to a not-yet-fully-created rare data from a JSFunction
 2. A thread seeing a pointer to a not-yet-fully-created Structure from an ObjectAllocationProfile

For 1., only the JS thread can be creating the rare data (in runtime/CommonSlowPaths.cpp or in dfg/DFGOperations.cpp), so we don't need to worry about concurrent writes, and we don't need any fences when *reading* the rare data from the JS thread. Thus we only need a storeStoreFence between the rare data creation and assignment to m_rareData in JSFunction::createAndInitializeRareData() to ensure that when the store to m_rareData is issued, the rare data has been properly created.

For the DFG compilation threads, the only place they can access the rare data is through JSFunction::rareData(), and so we only need a loadLoadFence there to ensure that when we see a non-null pointer in m_rareData, the pointed object will be seen as a fully created FunctionRareData.


For 2., the structure is created in ObjectAllocationProfile::initialize() (which appears to be called only by the JS thread as well, in bytecode/CodeBlock.cpp and on rare data initialization, which always happen in the JS thread), and read through ObjectAllocationProfile::structure() and ObjectAllocationProfile::inlineCapacity(), so following the same reasoning we put a storeStoreFence in ObjectAllocationProfile::initialize() and a loadLoadFence in ObjectAllocationProfile::structure() (and change ObjectAllocationProfile::inlineCapacity() to go through ObjectAllocationProfile::structure()).

We don't need a fence in ObjectAllocationProfile::clear() because clearing the structure is an atomic change.

Also notice that we don't care about the ObjectAllocationProfile's allocator as that is only used by ObjectAllocationProfile::initialize() and ObjectAllocationProfile::clear() that are always run in the JS thread.
ObjectAllocationProfile::isNull() could cause some trouble, but it looks like it is only used in the ObjectAllocationProfile::clear() check, which is also in the JS thread (trying to build w/ isNull() private to verify this).

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.webkit.org/pipermail/webkit-unassigned/attachments/20150422/0d0ce3fa/attachment.html>


More information about the webkit-unassigned mailing list