Thu, 22 Sep 2011 10:57:37 -0700
6484982: G1: process references during evacuation pauses
Summary: G1 now uses two reference processors - one is used by concurrent marking and the other is used by STW GCs (both full and incremental evacuation pauses). In an evacuation pause, the reference processor is embedded into the closures used to scan objects. Doing so causes causes reference objects to be 'discovered' by the reference processor. At the end of the evacuation pause, these discovered reference objects are processed - preserving (and copying) referent objects (and their reachable graphs) as appropriate.
Reviewed-by: ysr, jwilhelm, brutisso, stefank, tonyp
1 /*
2 * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
25 #include "precompiled.hpp"
26 #include "gc_implementation/g1/heapRegionRemSet.hpp"
27 #include "gc_implementation/g1/heapRegionSets.hpp"
29 //////////////////// FreeRegionList ////////////////////
31 const char* FreeRegionList::verify_region_extra(HeapRegion* hr) {
32 if (hr->is_young()) {
33 return "the region should not be young";
34 }
35 // The superclass will check that the region is empty and
36 // not-humongous.
37 return HeapRegionLinkedList::verify_region_extra(hr);
38 }
40 //////////////////// MasterFreeRegionList ////////////////////
42 const char* MasterFreeRegionList::verify_region_extra(HeapRegion* hr) {
43 // We should reset the RSet for parallel iteration before we add it
44 // to the master free list so that it is ready when the region is
45 // re-allocated.
46 if (!hr->rem_set()->verify_ready_for_par_iteration()) {
47 return "the region's RSet should be ready for parallel iteration";
48 }
49 return FreeRegionList::verify_region_extra(hr);
50 }
52 bool MasterFreeRegionList::check_mt_safety() {
53 // Master Free List MT safety protocol:
54 // (a) If we're at a safepoint, operations on the master free list
55 // should be invoked by either the VM thread (which will serialize
56 // them) or by the GC workers while holding the
57 // FreeList_lock.
58 // (b) If we're not at a safepoint, operations on the master free
59 // list should be invoked while holding the Heap_lock.
61 guarantee((SafepointSynchronize::is_at_safepoint() &&
62 (Thread::current()->is_VM_thread() ||
63 FreeList_lock->owned_by_self())) ||
64 (!SafepointSynchronize::is_at_safepoint() &&
65 Heap_lock->owned_by_self()),
66 hrs_ext_msg(this, "master free list MT safety protocol"));
68 return FreeRegionList::check_mt_safety();
69 }
71 //////////////////// SecondaryFreeRegionList ////////////////////
73 bool SecondaryFreeRegionList::check_mt_safety() {
74 // Secondary Free List MT safety protocol:
75 // Operations on the secondary free list should always be invoked
76 // while holding the SecondaryFreeList_lock.
78 guarantee(SecondaryFreeList_lock->owned_by_self(),
79 hrs_ext_msg(this, "secondary free list MT safety protocol"));
81 return FreeRegionList::check_mt_safety();
82 }
84 //////////////////// HumongousRegionSet ////////////////////
86 const char* HumongousRegionSet::verify_region_extra(HeapRegion* hr) {
87 if (hr->is_young()) {
88 return "the region should not be young";
89 }
90 // The superclass will check that the region is not empty and
91 // humongous.
92 return HeapRegionSet::verify_region_extra(hr);
93 }
95 //////////////////// MasterHumongousRegionSet ////////////////////
97 bool MasterHumongousRegionSet::check_mt_safety() {
98 // Master Humongous Set MT safety protocol:
99 // (a) If we're at a safepoint, operations on the master humongous
100 // set should be invoked by either the VM thread (which will
101 // serialize them) or by the GC workers while holding the
102 // OldSets_lock.
103 // (b) If we're not at a safepoint, operations on the master
104 // humongous set should be invoked while holding the Heap_lock.
106 guarantee((SafepointSynchronize::is_at_safepoint() &&
107 (Thread::current()->is_VM_thread() ||
108 OldSets_lock->owned_by_self())) ||
109 (!SafepointSynchronize::is_at_safepoint() &&
110 Heap_lock->owned_by_self()),
111 hrs_ext_msg(this, "master humongous set MT safety protocol"));
112 return HumongousRegionSet::check_mt_safety();
113 }