Mercurial > hg > graal-jvmci-8
annotate src/share/vm/memory/referenceProcessor.hpp @ 1994:6cd6d394f280
7001033: assert(gch->gc_cause() == GCCause::_scavenge_alot || !gch->incremental_collection_failed())
7002546: regression on SpecJbb2005 on 7b118 comparing to 7b117 on small heaps
Summary: Relaxed assertion checking related to incremental_collection_failed flag to allow for ExplicitGCInvokesConcurrent behaviour where we do not want a failing scavenge to bail to a stop-world collection. Parameterized incremental_collection_will_fail() so we can selectively use, or not use, as appropriate, the statistical prediction at specific use sites. This essentially reverts the scavenge bail-out logic to what it was prior to some recent changes that had inadvertently started using the statistical prediction which can be noisy in the presence of bursty loads. Added some associated verbose non-product debugging messages.
Reviewed-by: johnc, tonyp
author | ysr |
---|---|
date | Tue, 07 Dec 2010 21:55:53 -0800 |
parents | f95d63e2154a |
children | 8df09fb45352 |
rev | line source |
---|---|
0 | 1 /* |
1833
8b10f48633dc
6984287: Regularize how GC parallel workers are specified.
jmasa
parents:
1552
diff
changeset
|
2 * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved. |
0 | 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 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1244
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1244
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1244
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
1972 | 25 #ifndef SHARE_VM_MEMORY_REFERENCEPROCESSOR_HPP |
26 #define SHARE_VM_MEMORY_REFERENCEPROCESSOR_HPP | |
27 | |
28 #include "memory/referencePolicy.hpp" | |
29 #include "oops/instanceRefKlass.hpp" | |
30 | |
0 | 31 // ReferenceProcessor class encapsulates the per-"collector" processing |
453
c96030fff130
6684579: SoftReference processing can be made more efficient
ysr
parents:
356
diff
changeset
|
32 // of java.lang.Reference objects for GC. The interface is useful for supporting |
0 | 33 // a generational abstraction, in particular when there are multiple |
34 // generations that are being independently collected -- possibly | |
35 // concurrently and/or incrementally. Note, however, that the | |
36 // ReferenceProcessor class abstracts away from a generational setting | |
37 // by using only a heap interval (called "span" below), thus allowing | |
38 // its use in a straightforward manner in a general, non-generational | |
39 // setting. | |
40 // | |
41 // The basic idea is that each ReferenceProcessor object concerns | |
42 // itself with ("weak") reference processing in a specific "span" | |
43 // of the heap of interest to a specific collector. Currently, | |
44 // the span is a convex interval of the heap, but, efficiency | |
45 // apart, there seems to be no reason it couldn't be extended | |
46 // (with appropriate modifications) to any "non-convex interval". | |
47 | |
48 // forward references | |
49 class ReferencePolicy; | |
50 class AbstractRefProcTaskExecutor; | |
51 class DiscoveredList; | |
52 | |
53 class ReferenceProcessor : public CHeapObj { | |
54 protected: | |
55 // End of list marker | |
56 static oop _sentinelRef; | |
57 MemRegion _span; // (right-open) interval of heap | |
58 // subject to wkref discovery | |
59 bool _discovering_refs; // true when discovery enabled | |
60 bool _discovery_is_atomic; // if discovery is atomic wrt | |
61 // other collectors in configuration | |
62 bool _discovery_is_mt; // true if reference discovery is MT. | |
342
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
63 // If true, setting "next" field of a discovered refs list requires |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
64 // write barrier(s). (Must be true if used in a collector in which |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
65 // elements of a discovered list may be moved during discovery: for |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
66 // example, a collector like Garbage-First that moves objects during a |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
67 // long-term concurrent marking phase that does weak reference |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
68 // discovery.) |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
69 bool _discovered_list_needs_barrier; |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
70 BarrierSet* _bs; // Cached copy of BarrierSet. |
0 | 71 bool _enqueuing_is_done; // true if all weak references enqueued |
72 bool _processing_is_mt; // true during phases when | |
73 // reference processing is MT. | |
74 int _next_id; // round-robin counter in | |
75 // support of work distribution | |
76 | |
77 // For collectors that do not keep GC marking information | |
78 // in the object header, this field holds a closure that | |
79 // helps the reference processor determine the reachability | |
80 // of an oop (the field is currently initialized to NULL for | |
81 // all collectors but the CMS collector). | |
82 BoolObjectClosure* _is_alive_non_header; | |
83 | |
453
c96030fff130
6684579: SoftReference processing can be made more efficient
ysr
parents:
356
diff
changeset
|
84 // Soft ref clearing policies |
c96030fff130
6684579: SoftReference processing can be made more efficient
ysr
parents:
356
diff
changeset
|
85 // . the default policy |
c96030fff130
6684579: SoftReference processing can be made more efficient
ysr
parents:
356
diff
changeset
|
86 static ReferencePolicy* _default_soft_ref_policy; |
c96030fff130
6684579: SoftReference processing can be made more efficient
ysr
parents:
356
diff
changeset
|
87 // . the "clear all" policy |
c96030fff130
6684579: SoftReference processing can be made more efficient
ysr
parents:
356
diff
changeset
|
88 static ReferencePolicy* _always_clear_soft_ref_policy; |
c96030fff130
6684579: SoftReference processing can be made more efficient
ysr
parents:
356
diff
changeset
|
89 // . the current policy below is either one of the above |
c96030fff130
6684579: SoftReference processing can be made more efficient
ysr
parents:
356
diff
changeset
|
90 ReferencePolicy* _current_soft_ref_policy; |
c96030fff130
6684579: SoftReference processing can be made more efficient
ysr
parents:
356
diff
changeset
|
91 |
0 | 92 // The discovered ref lists themselves |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
93 |
1833
8b10f48633dc
6984287: Regularize how GC parallel workers are specified.
jmasa
parents:
1552
diff
changeset
|
94 // The active MT'ness degree of the queues below |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
95 int _num_q; |
1833
8b10f48633dc
6984287: Regularize how GC parallel workers are specified.
jmasa
parents:
1552
diff
changeset
|
96 // The maximum MT'ness degree of the queues below |
8b10f48633dc
6984287: Regularize how GC parallel workers are specified.
jmasa
parents:
1552
diff
changeset
|
97 int _max_num_q; |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
98 // Arrays of lists of oops, one per thread |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
99 DiscoveredList* _discoveredSoftRefs; |
0 | 100 DiscoveredList* _discoveredWeakRefs; |
101 DiscoveredList* _discoveredFinalRefs; | |
102 DiscoveredList* _discoveredPhantomRefs; | |
103 | |
104 public: | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
105 int num_q() { return _num_q; } |
1833
8b10f48633dc
6984287: Regularize how GC parallel workers are specified.
jmasa
parents:
1552
diff
changeset
|
106 void set_mt_degree(int v) { _num_q = v; } |
0 | 107 DiscoveredList* discovered_soft_refs() { return _discoveredSoftRefs; } |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
108 static oop sentinel_ref() { return _sentinelRef; } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
109 static oop* adr_sentinel_ref() { return &_sentinelRef; } |
457
27a80744a83b
6778647: snap(), snap_policy() should be renamed setup(), setup_policy()
ysr
parents:
453
diff
changeset
|
110 ReferencePolicy* setup_policy(bool always_clear) { |
453
c96030fff130
6684579: SoftReference processing can be made more efficient
ysr
parents:
356
diff
changeset
|
111 _current_soft_ref_policy = always_clear ? |
c96030fff130
6684579: SoftReference processing can be made more efficient
ysr
parents:
356
diff
changeset
|
112 _always_clear_soft_ref_policy : _default_soft_ref_policy; |
457
27a80744a83b
6778647: snap(), snap_policy() should be renamed setup(), setup_policy()
ysr
parents:
453
diff
changeset
|
113 _current_soft_ref_policy->setup(); // snapshot the policy threshold |
453
c96030fff130
6684579: SoftReference processing can be made more efficient
ysr
parents:
356
diff
changeset
|
114 return _current_soft_ref_policy; |
c96030fff130
6684579: SoftReference processing can be made more efficient
ysr
parents:
356
diff
changeset
|
115 } |
0 | 116 |
117 public: | |
118 // Process references with a certain reachability level. | |
119 void process_discovered_reflist(DiscoveredList refs_lists[], | |
120 ReferencePolicy* policy, | |
121 bool clear_referent, | |
122 BoolObjectClosure* is_alive, | |
123 OopClosure* keep_alive, | |
124 VoidClosure* complete_gc, | |
125 AbstractRefProcTaskExecutor* task_executor); | |
126 | |
127 void process_phaseJNI(BoolObjectClosure* is_alive, | |
128 OopClosure* keep_alive, | |
129 VoidClosure* complete_gc); | |
130 | |
131 // Work methods used by the method process_discovered_reflist | |
132 // Phase1: keep alive all those referents that are otherwise | |
133 // dead but which must be kept alive by policy (and their closure). | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
134 void process_phase1(DiscoveredList& refs_list, |
0 | 135 ReferencePolicy* policy, |
136 BoolObjectClosure* is_alive, | |
137 OopClosure* keep_alive, | |
138 VoidClosure* complete_gc); | |
139 // Phase2: remove all those references whose referents are | |
140 // reachable. | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
141 inline void process_phase2(DiscoveredList& refs_list, |
0 | 142 BoolObjectClosure* is_alive, |
143 OopClosure* keep_alive, | |
144 VoidClosure* complete_gc) { | |
145 if (discovery_is_atomic()) { | |
146 // complete_gc is ignored in this case for this phase | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
147 pp2_work(refs_list, is_alive, keep_alive); |
0 | 148 } else { |
149 assert(complete_gc != NULL, "Error"); | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
150 pp2_work_concurrent_discovery(refs_list, is_alive, |
0 | 151 keep_alive, complete_gc); |
152 } | |
153 } | |
154 // Work methods in support of process_phase2 | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
155 void pp2_work(DiscoveredList& refs_list, |
0 | 156 BoolObjectClosure* is_alive, |
157 OopClosure* keep_alive); | |
158 void pp2_work_concurrent_discovery( | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
159 DiscoveredList& refs_list, |
0 | 160 BoolObjectClosure* is_alive, |
161 OopClosure* keep_alive, | |
162 VoidClosure* complete_gc); | |
163 // Phase3: process the referents by either clearing them | |
164 // or keeping them alive (and their closure) | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
165 void process_phase3(DiscoveredList& refs_list, |
0 | 166 bool clear_referent, |
167 BoolObjectClosure* is_alive, | |
168 OopClosure* keep_alive, | |
169 VoidClosure* complete_gc); | |
170 | |
171 // Enqueue references with a certain reachability level | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
172 void enqueue_discovered_reflist(DiscoveredList& refs_list, HeapWord* pending_list_addr); |
0 | 173 |
174 // "Preclean" all the discovered reference lists | |
175 // by removing references with strongly reachable referents. | |
176 // The first argument is a predicate on an oop that indicates | |
177 // its (strong) reachability and the second is a closure that | |
178 // may be used to incrementalize or abort the precleaning process. | |
179 // The caller is responsible for taking care of potential | |
180 // interference with concurrent operations on these lists | |
181 // (or predicates involved) by other threads. Currently | |
1190
4788266644c1
6895236: CMS: cmsOopClosures.inline.hpp:43 assert(..., "Should remember klasses in this context")
jmasa
parents:
457
diff
changeset
|
182 // only used by the CMS collector. should_unload_classes is |
4788266644c1
6895236: CMS: cmsOopClosures.inline.hpp:43 assert(..., "Should remember klasses in this context")
jmasa
parents:
457
diff
changeset
|
183 // used to aid assertion checking when classes are collected. |
0 | 184 void preclean_discovered_references(BoolObjectClosure* is_alive, |
185 OopClosure* keep_alive, | |
186 VoidClosure* complete_gc, | |
1190
4788266644c1
6895236: CMS: cmsOopClosures.inline.hpp:43 assert(..., "Should remember klasses in this context")
jmasa
parents:
457
diff
changeset
|
187 YieldClosure* yield, |
4788266644c1
6895236: CMS: cmsOopClosures.inline.hpp:43 assert(..., "Should remember klasses in this context")
jmasa
parents:
457
diff
changeset
|
188 bool should_unload_classes); |
0 | 189 |
190 // Delete entries in the discovered lists that have | |
191 // either a null referent or are not active. Such | |
192 // Reference objects can result from the clearing | |
193 // or enqueueing of Reference objects concurrent | |
194 // with their discovery by a (concurrent) collector. | |
195 // For a definition of "active" see java.lang.ref.Reference; | |
196 // Refs are born active, become inactive when enqueued, | |
197 // and never become active again. The state of being | |
198 // active is encoded as follows: A Ref is active | |
199 // if and only if its "next" field is NULL. | |
200 void clean_up_discovered_references(); | |
201 void clean_up_discovered_reflist(DiscoveredList& refs_list); | |
202 | |
203 // Returns the name of the discovered reference list | |
204 // occupying the i / _num_q slot. | |
205 const char* list_name(int i); | |
206 | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
207 void enqueue_discovered_reflists(HeapWord* pending_list_addr, AbstractRefProcTaskExecutor* task_executor); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
208 |
0 | 209 protected: |
210 // "Preclean" the given discovered reference list | |
211 // by removing references with strongly reachable referents. | |
212 // Currently used in support of CMS only. | |
213 void preclean_discovered_reflist(DiscoveredList& refs_list, | |
214 BoolObjectClosure* is_alive, | |
215 OopClosure* keep_alive, | |
216 VoidClosure* complete_gc, | |
217 YieldClosure* yield); | |
218 | |
219 int next_id() { | |
220 int id = _next_id; | |
221 if (++_next_id == _num_q) { | |
222 _next_id = 0; | |
223 } | |
224 return id; | |
225 } | |
226 DiscoveredList* get_discovered_list(ReferenceType rt); | |
227 inline void add_to_discovered_list_mt(DiscoveredList& refs_list, oop obj, | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
228 HeapWord* discovered_addr); |
0 | 229 void verify_ok_to_handle_reflists() PRODUCT_RETURN; |
230 | |
231 void abandon_partial_discovered_list(DiscoveredList& refs_list); | |
232 | |
233 // Calculate the number of jni handles. | |
234 unsigned int count_jni_refs(); | |
235 | |
236 // Balances reference queues. | |
237 void balance_queues(DiscoveredList ref_lists[]); | |
238 | |
239 // Update (advance) the soft ref master clock field. | |
240 void update_soft_ref_master_clock(); | |
241 | |
242 public: | |
243 // constructor | |
244 ReferenceProcessor(): | |
245 _span((HeapWord*)NULL, (HeapWord*)NULL), | |
246 _discoveredSoftRefs(NULL), _discoveredWeakRefs(NULL), | |
247 _discoveredFinalRefs(NULL), _discoveredPhantomRefs(NULL), | |
248 _discovering_refs(false), | |
249 _discovery_is_atomic(true), | |
250 _enqueuing_is_done(false), | |
251 _discovery_is_mt(false), | |
342
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
252 _discovered_list_needs_barrier(false), |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
253 _bs(NULL), |
0 | 254 _is_alive_non_header(NULL), |
255 _num_q(0), | |
1833
8b10f48633dc
6984287: Regularize how GC parallel workers are specified.
jmasa
parents:
1552
diff
changeset
|
256 _max_num_q(0), |
0 | 257 _processing_is_mt(false), |
258 _next_id(0) | |
259 {} | |
260 | |
261 ReferenceProcessor(MemRegion span, bool atomic_discovery, | |
342
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
262 bool mt_discovery, |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
263 int mt_degree = 1, |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
264 bool mt_processing = false, |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
265 bool discovered_list_needs_barrier = false); |
0 | 266 |
267 // Allocates and initializes a reference processor. | |
268 static ReferenceProcessor* create_ref_processor( | |
269 MemRegion span, | |
270 bool atomic_discovery, | |
271 bool mt_discovery, | |
272 BoolObjectClosure* is_alive_non_header = NULL, | |
273 int parallel_gc_threads = 1, | |
342
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
274 bool mt_processing = false, |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
275 bool discovered_list_needs_barrier = false); |
1244
745c853ee57f
6885297: java -XX:RefDiscoveryPolicy=2 or -XX:TLABWasteTargetPercent=0 cause VM crash
johnc
parents:
1190
diff
changeset
|
276 |
0 | 277 // RefDiscoveryPolicy values |
1244
745c853ee57f
6885297: java -XX:RefDiscoveryPolicy=2 or -XX:TLABWasteTargetPercent=0 cause VM crash
johnc
parents:
1190
diff
changeset
|
278 enum DiscoveryPolicy { |
0 | 279 ReferenceBasedDiscovery = 0, |
1244
745c853ee57f
6885297: java -XX:RefDiscoveryPolicy=2 or -XX:TLABWasteTargetPercent=0 cause VM crash
johnc
parents:
1190
diff
changeset
|
280 ReferentBasedDiscovery = 1, |
745c853ee57f
6885297: java -XX:RefDiscoveryPolicy=2 or -XX:TLABWasteTargetPercent=0 cause VM crash
johnc
parents:
1190
diff
changeset
|
281 DiscoveryPolicyMin = ReferenceBasedDiscovery, |
745c853ee57f
6885297: java -XX:RefDiscoveryPolicy=2 or -XX:TLABWasteTargetPercent=0 cause VM crash
johnc
parents:
1190
diff
changeset
|
282 DiscoveryPolicyMax = ReferentBasedDiscovery |
0 | 283 }; |
284 | |
285 static void init_statics(); | |
286 | |
287 public: | |
288 // get and set "is_alive_non_header" field | |
289 BoolObjectClosure* is_alive_non_header() { | |
290 return _is_alive_non_header; | |
291 } | |
292 void set_is_alive_non_header(BoolObjectClosure* is_alive_non_header) { | |
293 _is_alive_non_header = is_alive_non_header; | |
294 } | |
295 | |
296 // get and set span | |
297 MemRegion span() { return _span; } | |
298 void set_span(MemRegion span) { _span = span; } | |
299 | |
300 // start and stop weak ref discovery | |
301 void enable_discovery() { _discovering_refs = true; } | |
302 void disable_discovery() { _discovering_refs = false; } | |
303 bool discovery_enabled() { return _discovering_refs; } | |
304 | |
305 // whether discovery is atomic wrt other collectors | |
306 bool discovery_is_atomic() const { return _discovery_is_atomic; } | |
307 void set_atomic_discovery(bool atomic) { _discovery_is_atomic = atomic; } | |
308 | |
309 // whether discovery is done by multiple threads same-old-timeously | |
310 bool discovery_is_mt() const { return _discovery_is_mt; } | |
311 void set_mt_discovery(bool mt) { _discovery_is_mt = mt; } | |
312 | |
313 // Whether we are in a phase when _processing_ is MT. | |
314 bool processing_is_mt() const { return _processing_is_mt; } | |
315 void set_mt_processing(bool mt) { _processing_is_mt = mt; } | |
316 | |
317 // whether all enqueuing of weak references is complete | |
318 bool enqueuing_is_done() { return _enqueuing_is_done; } | |
319 void set_enqueuing_is_done(bool v) { _enqueuing_is_done = v; } | |
320 | |
321 // iterate over oops | |
322 void weak_oops_do(OopClosure* f); // weak roots | |
323 static void oops_do(OopClosure* f); // strong root(s) | |
324 | |
1833
8b10f48633dc
6984287: Regularize how GC parallel workers are specified.
jmasa
parents:
1552
diff
changeset
|
325 // Balance each of the discovered lists. |
8b10f48633dc
6984287: Regularize how GC parallel workers are specified.
jmasa
parents:
1552
diff
changeset
|
326 void balance_all_queues(); |
8b10f48633dc
6984287: Regularize how GC parallel workers are specified.
jmasa
parents:
1552
diff
changeset
|
327 |
0 | 328 // Discover a Reference object, using appropriate discovery criteria |
329 bool discover_reference(oop obj, ReferenceType rt); | |
330 | |
331 // Process references found during GC (called by the garbage collector) | |
453
c96030fff130
6684579: SoftReference processing can be made more efficient
ysr
parents:
356
diff
changeset
|
332 void process_discovered_references(BoolObjectClosure* is_alive, |
0 | 333 OopClosure* keep_alive, |
334 VoidClosure* complete_gc, | |
335 AbstractRefProcTaskExecutor* task_executor); | |
336 | |
337 public: | |
338 // Enqueue references at end of GC (called by the garbage collector) | |
339 bool enqueue_discovered_references(AbstractRefProcTaskExecutor* task_executor = NULL); | |
340 | |
342
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
341 // If a discovery is in process that is being superceded, abandon it: all |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
342 // the discovered lists will be empty, and all the objects on them will |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
343 // have NULL discovered fields. Must be called only at a safepoint. |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
344 void abandon_partial_discovery(); |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
345 |
0 | 346 // debugging |
347 void verify_no_references_recorded() PRODUCT_RETURN; | |
348 static void verify(); | |
349 | |
350 // clear the discovered lists (unlinking each entry). | |
351 void clear_discovered_references() PRODUCT_RETURN; | |
352 }; | |
353 | |
354 // A utility class to disable reference discovery in | |
355 // the scope which contains it, for given ReferenceProcessor. | |
356 class NoRefDiscovery: StackObj { | |
357 private: | |
358 ReferenceProcessor* _rp; | |
359 bool _was_discovering_refs; | |
360 public: | |
361 NoRefDiscovery(ReferenceProcessor* rp) : _rp(rp) { | |
1789
a83b0246bb77
6934483: GCC 4.5 errors "suggest parentheses around something..." when compiling with -Werror and -Wall
twisti
parents:
1552
diff
changeset
|
362 _was_discovering_refs = _rp->discovery_enabled(); |
a83b0246bb77
6934483: GCC 4.5 errors "suggest parentheses around something..." when compiling with -Werror and -Wall
twisti
parents:
1552
diff
changeset
|
363 if (_was_discovering_refs) { |
0 | 364 _rp->disable_discovery(); |
365 } | |
366 } | |
367 | |
368 ~NoRefDiscovery() { | |
369 if (_was_discovering_refs) { | |
370 _rp->enable_discovery(); | |
371 } | |
372 } | |
373 }; | |
374 | |
375 | |
376 // A utility class to temporarily mutate the span of the | |
377 // given ReferenceProcessor in the scope that contains it. | |
378 class ReferenceProcessorSpanMutator: StackObj { | |
379 private: | |
380 ReferenceProcessor* _rp; | |
381 MemRegion _saved_span; | |
382 | |
383 public: | |
384 ReferenceProcessorSpanMutator(ReferenceProcessor* rp, | |
385 MemRegion span): | |
386 _rp(rp) { | |
387 _saved_span = _rp->span(); | |
388 _rp->set_span(span); | |
389 } | |
390 | |
391 ~ReferenceProcessorSpanMutator() { | |
392 _rp->set_span(_saved_span); | |
393 } | |
394 }; | |
395 | |
396 // A utility class to temporarily change the MT'ness of | |
397 // reference discovery for the given ReferenceProcessor | |
398 // in the scope that contains it. | |
399 class ReferenceProcessorMTMutator: StackObj { | |
400 private: | |
401 ReferenceProcessor* _rp; | |
402 bool _saved_mt; | |
403 | |
404 public: | |
405 ReferenceProcessorMTMutator(ReferenceProcessor* rp, | |
406 bool mt): | |
407 _rp(rp) { | |
408 _saved_mt = _rp->discovery_is_mt(); | |
409 _rp->set_mt_discovery(mt); | |
410 } | |
411 | |
412 ~ReferenceProcessorMTMutator() { | |
413 _rp->set_mt_discovery(_saved_mt); | |
414 } | |
415 }; | |
416 | |
417 | |
418 // A utility class to temporarily change the disposition | |
419 // of the "is_alive_non_header" closure field of the | |
420 // given ReferenceProcessor in the scope that contains it. | |
421 class ReferenceProcessorIsAliveMutator: StackObj { | |
422 private: | |
423 ReferenceProcessor* _rp; | |
424 BoolObjectClosure* _saved_cl; | |
425 | |
426 public: | |
427 ReferenceProcessorIsAliveMutator(ReferenceProcessor* rp, | |
428 BoolObjectClosure* cl): | |
429 _rp(rp) { | |
430 _saved_cl = _rp->is_alive_non_header(); | |
431 _rp->set_is_alive_non_header(cl); | |
432 } | |
433 | |
434 ~ReferenceProcessorIsAliveMutator() { | |
435 _rp->set_is_alive_non_header(_saved_cl); | |
436 } | |
437 }; | |
438 | |
439 // A utility class to temporarily change the disposition | |
440 // of the "discovery_is_atomic" field of the | |
441 // given ReferenceProcessor in the scope that contains it. | |
442 class ReferenceProcessorAtomicMutator: StackObj { | |
443 private: | |
444 ReferenceProcessor* _rp; | |
445 bool _saved_atomic_discovery; | |
446 | |
447 public: | |
448 ReferenceProcessorAtomicMutator(ReferenceProcessor* rp, | |
449 bool atomic): | |
450 _rp(rp) { | |
451 _saved_atomic_discovery = _rp->discovery_is_atomic(); | |
452 _rp->set_atomic_discovery(atomic); | |
453 } | |
454 | |
455 ~ReferenceProcessorAtomicMutator() { | |
456 _rp->set_atomic_discovery(_saved_atomic_discovery); | |
457 } | |
458 }; | |
459 | |
460 | |
461 // A utility class to temporarily change the MT processing | |
462 // disposition of the given ReferenceProcessor instance | |
463 // in the scope that contains it. | |
464 class ReferenceProcessorMTProcMutator: StackObj { | |
465 private: | |
466 ReferenceProcessor* _rp; | |
467 bool _saved_mt; | |
468 | |
469 public: | |
470 ReferenceProcessorMTProcMutator(ReferenceProcessor* rp, | |
471 bool mt): | |
472 _rp(rp) { | |
473 _saved_mt = _rp->processing_is_mt(); | |
474 _rp->set_mt_processing(mt); | |
475 } | |
476 | |
477 ~ReferenceProcessorMTProcMutator() { | |
478 _rp->set_mt_processing(_saved_mt); | |
479 } | |
480 }; | |
481 | |
482 | |
483 // This class is an interface used to implement task execution for the | |
484 // reference processing. | |
485 class AbstractRefProcTaskExecutor { | |
486 public: | |
487 | |
488 // Abstract tasks to execute. | |
489 class ProcessTask; | |
490 class EnqueueTask; | |
491 | |
492 // Executes a task using worker threads. | |
493 virtual void execute(ProcessTask& task) = 0; | |
494 virtual void execute(EnqueueTask& task) = 0; | |
495 | |
496 // Switch to single threaded mode. | |
497 virtual void set_single_threaded_mode() { }; | |
498 }; | |
499 | |
500 // Abstract reference processing task to execute. | |
501 class AbstractRefProcTaskExecutor::ProcessTask { | |
502 protected: | |
503 ProcessTask(ReferenceProcessor& ref_processor, | |
504 DiscoveredList refs_lists[], | |
505 bool marks_oops_alive) | |
506 : _ref_processor(ref_processor), | |
507 _refs_lists(refs_lists), | |
508 _marks_oops_alive(marks_oops_alive) | |
509 { } | |
510 | |
511 public: | |
512 virtual void work(unsigned int work_id, BoolObjectClosure& is_alive, | |
513 OopClosure& keep_alive, | |
514 VoidClosure& complete_gc) = 0; | |
515 | |
516 // Returns true if a task marks some oops as alive. | |
517 bool marks_oops_alive() const | |
518 { return _marks_oops_alive; } | |
519 | |
520 protected: | |
521 ReferenceProcessor& _ref_processor; | |
522 DiscoveredList* _refs_lists; | |
523 const bool _marks_oops_alive; | |
524 }; | |
525 | |
526 // Abstract reference processing task to execute. | |
527 class AbstractRefProcTaskExecutor::EnqueueTask { | |
528 protected: | |
529 EnqueueTask(ReferenceProcessor& ref_processor, | |
530 DiscoveredList refs_lists[], | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
531 HeapWord* pending_list_addr, |
0 | 532 oop sentinel_ref, |
533 int n_queues) | |
534 : _ref_processor(ref_processor), | |
535 _refs_lists(refs_lists), | |
536 _pending_list_addr(pending_list_addr), | |
537 _sentinel_ref(sentinel_ref), | |
538 _n_queues(n_queues) | |
539 { } | |
540 | |
541 public: | |
542 virtual void work(unsigned int work_id) = 0; | |
543 | |
544 protected: | |
545 ReferenceProcessor& _ref_processor; | |
546 DiscoveredList* _refs_lists; | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
547 HeapWord* _pending_list_addr; |
0 | 548 oop _sentinel_ref; |
549 int _n_queues; | |
550 }; | |
1972 | 551 |
552 #endif // SHARE_VM_MEMORY_REFERENCEPROCESSOR_HPP |