Mercurial > hg > graal-jvmci-8
annotate src/share/vm/gc_implementation/g1/heapRegionSets.cpp @ 4097:dc467e8b2c5e
7112743: G1: Reduce overhead of marking closure during evacuation pauses
Summary: Parallelize the serial code that was used to mark objects reachable from survivor objects in the collection set. Some minor improvments in the timers used to track the freeing of the collection set along with some tweaks to PrintGCDetails.
Reviewed-by: tonyp, brutisso
author | johnc |
---|---|
date | Thu, 17 Nov 2011 12:40:15 -0800 |
parents | 8aae2050e83e |
children | 58fc1b1523dc |
rev | line source |
---|---|
2152 | 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 */ | |
24 | |
25 #include "precompiled.hpp" | |
3777
e8b0b0392037
7046182: G1: remove unnecessary iterations over the collection set
tonyp
parents:
2361
diff
changeset
|
26 #include "gc_implementation/g1/heapRegionRemSet.hpp" |
2152 | 27 #include "gc_implementation/g1/heapRegionSets.hpp" |
28 | |
4072 | 29 // Note on the check_mt_safety() methods below: |
30 // | |
31 // Verification of the "master" heap region sets / lists that are | |
32 // maintained by G1CollectedHeap is always done during a STW pause and | |
33 // by the VM thread at the start / end of the pause. The standard | |
34 // verification methods all assert check_mt_safety(). This is | |
35 // important as it ensures that verification is done without | |
36 // concurrent updates taking place at the same time. It follows, that, | |
37 // for the "master" heap region sets / lists, the check_mt_safety() | |
38 // method should include the VM thread / STW case. | |
39 | |
2152 | 40 //////////////////// FreeRegionList //////////////////// |
41 | |
42 const char* FreeRegionList::verify_region_extra(HeapRegion* hr) { | |
43 if (hr->is_young()) { | |
44 return "the region should not be young"; | |
45 } | |
46 // The superclass will check that the region is empty and | |
4072 | 47 // not humongous. |
2152 | 48 return HeapRegionLinkedList::verify_region_extra(hr); |
49 } | |
50 | |
51 //////////////////// MasterFreeRegionList //////////////////// | |
52 | |
3777
e8b0b0392037
7046182: G1: remove unnecessary iterations over the collection set
tonyp
parents:
2361
diff
changeset
|
53 const char* MasterFreeRegionList::verify_region_extra(HeapRegion* hr) { |
e8b0b0392037
7046182: G1: remove unnecessary iterations over the collection set
tonyp
parents:
2361
diff
changeset
|
54 // We should reset the RSet for parallel iteration before we add it |
e8b0b0392037
7046182: G1: remove unnecessary iterations over the collection set
tonyp
parents:
2361
diff
changeset
|
55 // to the master free list so that it is ready when the region is |
e8b0b0392037
7046182: G1: remove unnecessary iterations over the collection set
tonyp
parents:
2361
diff
changeset
|
56 // re-allocated. |
e8b0b0392037
7046182: G1: remove unnecessary iterations over the collection set
tonyp
parents:
2361
diff
changeset
|
57 if (!hr->rem_set()->verify_ready_for_par_iteration()) { |
e8b0b0392037
7046182: G1: remove unnecessary iterations over the collection set
tonyp
parents:
2361
diff
changeset
|
58 return "the region's RSet should be ready for parallel iteration"; |
e8b0b0392037
7046182: G1: remove unnecessary iterations over the collection set
tonyp
parents:
2361
diff
changeset
|
59 } |
e8b0b0392037
7046182: G1: remove unnecessary iterations over the collection set
tonyp
parents:
2361
diff
changeset
|
60 return FreeRegionList::verify_region_extra(hr); |
e8b0b0392037
7046182: G1: remove unnecessary iterations over the collection set
tonyp
parents:
2361
diff
changeset
|
61 } |
e8b0b0392037
7046182: G1: remove unnecessary iterations over the collection set
tonyp
parents:
2361
diff
changeset
|
62 |
2152 | 63 bool MasterFreeRegionList::check_mt_safety() { |
64 // Master Free List MT safety protocol: | |
65 // (a) If we're at a safepoint, operations on the master free list | |
66 // should be invoked by either the VM thread (which will serialize | |
67 // them) or by the GC workers while holding the | |
68 // FreeList_lock. | |
69 // (b) If we're not at a safepoint, operations on the master free | |
70 // list should be invoked while holding the Heap_lock. | |
71 | |
4072 | 72 if (SafepointSynchronize::is_at_safepoint()) { |
73 guarantee(Thread::current()->is_VM_thread() || | |
74 FreeList_lock->owned_by_self(), | |
75 hrs_ext_msg(this, "master free list MT safety protocol " | |
76 "at a safepoint")); | |
77 } else { | |
78 guarantee(Heap_lock->owned_by_self(), | |
79 hrs_ext_msg(this, "master free list MT safety protocol " | |
80 "outside a safepoint")); | |
81 } | |
2152 | 82 |
83 return FreeRegionList::check_mt_safety(); | |
84 } | |
85 | |
86 //////////////////// SecondaryFreeRegionList //////////////////// | |
87 | |
88 bool SecondaryFreeRegionList::check_mt_safety() { | |
89 // Secondary Free List MT safety protocol: | |
90 // Operations on the secondary free list should always be invoked | |
91 // while holding the SecondaryFreeList_lock. | |
92 | |
93 guarantee(SecondaryFreeList_lock->owned_by_self(), | |
2361 | 94 hrs_ext_msg(this, "secondary free list MT safety protocol")); |
2152 | 95 |
96 return FreeRegionList::check_mt_safety(); | |
97 } | |
98 | |
4072 | 99 //////////////////// OldRegionSet //////////////////// |
100 | |
101 const char* OldRegionSet::verify_region_extra(HeapRegion* hr) { | |
102 if (hr->is_young()) { | |
103 return "the region should not be young"; | |
104 } | |
105 // The superclass will check that the region is not empty and not | |
106 // humongous. | |
107 return HeapRegionSet::verify_region_extra(hr); | |
108 } | |
109 | |
110 //////////////////// MasterOldRegionSet //////////////////// | |
111 | |
112 bool MasterOldRegionSet::check_mt_safety() { | |
113 // Master Old Set MT safety protocol: | |
114 // (a) If we're at a safepoint, operations on the master old set | |
115 // should be invoked: | |
116 // - by the VM thread (which will serialize them), or | |
117 // - by the GC workers while holding the FreeList_lock, if we're | |
118 // at a safepoint for an evacuation pause (this lock is taken | |
119 // anyway when an GC alloc region is retired so that a new one | |
120 // is allocated from the free list), or | |
121 // - by the GC workers while holding the OldSets_lock, if we're at a | |
122 // safepoint for a cleanup pause. | |
123 // (b) If we're not at a safepoint, operations on the master old set | |
124 // should be invoked while holding the Heap_lock. | |
125 | |
126 if (SafepointSynchronize::is_at_safepoint()) { | |
127 guarantee(Thread::current()->is_VM_thread() || | |
128 _phase == HRSPhaseEvacuation && FreeList_lock->owned_by_self() || | |
129 _phase == HRSPhaseCleanup && OldSets_lock->owned_by_self(), | |
130 hrs_ext_msg(this, "master old set MT safety protocol " | |
131 "at a safepoint")); | |
132 } else { | |
133 guarantee(Heap_lock->owned_by_self(), | |
134 hrs_ext_msg(this, "master old set MT safety protocol " | |
135 "outside a safepoint")); | |
136 } | |
137 | |
138 return OldRegionSet::check_mt_safety(); | |
139 } | |
140 | |
2152 | 141 //////////////////// HumongousRegionSet //////////////////// |
142 | |
143 const char* HumongousRegionSet::verify_region_extra(HeapRegion* hr) { | |
144 if (hr->is_young()) { | |
145 return "the region should not be young"; | |
146 } | |
147 // The superclass will check that the region is not empty and | |
148 // humongous. | |
149 return HeapRegionSet::verify_region_extra(hr); | |
150 } | |
151 | |
2361 | 152 //////////////////// MasterHumongousRegionSet //////////////////// |
2152 | 153 |
154 bool MasterHumongousRegionSet::check_mt_safety() { | |
155 // Master Humongous Set MT safety protocol: | |
156 // (a) If we're at a safepoint, operations on the master humongous | |
157 // set should be invoked by either the VM thread (which will | |
158 // serialize them) or by the GC workers while holding the | |
159 // OldSets_lock. | |
160 // (b) If we're not at a safepoint, operations on the master | |
161 // humongous set should be invoked while holding the Heap_lock. | |
162 | |
4072 | 163 if (SafepointSynchronize::is_at_safepoint()) { |
164 guarantee(Thread::current()->is_VM_thread() || | |
165 OldSets_lock->owned_by_self(), | |
166 hrs_ext_msg(this, "master humongous set MT safety protocol " | |
167 "at a safepoint")); | |
168 } else { | |
169 guarantee(Heap_lock->owned_by_self(), | |
170 hrs_ext_msg(this, "master humongous set MT safety protocol " | |
171 "outside a safepoint")); | |
172 } | |
173 | |
2152 | 174 return HumongousRegionSet::check_mt_safety(); |
175 } |