Ignore:
Timestamp:
May 2, 2008, 3:29:47 AM (17 years ago)
Author:
[email protected]
Message:

Reviewed by Darin.

Make JavaScriptGlue and JavaScriptCore API functions implicitly call initializeThreading
for the sake of non-WebKit clients.

JavaScriptCore:

  • API/JSBase.cpp: (JSGarbageCollect):
  • API/JSContextRef.cpp: (JSGlobalContextCreate): These are the JavaScriptCore API bottlenecks. There are a few other JSStringRef and JSClassRef functions that can be called earlier, but they do not do anything that requires initializeThreading.
  • kjs/InitializeThreading.cpp: (KJS::doInitializeThreading): (KJS::initializeThreading): On Darwin, make the initialization happen under pthread_once, since there is no guarantee that non-WebKit clients won't try to call this function re-entrantly.
  • kjs/InitializeThreading.h:
  • wtf/Threading.h: Spell out initializeThreading contract.
  • wtf/ThreadingPthreads.cpp: (WTF::isMainThread): Make sure that results are correct on Darwin, even if threading was initialized from a secondary thread.

JavaScriptGlue:

  • JavaScriptGlue.cpp: (JSRunCreate): (JSCollect): (JSCreateJSArrayFromCFArray): (JSLockInterpreter): These are all possible JavaScriptGlue entry points.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/kjs/InitializeThreading.cpp

    r32807 r32808  
    4242namespace KJS {
    4343
    44 void initializeThreading()
     44#if PLATFORM(DARWIN)
     45static pthread_once_t initializeThreadingKeyOnce = PTHREAD_ONCE_INIT;
     46#endif
     47
     48static void initializeThreadingOnce()
    4549{
    4650    WTF::initializeThreading();
    4751#if USE(MULTIPLE_THREADS)
    48     if (!s_dtoaP5Mutex) {
    49         s_dtoaP5Mutex = new Mutex;
    50         Heap::threadHeap();
    51         UString::null();
    52         Identifier::initializeIdentifierThreading();
    53         CommonIdentifiers::shared();
    54         lexer();
    55         initDateMath();
    56         JSGlobalObject::threadClassInfoHashTables();
    57         JSGlobalObject::head();
     52    s_dtoaP5Mutex = new Mutex;
     53    Heap::threadHeap();
     54    UString::null();
     55    Identifier::initializeIdentifierThreading();
     56    CommonIdentifiers::shared();
     57    lexer();
     58    initDateMath();
     59    JSGlobalObject::threadClassInfoHashTables();
     60    JSGlobalObject::head();
     61#endif
     62}
     63
     64void initializeThreading()
     65{
     66#if PLATFORM(DARWIN)
     67    pthread_once(&initializeThreadingKeyOnce, initializeThreadingOnce);
     68#else
     69    static bool initializedThreading = false;
     70    if (!initializedThreading) {
     71        initializeThreadingOnce();
     72        initializedThreading = true;
    5873    }
    5974#endif
Note: See TracChangeset for help on using the changeset viewer.