tonyp@2472: /* tonyp@2472: * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. tonyp@2472: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. tonyp@2472: * tonyp@2472: * This code is free software; you can redistribute it and/or modify it tonyp@2472: * under the terms of the GNU General Public License version 2 only, as tonyp@2472: * published by the Free Software Foundation. tonyp@2472: * tonyp@2472: * This code is distributed in the hope that it will be useful, but WITHOUT tonyp@2472: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or tonyp@2472: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License tonyp@2472: * version 2 for more details (a copy is included in the LICENSE file that tonyp@2472: * accompanied this code). tonyp@2472: * tonyp@2472: * You should have received a copy of the GNU General Public License version tonyp@2472: * 2 along with this work; if not, write to the Free Software Foundation, tonyp@2472: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. tonyp@2472: * tonyp@2472: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA tonyp@2472: * or visit www.oracle.com if you need additional information or have any tonyp@2472: * questions. tonyp@2472: * tonyp@2472: */ tonyp@2472: tonyp@2472: #include "precompiled.hpp" tonyp@2974: #include "gc_implementation/g1/heapRegionRemSet.hpp" tonyp@2472: #include "gc_implementation/g1/heapRegionSets.hpp" tonyp@2472: tonyp@2472: //////////////////// FreeRegionList //////////////////// tonyp@2472: tonyp@2472: const char* FreeRegionList::verify_region_extra(HeapRegion* hr) { tonyp@2472: if (hr->is_young()) { tonyp@2472: return "the region should not be young"; tonyp@2472: } tonyp@2472: // The superclass will check that the region is empty and tonyp@2472: // not-humongous. tonyp@2472: return HeapRegionLinkedList::verify_region_extra(hr); tonyp@2472: } tonyp@2472: tonyp@2472: //////////////////// MasterFreeRegionList //////////////////// tonyp@2472: tonyp@2974: const char* MasterFreeRegionList::verify_region_extra(HeapRegion* hr) { tonyp@2974: // We should reset the RSet for parallel iteration before we add it tonyp@2974: // to the master free list so that it is ready when the region is tonyp@2974: // re-allocated. tonyp@2974: if (!hr->rem_set()->verify_ready_for_par_iteration()) { tonyp@2974: return "the region's RSet should be ready for parallel iteration"; tonyp@2974: } tonyp@2974: return FreeRegionList::verify_region_extra(hr); tonyp@2974: } tonyp@2974: tonyp@2472: bool MasterFreeRegionList::check_mt_safety() { tonyp@2472: // Master Free List MT safety protocol: tonyp@2472: // (a) If we're at a safepoint, operations on the master free list tonyp@2472: // should be invoked by either the VM thread (which will serialize tonyp@2472: // them) or by the GC workers while holding the tonyp@2472: // FreeList_lock. tonyp@2472: // (b) If we're not at a safepoint, operations on the master free tonyp@2472: // list should be invoked while holding the Heap_lock. tonyp@2472: tonyp@2472: guarantee((SafepointSynchronize::is_at_safepoint() && tonyp@2472: (Thread::current()->is_VM_thread() || tonyp@2472: FreeList_lock->owned_by_self())) || tonyp@2472: (!SafepointSynchronize::is_at_safepoint() && tonyp@2472: Heap_lock->owned_by_self()), tonyp@2643: hrs_ext_msg(this, "master free list MT safety protocol")); tonyp@2472: tonyp@2472: return FreeRegionList::check_mt_safety(); tonyp@2472: } tonyp@2472: tonyp@2472: //////////////////// SecondaryFreeRegionList //////////////////// tonyp@2472: tonyp@2472: bool SecondaryFreeRegionList::check_mt_safety() { tonyp@2472: // Secondary Free List MT safety protocol: tonyp@2472: // Operations on the secondary free list should always be invoked tonyp@2472: // while holding the SecondaryFreeList_lock. tonyp@2472: tonyp@2472: guarantee(SecondaryFreeList_lock->owned_by_self(), tonyp@2643: hrs_ext_msg(this, "secondary free list MT safety protocol")); tonyp@2472: tonyp@2472: return FreeRegionList::check_mt_safety(); tonyp@2472: } tonyp@2472: tonyp@2472: //////////////////// HumongousRegionSet //////////////////// tonyp@2472: tonyp@2472: const char* HumongousRegionSet::verify_region_extra(HeapRegion* hr) { tonyp@2472: if (hr->is_young()) { tonyp@2472: return "the region should not be young"; tonyp@2472: } tonyp@2472: // The superclass will check that the region is not empty and tonyp@2472: // humongous. tonyp@2472: return HeapRegionSet::verify_region_extra(hr); tonyp@2472: } tonyp@2472: tonyp@2643: //////////////////// MasterHumongousRegionSet //////////////////// tonyp@2472: tonyp@2472: bool MasterHumongousRegionSet::check_mt_safety() { tonyp@2472: // Master Humongous Set MT safety protocol: tonyp@2472: // (a) If we're at a safepoint, operations on the master humongous tonyp@2472: // set should be invoked by either the VM thread (which will tonyp@2472: // serialize them) or by the GC workers while holding the tonyp@2472: // OldSets_lock. tonyp@2472: // (b) If we're not at a safepoint, operations on the master tonyp@2472: // humongous set should be invoked while holding the Heap_lock. tonyp@2472: tonyp@2472: guarantee((SafepointSynchronize::is_at_safepoint() && tonyp@2472: (Thread::current()->is_VM_thread() || tonyp@2472: OldSets_lock->owned_by_self())) || tonyp@2472: (!SafepointSynchronize::is_at_safepoint() && tonyp@2472: Heap_lock->owned_by_self()), tonyp@2643: hrs_ext_msg(this, "master humongous set MT safety protocol")); tonyp@2472: return HumongousRegionSet::check_mt_safety(); tonyp@2472: }