Bug 27759 - [V8] DOMData needs AtomicallyInitializedStatic
Summary: [V8] DOMData needs AtomicallyInitializedStatic
Status: RESOLVED INVALID
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore JavaScript (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-07-28 01:38 PDT by Adam Barth
Modified: 2014-12-16 00:48 PST (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Adam Barth 2009-07-28 01:38:15 PDT
> +
> +DOMData* DOMData::getCurrent()
> +{
> +    if (WTF::isMainThread())
> +        return getCurrentMainThread();
> +
> +    DEFINE_STATIC_LOCAL(WTF::ThreadSpecific<ChildThreadDOMData>, childThreadDOMData, ());

This looks like it has race conditions.  Please add a comment about why it
isn't or consider switching to using AtomicallyInitializedStatic (from
wtf/Threading.h).
Comment 1 Adam Barth 2009-07-28 01:38:54 PDT
I should say that those words in the issue report are Dave Levin's.  I don't understand the issue yet.
Comment 2 David Levin 2009-07-28 01:53:00 PDT
This one too:

> Index: WebCore/bindings/v8/DOMData.h
> +WTF::Mutex& DOMDataStore::allStoresMutex()
> +{
> +    DEFINE_STATIC_LOCAL(WTF::Mutex, staticDOMDataListMutex, ());

This looks like it has race conditions.  Please add a comment about why it
isn't or consider switching to using AtomicallyInitializedStatic (from
wtf/Threading.h).
Comment 3 anton muhin 2009-07-29 09:31:57 PDT
(In reply to comment #2)
> This one too:
> 
> > Index: WebCore/bindings/v8/DOMData.h
> > +WTF::Mutex& DOMDataStore::allStoresMutex()
> > +{
> > +    DEFINE_STATIC_LOCAL(WTF::Mutex, staticDOMDataListMutex, ());
> 
> This looks like it has race conditions.  Please add a comment about why it
> isn't or consider switching to using AtomicallyInitializedStatic (from
> wtf/Threading.h).

Just a minor comment.  If I did measurements right, AtomicallyInitializedStatic is rather expensive on Windows, so, please, be careful to measure performance implications.  Maybe sometimes it's easier to have plain static at least for main thread.

just my 2 cents.
Comment 4 David Levin 2009-07-29 09:40:01 PDT
>  If I did measurements right, AtomicallyInitializedStatic is rather expensive on Windows

Likely true.  I simply want something that is safe though (for anyone using the bindings in a multithreaded fashion).  Of course, there could be a (compile time or runtime) flag that indicates whether this level of safetly is needed.
Comment 5 Adam Barth 2009-07-29 10:37:58 PDT
I bet the main thread static is actually safe.  After all, you need to get a Worker wrapper before you can even create another thread.  :)
Comment 6 Brian Burg 2014-12-16 00:48:17 PST
Closing some V8-related work items.