1.1 --- a/src/share/vm/gc_implementation/concurrentMarkSweep/cmsLockVerifier.cpp Wed Dec 16 15:12:51 2009 -0800 1.2 +++ b/src/share/vm/gc_implementation/concurrentMarkSweep/cmsLockVerifier.cpp Wed Dec 23 09:23:54 2009 -0800 1.3 @@ -32,7 +32,9 @@ 1.4 // threads. The second argument is in support of an extra locking 1.5 // check for CFL spaces' free list locks. 1.6 #ifndef PRODUCT 1.7 -void CMSLockVerifier::assert_locked(const Mutex* lock, const Mutex* p_lock) { 1.8 +void CMSLockVerifier::assert_locked(const Mutex* lock, 1.9 + const Mutex* p_lock1, 1.10 + const Mutex* p_lock2) { 1.11 if (!Universe::is_fully_initialized()) { 1.12 return; 1.13 } 1.14 @@ -40,7 +42,7 @@ 1.15 Thread* myThread = Thread::current(); 1.16 1.17 if (lock == NULL) { // a "lock-free" structure, e.g. MUT, protected by CMS token 1.18 - assert(p_lock == NULL, "Unexpected state"); 1.19 + assert(p_lock1 == NULL && p_lock2 == NULL, "Unexpected caller error"); 1.20 if (myThread->is_ConcurrentGC_thread()) { 1.21 // This test might have to change in the future, if there can be 1.22 // multiple peer CMS threads. But for now, if we're testing the CMS 1.23 @@ -60,36 +62,39 @@ 1.24 return; 1.25 } 1.26 1.27 - if (ParallelGCThreads == 0) { 1.28 + if (myThread->is_VM_thread() 1.29 + || myThread->is_ConcurrentGC_thread() 1.30 + || myThread->is_Java_thread()) { 1.31 + // Make sure that we are holding the associated lock. 1.32 assert_lock_strong(lock); 1.33 + // The checking of p_lock is a spl case for CFLS' free list 1.34 + // locks: we make sure that none of the parallel GC work gang 1.35 + // threads are holding "sub-locks" of freeListLock(). We check only 1.36 + // the parDictionaryAllocLock because the others are too numerous. 1.37 + // This spl case code is somewhat ugly and any improvements 1.38 + // are welcome. 1.39 + assert(p_lock1 == NULL || !p_lock1->is_locked() || p_lock1->owned_by_self(), 1.40 + "Possible race between this and parallel GC threads"); 1.41 + assert(p_lock2 == NULL || !p_lock2->is_locked() || p_lock2->owned_by_self(), 1.42 + "Possible race between this and parallel GC threads"); 1.43 + } else if (myThread->is_GC_task_thread()) { 1.44 + // Make sure that the VM or CMS thread holds lock on our behalf 1.45 + // XXX If there were a concept of a gang_master for a (set of) 1.46 + // gang_workers, we could have used the identity of that thread 1.47 + // for checking ownership here; for now we just disjunct. 1.48 + assert(lock->owner() == VMThread::vm_thread() || 1.49 + lock->owner() == ConcurrentMarkSweepThread::cmst(), 1.50 + "Should be locked by VM thread or CMS thread on my behalf"); 1.51 + if (p_lock1 != NULL) { 1.52 + assert_lock_strong(p_lock1); 1.53 + } 1.54 + if (p_lock2 != NULL) { 1.55 + assert_lock_strong(p_lock2); 1.56 + } 1.57 } else { 1.58 - if (myThread->is_VM_thread() 1.59 - || myThread->is_ConcurrentGC_thread() 1.60 - || myThread->is_Java_thread()) { 1.61 - // Make sure that we are holding the associated lock. 1.62 - assert_lock_strong(lock); 1.63 - // The checking of p_lock is a spl case for CFLS' free list 1.64 - // locks: we make sure that none of the parallel GC work gang 1.65 - // threads are holding "sub-locks" of freeListLock(). We check only 1.66 - // the parDictionaryAllocLock because the others are too numerous. 1.67 - // This spl case code is somewhat ugly and any improvements 1.68 - // are welcome XXX FIX ME!! 1.69 - if (p_lock != NULL) { 1.70 - assert(!p_lock->is_locked() || p_lock->owned_by_self(), 1.71 - "Possible race between this and parallel GC threads"); 1.72 - } 1.73 - } else if (myThread->is_GC_task_thread()) { 1.74 - // Make sure that the VM or CMS thread holds lock on our behalf 1.75 - // XXX If there were a concept of a gang_master for a (set of) 1.76 - // gang_workers, we could have used the identity of that thread 1.77 - // for checking ownership here; for now we just disjunct. 1.78 - assert(lock->owner() == VMThread::vm_thread() || 1.79 - lock->owner() == ConcurrentMarkSweepThread::cmst(), 1.80 - "Should be locked by VM thread or CMS thread on my behalf"); 1.81 - } else { 1.82 - // Make sure we didn't miss some obscure corner case 1.83 - ShouldNotReachHere(); 1.84 - } 1.85 + // Make sure we didn't miss some other thread type calling into here; 1.86 + // perhaps as a result of future VM evolution. 1.87 + ShouldNotReachHere(); 1.88 } 1.89 } 1.90 #endif