Changeset 20115 in webkit for trunk/JavaScriptCore/kjs
- Timestamp:
- Mar 12, 2007, 8:09:37 AM (18 years ago)
- Location:
- trunk/JavaScriptCore/kjs
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/JSLock.cpp
r20104 r20115 54 54 } 55 55 ++JSLockCount; 56 57 Collector::registerThread();58 56 } 59 57 … … 68 66 pthread_mutex_unlock(&JSMutex); 69 67 } 68 } 69 70 void JSLock::registerThread() 71 { 72 Collector::registerThread(); 70 73 } 71 74 … … 101 104 } 102 105 106 void JSLock::registerThread() 107 { 108 } 109 103 110 JSLock::DropAllLocks::DropAllLocks() 104 111 { -
trunk/JavaScriptCore/kjs/JSLock.h
r20104 r20115 31 31 // To make it safe to use JavaScript on multiple threads, it is 32 32 // important to lock before doing anything that allocates a 33 // garbage-collected object or which may affect other shared state 34 // such as the protect count hash table. The simplest way to do 35 // this is by having a local JSLock object for the scope 36 // where the lock must be held. The lock is recursive so nesting 37 // is ok. 33 // JavaScript data structure or that interacts with shared state 34 // such as the protect count hash table. The simplest way to lock 35 // is to create a local JSLock object in the scope where the lock 36 // must be held. The lock is recursive so nesting is ok. The JSLock 37 // object also acts as a convenience short-hand for running important 38 // initialization routines. 38 39 39 40 // To avoid deadlock, sometimes it is necessary to temporarily … … 48 49 class JSLock : Noncopyable { 49 50 public: 50 JSLock() 51 JSLock() 51 52 { 52 53 lock(); 54 registerThread(); 53 55 } 54 56 … … 61 63 static void unlock(); 62 64 static int lockCount(); 65 66 static void registerThread(); 63 67 64 68 class DropAllLocks : Noncopyable { -
trunk/JavaScriptCore/kjs/collector.cpp
r20019 r20115 237 237 Collector::Thread *thread = (Collector::Thread *)data; 238 238 239 // Can't use JSLock convenience object here because we don't want to re-register 240 // an exiting thread. 241 JSLock::lock(); 242 239 243 if (registeredThreads == thread) { 240 244 registeredThreads = registeredThreads->next; 241 245 } else { 242 246 Collector::Thread *last = registeredThreads; 243 for (Collector::Thread *t = registeredThreads->next; t != NULL; t = t->next) { 247 Collector::Thread *t; 248 for (t = registeredThreads->next; t != NULL; t = t->next) { 244 249 if (t == thread) { 245 250 last->next = t->next; … … 248 253 last = t; 249 254 } 250 } 255 ASSERT(t); // If t is NULL, we never found ourselves in the list. 256 } 257 258 JSLock::unlock(); 251 259 252 260 delete thread; … … 260 268 void Collector::registerThread() 261 269 { 270 ASSERT(JSLock::lockCount() > 0); 271 262 272 pthread_once(®isteredThreadKeyOnce, initializeRegisteredThreadKey); 263 273
Note:
See TracChangeset
for help on using the changeset viewer.