src/share/vm/gc_implementation/g1/heapRegionSets.cpp

Thu, 03 Jan 2013 16:28:22 -0800

author
johnc
date
Thu, 03 Jan 2013 16:28:22 -0800
changeset 4386
d275c3dc73e6
parent 3268
8aae2050e83e
child 6385
58fc1b1523dc
permissions
-rw-r--r--

8004816: G1: Kitchensink failures after marking stack changes
Summary: Reset the marking state, including the mark stack overflow flag, in the event of a marking stack overflow during serial reference processing.
Reviewed-by: jmasa

tonyp@2472 1 /*
tonyp@2472 2 * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
tonyp@2472 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
tonyp@2472 4 *
tonyp@2472 5 * This code is free software; you can redistribute it and/or modify it
tonyp@2472 6 * under the terms of the GNU General Public License version 2 only, as
tonyp@2472 7 * published by the Free Software Foundation.
tonyp@2472 8 *
tonyp@2472 9 * This code is distributed in the hope that it will be useful, but WITHOUT
tonyp@2472 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
tonyp@2472 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
tonyp@2472 12 * version 2 for more details (a copy is included in the LICENSE file that
tonyp@2472 13 * accompanied this code).
tonyp@2472 14 *
tonyp@2472 15 * You should have received a copy of the GNU General Public License version
tonyp@2472 16 * 2 along with this work; if not, write to the Free Software Foundation,
tonyp@2472 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
tonyp@2472 18 *
tonyp@2472 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
tonyp@2472 20 * or visit www.oracle.com if you need additional information or have any
tonyp@2472 21 * questions.
tonyp@2472 22 *
tonyp@2472 23 */
tonyp@2472 24
tonyp@2472 25 #include "precompiled.hpp"
tonyp@2974 26 #include "gc_implementation/g1/heapRegionRemSet.hpp"
tonyp@2472 27 #include "gc_implementation/g1/heapRegionSets.hpp"
tonyp@2472 28
tonyp@3268 29 // Note on the check_mt_safety() methods below:
tonyp@3268 30 //
tonyp@3268 31 // Verification of the "master" heap region sets / lists that are
tonyp@3268 32 // maintained by G1CollectedHeap is always done during a STW pause and
tonyp@3268 33 // by the VM thread at the start / end of the pause. The standard
tonyp@3268 34 // verification methods all assert check_mt_safety(). This is
tonyp@3268 35 // important as it ensures that verification is done without
tonyp@3268 36 // concurrent updates taking place at the same time. It follows, that,
tonyp@3268 37 // for the "master" heap region sets / lists, the check_mt_safety()
tonyp@3268 38 // method should include the VM thread / STW case.
tonyp@3268 39
tonyp@2472 40 //////////////////// FreeRegionList ////////////////////
tonyp@2472 41
tonyp@2472 42 const char* FreeRegionList::verify_region_extra(HeapRegion* hr) {
tonyp@2472 43 if (hr->is_young()) {
tonyp@2472 44 return "the region should not be young";
tonyp@2472 45 }
tonyp@2472 46 // The superclass will check that the region is empty and
tonyp@3268 47 // not humongous.
tonyp@2472 48 return HeapRegionLinkedList::verify_region_extra(hr);
tonyp@2472 49 }
tonyp@2472 50
tonyp@2472 51 //////////////////// MasterFreeRegionList ////////////////////
tonyp@2472 52
tonyp@2974 53 const char* MasterFreeRegionList::verify_region_extra(HeapRegion* hr) {
tonyp@2974 54 // We should reset the RSet for parallel iteration before we add it
tonyp@2974 55 // to the master free list so that it is ready when the region is
tonyp@2974 56 // re-allocated.
tonyp@2974 57 if (!hr->rem_set()->verify_ready_for_par_iteration()) {
tonyp@2974 58 return "the region's RSet should be ready for parallel iteration";
tonyp@2974 59 }
tonyp@2974 60 return FreeRegionList::verify_region_extra(hr);
tonyp@2974 61 }
tonyp@2974 62
tonyp@2472 63 bool MasterFreeRegionList::check_mt_safety() {
tonyp@2472 64 // Master Free List MT safety protocol:
tonyp@2472 65 // (a) If we're at a safepoint, operations on the master free list
tonyp@2472 66 // should be invoked by either the VM thread (which will serialize
tonyp@2472 67 // them) or by the GC workers while holding the
tonyp@2472 68 // FreeList_lock.
tonyp@2472 69 // (b) If we're not at a safepoint, operations on the master free
tonyp@2472 70 // list should be invoked while holding the Heap_lock.
tonyp@2472 71
tonyp@3268 72 if (SafepointSynchronize::is_at_safepoint()) {
tonyp@3268 73 guarantee(Thread::current()->is_VM_thread() ||
tonyp@3268 74 FreeList_lock->owned_by_self(),
tonyp@3268 75 hrs_ext_msg(this, "master free list MT safety protocol "
tonyp@3268 76 "at a safepoint"));
tonyp@3268 77 } else {
tonyp@3268 78 guarantee(Heap_lock->owned_by_self(),
tonyp@3268 79 hrs_ext_msg(this, "master free list MT safety protocol "
tonyp@3268 80 "outside a safepoint"));
tonyp@3268 81 }
tonyp@2472 82
tonyp@2472 83 return FreeRegionList::check_mt_safety();
tonyp@2472 84 }
tonyp@2472 85
tonyp@2472 86 //////////////////// SecondaryFreeRegionList ////////////////////
tonyp@2472 87
tonyp@2472 88 bool SecondaryFreeRegionList::check_mt_safety() {
tonyp@2472 89 // Secondary Free List MT safety protocol:
tonyp@2472 90 // Operations on the secondary free list should always be invoked
tonyp@2472 91 // while holding the SecondaryFreeList_lock.
tonyp@2472 92
tonyp@2472 93 guarantee(SecondaryFreeList_lock->owned_by_self(),
tonyp@2643 94 hrs_ext_msg(this, "secondary free list MT safety protocol"));
tonyp@2472 95
tonyp@2472 96 return FreeRegionList::check_mt_safety();
tonyp@2472 97 }
tonyp@2472 98
tonyp@3268 99 //////////////////// OldRegionSet ////////////////////
tonyp@3268 100
tonyp@3268 101 const char* OldRegionSet::verify_region_extra(HeapRegion* hr) {
tonyp@3268 102 if (hr->is_young()) {
tonyp@3268 103 return "the region should not be young";
tonyp@3268 104 }
tonyp@3268 105 // The superclass will check that the region is not empty and not
tonyp@3268 106 // humongous.
tonyp@3268 107 return HeapRegionSet::verify_region_extra(hr);
tonyp@3268 108 }
tonyp@3268 109
tonyp@3268 110 //////////////////// MasterOldRegionSet ////////////////////
tonyp@3268 111
tonyp@3268 112 bool MasterOldRegionSet::check_mt_safety() {
tonyp@3268 113 // Master Old Set MT safety protocol:
tonyp@3268 114 // (a) If we're at a safepoint, operations on the master old set
tonyp@3268 115 // should be invoked:
tonyp@3268 116 // - by the VM thread (which will serialize them), or
tonyp@3268 117 // - by the GC workers while holding the FreeList_lock, if we're
tonyp@3268 118 // at a safepoint for an evacuation pause (this lock is taken
tonyp@3268 119 // anyway when an GC alloc region is retired so that a new one
tonyp@3268 120 // is allocated from the free list), or
tonyp@3268 121 // - by the GC workers while holding the OldSets_lock, if we're at a
tonyp@3268 122 // safepoint for a cleanup pause.
tonyp@3268 123 // (b) If we're not at a safepoint, operations on the master old set
tonyp@3268 124 // should be invoked while holding the Heap_lock.
tonyp@3268 125
tonyp@3268 126 if (SafepointSynchronize::is_at_safepoint()) {
tonyp@3268 127 guarantee(Thread::current()->is_VM_thread() ||
tonyp@3268 128 _phase == HRSPhaseEvacuation && FreeList_lock->owned_by_self() ||
tonyp@3268 129 _phase == HRSPhaseCleanup && OldSets_lock->owned_by_self(),
tonyp@3268 130 hrs_ext_msg(this, "master old set MT safety protocol "
tonyp@3268 131 "at a safepoint"));
tonyp@3268 132 } else {
tonyp@3268 133 guarantee(Heap_lock->owned_by_self(),
tonyp@3268 134 hrs_ext_msg(this, "master old set MT safety protocol "
tonyp@3268 135 "outside a safepoint"));
tonyp@3268 136 }
tonyp@3268 137
tonyp@3268 138 return OldRegionSet::check_mt_safety();
tonyp@3268 139 }
tonyp@3268 140
tonyp@2472 141 //////////////////// HumongousRegionSet ////////////////////
tonyp@2472 142
tonyp@2472 143 const char* HumongousRegionSet::verify_region_extra(HeapRegion* hr) {
tonyp@2472 144 if (hr->is_young()) {
tonyp@2472 145 return "the region should not be young";
tonyp@2472 146 }
tonyp@2472 147 // The superclass will check that the region is not empty and
tonyp@2472 148 // humongous.
tonyp@2472 149 return HeapRegionSet::verify_region_extra(hr);
tonyp@2472 150 }
tonyp@2472 151
tonyp@2643 152 //////////////////// MasterHumongousRegionSet ////////////////////
tonyp@2472 153
tonyp@2472 154 bool MasterHumongousRegionSet::check_mt_safety() {
tonyp@2472 155 // Master Humongous Set MT safety protocol:
tonyp@2472 156 // (a) If we're at a safepoint, operations on the master humongous
tonyp@2472 157 // set should be invoked by either the VM thread (which will
tonyp@2472 158 // serialize them) or by the GC workers while holding the
tonyp@2472 159 // OldSets_lock.
tonyp@2472 160 // (b) If we're not at a safepoint, operations on the master
tonyp@2472 161 // humongous set should be invoked while holding the Heap_lock.
tonyp@2472 162
tonyp@3268 163 if (SafepointSynchronize::is_at_safepoint()) {
tonyp@3268 164 guarantee(Thread::current()->is_VM_thread() ||
tonyp@3268 165 OldSets_lock->owned_by_self(),
tonyp@3268 166 hrs_ext_msg(this, "master humongous set MT safety protocol "
tonyp@3268 167 "at a safepoint"));
tonyp@3268 168 } else {
tonyp@3268 169 guarantee(Heap_lock->owned_by_self(),
tonyp@3268 170 hrs_ext_msg(this, "master humongous set MT safety protocol "
tonyp@3268 171 "outside a safepoint"));
tonyp@3268 172 }
tonyp@3268 173
tonyp@2472 174 return HumongousRegionSet::check_mt_safety();
tonyp@2472 175 }

mercurial