Changeset 11284 in webkit for trunk/JavaScriptCore/kjs
- Timestamp:
- Nov 22, 2005, 9:41:23 PM (20 years ago)
- Location:
- trunk/JavaScriptCore/kjs
- Files:
-
- 2 added
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/collector.cpp
r11213 r11284 107 107 void* Collector::allocate(size_t s) 108 108 { 109 assert(Interpreter ::lockCount() > 0);109 assert(InterpreterLock::lockCount() > 0); 110 110 111 111 // collect if needed … … 394 394 bool Collector::collect() 395 395 { 396 assert(Interpreter ::lockCount() > 0);396 assert(InterpreterLock::lockCount() > 0); 397 397 398 398 if (InterpreterImp::s_hook) { -
trunk/JavaScriptCore/kjs/config.h
r10801 r11284 10 10 #define HAVE_SYS_TIME_H 1 11 11 #define HAVE_SYS_TIMEB_H 1 12 13 #define KJS_MULTIPLE_THREADS 1 12 14 13 15 #elif WIN32 -
trunk/JavaScriptCore/kjs/internal.cpp
r11213 r11284 74 74 75 75 #endif // APPLE_CHANGES 76 77 #if defined(KJS_MULTIPLE_THREADS) && KJS_MULTIPLE_THREADS78 79 static pthread_once_t interpreterLockOnce = PTHREAD_ONCE_INIT;80 static pthread_mutex_t interpreterLock;81 static int interpreterLockCount = 0;82 83 static void initializeInterpreterLock()84 {85 pthread_mutexattr_t attr;86 87 pthread_mutexattr_init(&attr);88 pthread_mutexattr_settype (&attr, PTHREAD_MUTEX_RECURSIVE);89 90 pthread_mutex_init(&interpreterLock, &attr);91 }92 93 static inline void lockInterpreter()94 {95 pthread_once(&interpreterLockOnce, initializeInterpreterLock);96 pthread_mutex_lock(&interpreterLock);97 interpreterLockCount++;98 Collector::registerThread();99 }100 101 static inline void unlockInterpreter()102 {103 interpreterLockCount--;104 pthread_mutex_unlock(&interpreterLock);105 }106 107 #else108 109 static inline void initializeInterpreterLock() { }110 static inline void lockInterpreter() { }111 static inline void unlockInterpreter() { }112 113 const int interpreterLockCount = 1;114 115 #endif116 76 117 77 // ------------------------------ UndefinedImp --------------------------------- … … 472 432 473 433 recursion = 0; 474 }475 476 void InterpreterImp::lock()477 {478 lockInterpreter();479 480 // FIXME: Hack-o-rama. To prevent construction of a global object with a null prototype (4342216),481 // we need to intialize our constants before the first object is constructed. InterpreterImp::lock()482 // is a good place to do this because you have to call it before doing any allocations. Once we change our483 // implementation to use immediate values, we should remove this code.484 ConstantValues::initIfNeeded();485 }486 487 int InterpreterImp::lockCount()488 {489 return interpreterLockCount;490 }491 492 void InterpreterImp::unlock()493 {494 unlockInterpreter();495 434 } 496 435 -
trunk/JavaScriptCore/kjs/internal.h
r11213 r11284 34 34 #include <kxmlcore/SharedPtr.h> 35 35 36 #if __APPLE__37 #define KJS_MULTIPLE_THREADS 138 #endif39 40 36 #define I18N_NOOP(s) s 41 37 … … 254 250 255 251 void initGlobalObject(); 256 static void lock();257 static void unlock();258 static int lockCount();259 252 260 253 void mark(); -
trunk/JavaScriptCore/kjs/interpreter.cpp
r10701 r11284 100 100 } 101 101 102 void Interpreter::lock()103 {104 InterpreterImp::lock();105 }106 107 void Interpreter::unlock()108 {109 InterpreterImp::unlock();110 }111 112 int Interpreter::lockCount()113 {114 return InterpreterImp::lockCount();115 }116 117 102 ExecState *Interpreter::globalExec() 118 103 { -
trunk/JavaScriptCore/kjs/interpreter.h
r10563 r11284 168 168 void initGlobalObject(); 169 169 170 static void lock();171 static void unlock();172 static int lockCount();173 174 170 /** 175 171 * Returns the execution state object which can be used to execute … … 483 479 }; 484 480 485 class InterpreterLock486 {487 public:488 InterpreterLock() { Interpreter::lock(); }489 ~InterpreterLock() { Interpreter::unlock(); }490 private:491 InterpreterLock(const InterpreterLock &);492 InterpreterLock &operator =(const InterpreterLock &);493 };494 495 481 } // namespace 496 482 -
trunk/JavaScriptCore/kjs/protect.h
r10857 r11284 28 28 #include "value.h" 29 29 #include "protected_values.h" 30 #include " interpreter.h"30 #include "JSLock.h" 31 31 32 32 namespace KJS { -
trunk/JavaScriptCore/kjs/protected_values.cpp
r10713 r11284 43 43 { 44 44 assert(k); 45 assert(Interpreter Imp::lockCount() > 0);45 assert(InterpreterLock::lockCount() > 0); 46 46 47 47 if (!_table) … … 72 72 { 73 73 assert(k); 74 assert(Interpreter Imp::lockCount() > 0);74 assert(InterpreterLock::lockCount() > 0); 75 75 76 76 if (SimpleNumber::is(k)) … … 122 122 { 123 123 assert(k); 124 assert(Interpreter Imp::lockCount() > 0);124 assert(InterpreterLock::lockCount() > 0); 125 125 126 126 if (SimpleNumber::is(k)) -
trunk/JavaScriptCore/kjs/testkjs.cpp
r10701 r11284 32 32 #include "interpreter.h" 33 33 #include "collector.h" 34 #include "JSLock.h" 34 35 35 36 using namespace KJS; … … 63 64 return Undefined(); 64 65 case GC: 65 Interpreter::lock(); 66 { 67 InterpreterLock lock; 66 68 Collector::collect(); 67 Interpreter::unlock();69 } 68 70 break; 69 71 default:
Note:
See TracChangeset
for help on using the changeset viewer.