src/share/vm/gc_implementation/concurrentMarkSweep/cmsLockVerifier.cpp

Thu, 27 May 2010 19:08:38 -0700

author
trims
date
Thu, 27 May 2010 19:08:38 -0700
changeset 1907
c18cbe5936b8
parent 1580
e018e6884bd8
child 2314
f95d63e2154a
permissions
-rw-r--r--

6941466: Oracle rebranding changes for Hotspot repositories
Summary: Change all the Sun copyrights to Oracle copyright
Reviewed-by: ohair

duke@435 1 /*
trims@1907 2 * Copyright (c) 2002, 2005, Oracle and/or its affiliates. All rights reserved.
duke@435 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@435 4 *
duke@435 5 * This code is free software; you can redistribute it and/or modify it
duke@435 6 * under the terms of the GNU General Public License version 2 only, as
duke@435 7 * published by the Free Software Foundation.
duke@435 8 *
duke@435 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@435 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@435 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@435 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@435 13 * accompanied this code).
duke@435 14 *
duke@435 15 * You should have received a copy of the GNU General Public License version
duke@435 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@435 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@435 18 *
trims@1907 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1907 20 * or visit www.oracle.com if you need additional information or have any
trims@1907 21 * questions.
duke@435 22 *
duke@435 23 */
duke@435 24
duke@435 25 # include "incls/_precompiled.incl"
duke@435 26 # include "incls/_cmsLockVerifier.cpp.incl"
duke@435 27
duke@435 28 ///////////// Locking verification specific to CMS //////////////
duke@435 29 // Much like "assert_lock_strong()", except that it relaxes the
duke@435 30 // assertion somewhat for the parallel GC case, where VM thread
duke@435 31 // or the CMS thread might hold the lock on behalf of the parallel
duke@435 32 // threads. The second argument is in support of an extra locking
duke@435 33 // check for CFL spaces' free list locks.
duke@435 34 #ifndef PRODUCT
ysr@1580 35 void CMSLockVerifier::assert_locked(const Mutex* lock,
ysr@1580 36 const Mutex* p_lock1,
ysr@1580 37 const Mutex* p_lock2) {
duke@435 38 if (!Universe::is_fully_initialized()) {
duke@435 39 return;
duke@435 40 }
duke@435 41
duke@435 42 Thread* myThread = Thread::current();
duke@435 43
duke@435 44 if (lock == NULL) { // a "lock-free" structure, e.g. MUT, protected by CMS token
ysr@1580 45 assert(p_lock1 == NULL && p_lock2 == NULL, "Unexpected caller error");
duke@435 46 if (myThread->is_ConcurrentGC_thread()) {
duke@435 47 // This test might have to change in the future, if there can be
duke@435 48 // multiple peer CMS threads. But for now, if we're testing the CMS
duke@435 49 assert(myThread == ConcurrentMarkSweepThread::cmst(),
duke@435 50 "In CMS, CMS thread is the only Conc GC thread.");
duke@435 51 assert(ConcurrentMarkSweepThread::cms_thread_has_cms_token(),
duke@435 52 "CMS thread should have CMS token");
duke@435 53 } else if (myThread->is_VM_thread()) {
duke@435 54 assert(ConcurrentMarkSweepThread::vm_thread_has_cms_token(),
duke@435 55 "VM thread should have CMS token");
duke@435 56 } else {
duke@435 57 // Token should be held on our behalf by one of the other
duke@435 58 // of CMS or VM thread; not enough easily testable
duke@435 59 // state info to test which here.
duke@435 60 assert(myThread->is_GC_task_thread(), "Unexpected thread type");
duke@435 61 }
duke@435 62 return;
duke@435 63 }
duke@435 64
ysr@1580 65 if (myThread->is_VM_thread()
ysr@1580 66 || myThread->is_ConcurrentGC_thread()
ysr@1580 67 || myThread->is_Java_thread()) {
ysr@1580 68 // Make sure that we are holding the associated lock.
duke@435 69 assert_lock_strong(lock);
ysr@1580 70 // The checking of p_lock is a spl case for CFLS' free list
ysr@1580 71 // locks: we make sure that none of the parallel GC work gang
ysr@1580 72 // threads are holding "sub-locks" of freeListLock(). We check only
ysr@1580 73 // the parDictionaryAllocLock because the others are too numerous.
ysr@1580 74 // This spl case code is somewhat ugly and any improvements
ysr@1580 75 // are welcome.
ysr@1580 76 assert(p_lock1 == NULL || !p_lock1->is_locked() || p_lock1->owned_by_self(),
ysr@1580 77 "Possible race between this and parallel GC threads");
ysr@1580 78 assert(p_lock2 == NULL || !p_lock2->is_locked() || p_lock2->owned_by_self(),
ysr@1580 79 "Possible race between this and parallel GC threads");
ysr@1580 80 } else if (myThread->is_GC_task_thread()) {
ysr@1580 81 // Make sure that the VM or CMS thread holds lock on our behalf
ysr@1580 82 // XXX If there were a concept of a gang_master for a (set of)
ysr@1580 83 // gang_workers, we could have used the identity of that thread
ysr@1580 84 // for checking ownership here; for now we just disjunct.
ysr@1580 85 assert(lock->owner() == VMThread::vm_thread() ||
ysr@1580 86 lock->owner() == ConcurrentMarkSweepThread::cmst(),
ysr@1580 87 "Should be locked by VM thread or CMS thread on my behalf");
ysr@1580 88 if (p_lock1 != NULL) {
ysr@1580 89 assert_lock_strong(p_lock1);
ysr@1580 90 }
ysr@1580 91 if (p_lock2 != NULL) {
ysr@1580 92 assert_lock_strong(p_lock2);
ysr@1580 93 }
duke@435 94 } else {
ysr@1580 95 // Make sure we didn't miss some other thread type calling into here;
ysr@1580 96 // perhaps as a result of future VM evolution.
ysr@1580 97 ShouldNotReachHere();
duke@435 98 }
duke@435 99 }
duke@435 100 #endif

mercurial