Changeset 1789 in webkit for trunk/JavaScriptCore/kjs/collector.cpp
- Timestamp:
- Aug 9, 2002, 4:24:41 PM (23 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/collector.cpp
r1371 r1789 67 67 } 68 68 69 #ifdef APPLE_CHANGES70 static pthread_mutex_t collectorLock = PTHREAD_MUTEX_INITIALIZER;71 static pthread_cond_t collectorCondition = PTHREAD_COND_INITIALIZER;72 static unsigned collectorLockCount = 0;73 static pthread_t collectorLockThread;74 #endif75 69 CollectorBlock* Collector::root = 0L; 76 70 CollectorBlock* Collector::currentBlock = 0L; … … 91 85 if (s == 0) 92 86 return 0L; 93 94 #ifdef APPLE_CHANGES95 lock();96 #endif97 87 98 88 // Try and deal with memory requirements in a scalable way. Simple scripts … … 162 152 } 163 153 164 #ifdef APPLE_CHANGES165 unlock();166 #endif167 168 154 return m; 169 155 } … … 174 160 bool Collector::collect() 175 161 { 176 #ifdef APPLE_CHANGES177 lock();178 #endif179 162 #ifdef KJS_DEBUG_MEM 180 163 fprintf(stderr,"Collector::collect()\n"); … … 287 270 finalCheck(); 288 271 #endif 289 #ifdef APPLE_CHANGES290 unlock();291 #endif292 272 return deleted; 293 273 } … … 296 276 void Collector::finalCheck() 297 277 { 298 #ifdef APPLE_CHANGES299 lock();300 #endif301 278 CollectorBlock *block = root; 302 279 while (block) { … … 314 291 block = block->next; 315 292 } 316 #ifdef APPLE_CHANGES317 unlock();318 #endif319 293 } 320 294 #endif … … 323 297 int Collector::numInterpreters() 324 298 { 325 lock();326 299 int count = 0; 327 300 if (InterpreterImp::s_hook) { … … 332 305 } while (scr != InterpreterImp::s_hook); 333 306 } 334 unlock();335 307 return count; 336 308 } … … 338 310 int Collector::numGCNotAllowedObjects() 339 311 { 340 lock();341 312 int count = 0; 342 313 CollectorBlock *block = root; … … 353 324 block = block->next; 354 325 } 355 unlock();356 326 return count; 357 327 } … … 359 329 int Collector::numReferencedObjects() 360 330 { 361 lock();362 331 int count = 0; 363 332 CollectorBlock *block = root; … … 374 343 block = block->next; 375 344 } 376 unlock();377 345 return count; 378 346 } 379 347 380 void Collector::lock() 381 { 382 pthread_mutex_lock(&collectorLock); 383 while (collectorLockCount > 0 && 384 !pthread_equal(pthread_self(), collectorLockThread)) { 385 pthread_cond_wait(&collectorCondition, &collectorLock); 386 } 387 collectorLockThread = pthread_self(); 388 collectorLockCount++; 389 pthread_mutex_unlock(&collectorLock); 390 } 391 392 void Collector::unlock() 393 { 394 pthread_mutex_lock(&collectorLock); 395 collectorLockCount--; 396 if (collectorLockCount == 0) { 397 pthread_cond_signal(&collectorCondition); 398 } 399 pthread_mutex_unlock(&collectorLock); 400 } 401 402 #endif 348 #endif
Note:
See TracChangeset
for help on using the changeset viewer.