Bug 135895

Summary: Make bmalloc::PerThread work without C++ thread local storage
Product: WebKit Reporter: Daniel Bates <dbates>
Component: New BugsAssignee: Daniel Bates <dbates>
Status: RESOLVED FIXED    
Severity: Normal CC: ggaren
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: All   
OS: All   
Attachments:
Description Flags
Patch ggaren: review+

Description Daniel Bates 2014-08-13 12:30:34 PDT
Following up on Geoffrey Garen's comment (bug #135848, comment 4), we should look to remove the hardcoded constant __PTK_FRAMEWORK_JAVASCRIPTCORE_KEY0, which imposes a maintenance burden as we need to keep its value synchronized with the value of a macro define by the same name in System/pthread_machdep.h. This constant was hardcoded because the iOS public SDK neither includes the header System/pthread_machdep.h nor supports the use of the thread local storage attribute __thread as of the time of writing.

One alternative to hardcoding the constant __PTK_FRAMEWORK_JAVASCRIPTCORE_KEY0 is to add logic for toolchains that don't support C++ thread local storage to initialize a shared Pthread key exactly once (say, using std::call_once()). Then we would use a similar approach to the System/pthread_machdep.h logic in <http://trac.webkit.org/browser/trunk/Source/bmalloc/bmalloc/PerThread.h?rev=166956#L56> and explicitly save/retrieve the thread-specific data using this shared key and pthread_{get, set}specific().
Comment 1 Daniel Bates 2014-08-13 14:12:24 PDT
Created attachment 236553 [details]
Patch
Comment 2 Geoffrey Garen 2014-08-13 14:16:58 PDT
Comment on attachment 236553 [details]
Patch

r=me

The #ifdefs are starting to get gross, but I don't have a better suggestion :/.
Comment 3 Daniel Bates 2014-08-13 22:00:49 PDT
Committed r172576: <http://trac.webkit.org/changeset/172576>
Comment 4 Daniel Bates 2014-08-13 22:12:11 PDT
Committed build fix in <http://trac.webkit.org/changeset/172577>.