Bug 135895 - Make bmalloc::PerThread work without C++ thread local storage
Summary: Make bmalloc::PerThread work without C++ thread local storage
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Daniel Bates
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-08-13 12:30 PDT by Daniel Bates
Modified: 2014-08-13 22:12 PDT (History)
1 user (show)

See Also:


Attachments
Patch (5.50 KB, patch)
2014-08-13 14:12 PDT, Daniel Bates
ggaren: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
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>.