Changeset 11304 in webkit for trunk/JavaScriptCore/kjs
- Timestamp:
- Nov 26, 2005, 11:54:53 PM (20 years ago)
- Location:
- trunk/JavaScriptCore/kjs
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/JSLock.cpp
r11284 r11304 34 34 static int interpreterLockCount = 0; 35 35 36 static void initialize InterpreterLock()36 static void initializeJSLock() 37 37 { 38 38 pthread_mutexattr_t attr; … … 44 44 } 45 45 46 void InterpreterLock::lock()46 void JSLock::lock() 47 47 { 48 pthread_once(&interpreterLockOnce, initialize InterpreterLock);48 pthread_once(&interpreterLockOnce, initializeJSLock); 49 49 pthread_mutex_lock(&interpreterLock); 50 50 interpreterLockCount++; … … 58 58 } 59 59 60 void InterpreterLock::unlock()60 void JSLock::unlock() 61 61 { 62 62 interpreterLockCount--; … … 70 70 const int interpreterLockCount = 1; 71 71 72 void InterpreterLock::lock()72 void JSLock::lock() 73 73 { 74 74 } 75 75 76 void InterpreterLock::unlock()76 void JSLock::unlock() 77 77 { 78 78 } … … 80 80 #endif 81 81 82 int InterpreterLock::lockCount()82 int JSLock::lockCount() 83 83 { 84 84 return interpreterLockCount; 85 85 } 86 86 87 InterpreterLock::DropAllLocks::DropAllLocks()87 JSLock::DropAllLocks::DropAllLocks() 88 88 { 89 int lockCount = InterpreterLock::lockCount();89 int lockCount = JSLock::lockCount(); 90 90 for (int i = 0; i < lockCount; i++) { 91 InterpreterLock::unlock();91 JSLock::unlock(); 92 92 } 93 93 m_lockCount = lockCount; 94 94 } 95 95 96 InterpreterLock::DropAllLocks::~DropAllLocks()96 JSLock::DropAllLocks::~DropAllLocks() 97 97 { 98 98 int lockCount = m_lockCount; 99 99 for (int i = 0; i < lockCount; i++) { 100 InterpreterLock::lock();100 JSLock::lock(); 101 101 } 102 102 } -
trunk/JavaScriptCore/kjs/JSLock.h
r11284 r11304 30 30 // garbage-collected object or which may affect other shared state 31 31 // such as the protect count hash table. The simplest way to do 32 // this is by having a local InterpreterLock object for the scope32 // this is by having a local JSLock object for the scope 33 33 // where the lock must be held. The lock is recursive so nesting 34 34 // is ok. … … 39 39 // code that doesn't require the lock, and reacquire the right 40 40 // number of locks at the end. You can do this by constructing a 41 // locally scoped InterpreterLock::DropAllLocks object.41 // locally scoped JSLock::DropAllLocks object. 42 42 43 class InterpreterLock43 class JSLock 44 44 { 45 45 public: 46 InterpreterLock()46 JSLock() 47 47 { 48 48 lock(); 49 49 } 50 ~ InterpreterLock() {50 ~JSLock() { 51 51 unlock(); 52 52 } … … 68 68 69 69 private: 70 InterpreterLock(const InterpreterLock&);71 InterpreterLock& operator=(const InterpreterLock&);70 JSLock(const JSLock&); 71 JSLock& operator=(const JSLock&); 72 72 }; 73 73 -
trunk/JavaScriptCore/kjs/collector.cpp
r11284 r11304 107 107 void* Collector::allocate(size_t s) 108 108 { 109 assert( InterpreterLock::lockCount() > 0);109 assert(JSLock::lockCount() > 0); 110 110 111 111 // collect if needed … … 394 394 bool Collector::collect() 395 395 { 396 assert( InterpreterLock::lockCount() > 0);396 assert(JSLock::lockCount() > 0); 397 397 398 398 if (InterpreterImp::s_hook) { -
trunk/JavaScriptCore/kjs/internal.cpp
r11284 r11304 409 409 // add this interpreter to the global chain 410 410 // as a root set for garbage collection 411 InterpreterLock lock;411 JSLock lock; 412 412 413 413 m_interpreter = interp; … … 564 564 //fprintf(stderr,"InterpreterImp::clear\n"); 565 565 // remove from global chain (see init()) 566 InterpreterLock lock;566 JSLock lock; 567 567 568 568 next->prev = prev; … … 591 591 bool InterpreterImp::checkSyntax(const UString &code) 592 592 { 593 InterpreterLock lock;593 JSLock lock; 594 594 595 595 // Parser::parse() returns 0 in a syntax error occurs, so we just check for that … … 600 600 Completion InterpreterImp::evaluate(const UString &code, ValueImp *thisV, const UString &sourceURL, int startingLineNumber) 601 601 { 602 InterpreterLock lock;602 JSLock lock; 603 603 604 604 // prevent against infinite recursion -
trunk/JavaScriptCore/kjs/interpreter.cpp
r11284 r11304 121 121 #if APPLE_CHANGES 122 122 if (shouldPrintExceptions() && comp.complType() == Throw) { 123 InterpreterLock lock;123 JSLock lock; 124 124 ExecState *exec = rep->globalExec(); 125 125 char *f = strdup(sourceURL.ascii()); -
trunk/JavaScriptCore/kjs/protect.h
r11284 r11304 82 82 { 83 83 if (ptr) { 84 InterpreterLock lock;84 JSLock lock; 85 85 gcProtect(ptr); 86 86 } … … 91 91 { 92 92 if (T *ptr = m_ptr) { 93 InterpreterLock lock;93 JSLock lock; 94 94 gcProtect(ptr); 95 95 } … … 99 99 { 100 100 if (T *ptr = m_ptr) { 101 InterpreterLock lock;101 JSLock lock; 102 102 gcUnprotect(ptr); 103 103 } … … 108 108 { 109 109 if (T *ptr = m_ptr) { 110 InterpreterLock lock;110 JSLock lock; 111 111 gcProtect(ptr); 112 112 } … … 115 115 template <class T> ProtectedPtr<T> &ProtectedPtr<T>::operator=(const ProtectedPtr<T> &o) 116 116 { 117 InterpreterLock lock;117 JSLock lock; 118 118 T *optr = o.m_ptr; 119 119 gcProtectNullTolerant(optr); … … 125 125 template <class T> inline ProtectedPtr<T> &ProtectedPtr<T>::operator=(T *optr) 126 126 { 127 InterpreterLock lock;127 JSLock lock; 128 128 gcProtectNullTolerant(optr); 129 129 gcUnprotectNullTolerant(m_ptr); -
trunk/JavaScriptCore/kjs/protected_reference.h
r10857 r11304 35 35 : Reference(r) 36 36 { 37 InterpreterLock lock;37 JSLock lock; 38 38 gcProtectNullTolerant(base); 39 39 } … … 41 41 ~ProtectedReference() 42 42 { 43 InterpreterLock lock;43 JSLock lock; 44 44 gcUnprotectNullTolerant(base); 45 45 } … … 47 47 ProtectedReference& operator=(const Reference &r) 48 48 { 49 InterpreterLock lock;49 JSLock lock; 50 50 ValueImp *old = base; 51 51 Reference::operator=(r); -
trunk/JavaScriptCore/kjs/protected_values.cpp
r11284 r11304 43 43 { 44 44 assert(k); 45 assert( InterpreterLock::lockCount() > 0);45 assert(JSLock::lockCount() > 0); 46 46 47 47 if (!_table) … … 72 72 { 73 73 assert(k); 74 assert( InterpreterLock::lockCount() > 0);74 assert(JSLock::lockCount() > 0); 75 75 76 76 if (SimpleNumber::is(k)) … … 122 122 { 123 123 assert(k); 124 assert( InterpreterLock::lockCount() > 0);124 assert(JSLock::lockCount() > 0); 125 125 126 126 if (SimpleNumber::is(k)) -
trunk/JavaScriptCore/kjs/testkjs.cpp
r11284 r11304 65 65 case GC: 66 66 { 67 InterpreterLock lock;67 JSLock lock; 68 68 Collector::collect(); 69 69 } … … 105 105 bool ret = true; 106 106 { 107 InterpreterLock lock;107 JSLock lock; 108 108 109 109 ObjectImp *global(new GlobalImp());
Note:
See TracChangeset
for help on using the changeset viewer.