Changeset 32808 in webkit for trunk/JavaScriptCore
- Timestamp:
- May 2, 2008, 3:29:47 AM (17 years ago)
- Location:
- trunk/JavaScriptCore
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/API/JSBase.cpp
r32807 r32808 30 30 #include "APICast.h" 31 31 #include <kjs/ExecState.h> 32 #include <kjs/InitializeThreading.h> 33 #include <kjs/interpreter.h> 32 34 #include <kjs/JSGlobalObject.h> 33 35 #include <kjs/JSLock.h> 34 #include <kjs/interpreter.h>35 36 #include <kjs/object.h> 36 37 … … 77 78 } 78 79 79 void JSGarbageCollect(JSContextRef )80 void JSGarbageCollect(JSContextRef ctx) 80 81 { 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 81 86 JSLock lock; 82 87 -
trunk/JavaScriptCore/API/JSContextRef.cpp
r31962 r32808 29 29 30 30 #include "APICast.h" 31 #include "InitializeThreading.h" 31 32 #include "JSCallbackObject.h" 32 33 #include "JSClassRef.h" … … 39 40 JSGlobalContextRef JSGlobalContextCreate(JSClassRef globalObjectClass) 40 41 { 42 initializeThreading(); 43 41 44 JSLock lock; 42 45 -
trunk/JavaScriptCore/ChangeLog
r32807 r32808 1 2008-05-02 Alexey Proskuryakov <[email protected]> 2 3 Reviewed by Darin. 4 5 Make JavaScriptGlue and JavaScriptCore API functions implicitly call initializeThreading 6 for the sake of non-WebKit clients. 7 8 * API/JSBase.cpp: 9 (JSGarbageCollect): 10 * API/JSContextRef.cpp: 11 (JSGlobalContextCreate): 12 These are the JavaScriptCore API bottlenecks. There are a few other JSStringRef 13 and JSClassRef functions that can be called earlier, but they do not do anything that 14 requires initializeThreading. 15 16 * kjs/InitializeThreading.cpp: 17 (KJS::doInitializeThreading): 18 (KJS::initializeThreading): 19 On Darwin, make the initialization happen under pthread_once, since there is no guarantee 20 that non-WebKit clients won't try to call this function re-entrantly. 21 22 * kjs/InitializeThreading.h: 23 * wtf/Threading.h: 24 Spell out initializeThreading contract. 25 26 * wtf/ThreadingPthreads.cpp: (WTF::isMainThread): Make sure that results are correct on 27 Darwin, even if threading was initialized from a secondary thread. 28 1 29 2008-05-02 Alexey Proskuryakov <[email protected]> 2 30 -
trunk/JavaScriptCore/kjs/InitializeThreading.cpp
r32807 r32808 42 42 namespace KJS { 43 43 44 void initializeThreading() 44 #if PLATFORM(DARWIN) 45 static pthread_once_t initializeThreadingKeyOnce = PTHREAD_ONCE_INIT; 46 #endif 47 48 static void initializeThreadingOnce() 45 49 { 46 50 WTF::initializeThreading(); 47 51 #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 64 void 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; 58 73 } 59 74 #endif -
trunk/JavaScriptCore/kjs/InitializeThreading.h
r31404 r32808 32 32 namespace KJS { 33 33 34 // This function must be called from the main thread. It is safe to call it repeatedly. 35 // Darwin is an exception to this rule: it is OK to call this function from any thread, even reentrantly. 34 36 void initializeThreading(); 35 37 -
trunk/JavaScriptCore/wtf/Threading.h
r31971 r32808 240 240 }; 241 241 242 // This function must be called from the main thread. It is safe to call it repeatedly. 243 // Darwin is an exception to this rule: it is OK to call it from any thread, the only requirement is that the calls are not reentrant. 242 244 void initializeThreading(); 243 245 -
trunk/JavaScriptCore/wtf/ThreadingPthreads.cpp
r31939 r32808 40 40 Mutex* atomicallyInitializedStaticMutex; 41 41 42 static ThreadIdentifier mainThreadIdentifier; 42 static ThreadIdentifier mainThreadIdentifier; // More precisely, the thread that was the first to call initializeThreading(). 43 43 44 44 static Mutex& threadMapMutex() … … 151 151 bool isMainThread() 152 152 { 153 #if PLATFORM(DARWIN) 154 return pthread_main_np(); 155 #else 153 156 return currentThread() == mainThreadIdentifier; 157 #endif 154 158 } 155 159
Note:
See TracChangeset
for help on using the changeset viewer.