hotspot/src/share/vm/runtime/synchronizer.cpp
changeset 46484 688e3a206b86
parent 46474 c872a196b75f
child 46495 34f7d403039f
equal deleted inserted replaced
46483:94ffd2984ec9 46484:688e3a206b86
  1281 //
  1281 //
  1282 // Also return the monitors of a moribund thread's omInUseList to
  1282 // Also return the monitors of a moribund thread's omInUseList to
  1283 // a global gOmInUseList under the global list lock so these
  1283 // a global gOmInUseList under the global list lock so these
  1284 // will continue to be scanned.
  1284 // will continue to be scanned.
  1285 //
  1285 //
  1286 // We currently call omFlush() from the Thread:: dtor _after the thread
  1286 // We currently call omFlush() from Threads::remove() _before the thread
  1287 // has been excised from the thread list and is no longer a mutator.
  1287 // has been excised from the thread list and is no longer a mutator.
  1288 // That means that omFlush() can run concurrently with a safepoint and
  1288 // This means that omFlush() can not run concurrently with a safepoint and
  1289 // the scavenge operator.  Calling omFlush() from JavaThread::exit() might
  1289 // interleave with the scavenge operator. In particular, this ensures that
  1290 // be a better choice as we could safely reason that that the JVM is
  1290 // the thread's monitors are scanned by a GC safepoint, either via
  1291 // not at a safepoint at the time of the call, and thus there could
  1291 // Thread::oops_do() (if safepoint happens before omFlush()) or via
  1292 // be not inopportune interleavings between omFlush() and the scavenge
  1292 // ObjectSynchronizer::oops_do() (if it happens after omFlush() and the thread's
  1293 // operator.
  1293 // monitors have been transferred to the global in-use list).
  1294 
  1294 
  1295 void ObjectSynchronizer::omFlush(Thread * Self) {
  1295 void ObjectSynchronizer::omFlush(Thread * Self) {
  1296   ObjectMonitor * list = Self->omFreeList;  // Null-terminated SLL
  1296   ObjectMonitor * list = Self->omFreeList;  // Null-terminated SLL
  1297   Self->omFreeList = NULL;
  1297   Self->omFreeList = NULL;
  1298   ObjectMonitor * tail = NULL;
  1298   ObjectMonitor * tail = NULL;
  1336   Thread::muxAcquire(&gListLock, "omFlush");
  1336   Thread::muxAcquire(&gListLock, "omFlush");
  1337   if (tail != NULL) {
  1337   if (tail != NULL) {
  1338     tail->FreeNext = gFreeList;
  1338     tail->FreeNext = gFreeList;
  1339     gFreeList = list;
  1339     gFreeList = list;
  1340     gMonitorFreeCount += tally;
  1340     gMonitorFreeCount += tally;
       
  1341     assert(Self->omFreeCount == tally, "free-count off");
       
  1342     Self->omFreeCount = 0;
  1341   }
  1343   }
  1342 
  1344 
  1343   if (inUseTail != NULL) {
  1345   if (inUseTail != NULL) {
  1344     inUseTail->FreeNext = gOmInUseList;
  1346     inUseTail->FreeNext = gOmInUseList;
  1345     gOmInUseList = inUseList;
  1347     gOmInUseList = inUseList;