Changeset 32808 in webkit for trunk/JavaScriptCore/API/JSBase.cpp


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/API/JSBase.cpp

    r32807 r32808  
    3030#include "APICast.h"
    3131#include <kjs/ExecState.h>
     32#include <kjs/InitializeThreading.h>
     33#include <kjs/interpreter.h>
    3234#include <kjs/JSGlobalObject.h>
    3335#include <kjs/JSLock.h>
    34 #include <kjs/interpreter.h>
    3536#include <kjs/object.h>
    3637
     
    7778}
    7879
    79 void JSGarbageCollect(JSContextRef)
     80void JSGarbageCollect(JSContextRef ctx)
    8081{
     82    // Unlikely, but it is legal to call JSGarbageCollect(0) before actually doing anything that would implicitly call initializeThreading().
     83    if (!ctx)
     84        initializeThreading();
     85
    8186    JSLock lock;
    8287
Note: See TracChangeset for help on using the changeset viewer.