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