Mercurial > hg > graal-compiler
annotate src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp @ 1656:4e5661ba9d98
6944166: G1: explicit GCs are not always handled correctly
Summary: G1 was not handling explicit GCs correctly in many ways. It does now. See the CR for the list of improvements contained in this changeset.
Reviewed-by: iveresov, ysr, johnc
author | tonyp |
---|---|
date | Mon, 28 Jun 2010 14:13:17 -0400 |
parents | 215576b54709 |
children | 5cbac8938c4c |
rev | line source |
---|---|
342 | 1 /* |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1547
diff
changeset
|
2 * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved. |
342 | 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:
1547
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1547
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:
1547
diff
changeset
|
21 * questions. |
342 | 22 * |
23 */ | |
24 | |
25 #include "incls/_precompiled.incl" | |
26 #include "incls/_g1CollectedHeap.cpp.incl" | |
27 | |
942
2c79770d1f6e
6819085: G1: use larger and/or user settable region size
tonyp
parents:
941
diff
changeset
|
28 size_t G1CollectedHeap::_humongous_object_threshold_in_words = 0; |
2c79770d1f6e
6819085: G1: use larger and/or user settable region size
tonyp
parents:
941
diff
changeset
|
29 |
342 | 30 // turn it on so that the contents of the young list (scan-only / |
31 // to-be-collected) are printed at "strategic" points before / during | |
32 // / after the collection --- this is useful for debugging | |
1394
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
33 #define YOUNG_LIST_VERBOSE 0 |
342 | 34 // CURRENT STATUS |
35 // This file is under construction. Search for "FIXME". | |
36 | |
37 // INVARIANTS/NOTES | |
38 // | |
39 // All allocation activity covered by the G1CollectedHeap interface is | |
40 // serialized by acquiring the HeapLock. This happens in | |
41 // mem_allocate_work, which all such allocation functions call. | |
42 // (Note that this does not apply to TLAB allocation, which is not part | |
43 // of this interface: it is done by clients of this interface.) | |
44 | |
45 // Local to this file. | |
46 | |
47 class RefineCardTableEntryClosure: public CardTableEntryClosure { | |
48 SuspendibleThreadSet* _sts; | |
49 G1RemSet* _g1rs; | |
50 ConcurrentG1Refine* _cg1r; | |
51 bool _concurrent; | |
52 public: | |
53 RefineCardTableEntryClosure(SuspendibleThreadSet* sts, | |
54 G1RemSet* g1rs, | |
55 ConcurrentG1Refine* cg1r) : | |
56 _sts(sts), _g1rs(g1rs), _cg1r(cg1r), _concurrent(true) | |
57 {} | |
58 bool do_card_ptr(jbyte* card_ptr, int worker_i) { | |
59 _g1rs->concurrentRefineOneCard(card_ptr, worker_i); | |
60 if (_concurrent && _sts->should_yield()) { | |
61 // Caller will actually yield. | |
62 return false; | |
63 } | |
64 // Otherwise, we finished successfully; return true. | |
65 return true; | |
66 } | |
67 void set_concurrent(bool b) { _concurrent = b; } | |
68 }; | |
69 | |
70 | |
71 class ClearLoggedCardTableEntryClosure: public CardTableEntryClosure { | |
72 int _calls; | |
73 G1CollectedHeap* _g1h; | |
74 CardTableModRefBS* _ctbs; | |
75 int _histo[256]; | |
76 public: | |
77 ClearLoggedCardTableEntryClosure() : | |
78 _calls(0) | |
79 { | |
80 _g1h = G1CollectedHeap::heap(); | |
81 _ctbs = (CardTableModRefBS*)_g1h->barrier_set(); | |
82 for (int i = 0; i < 256; i++) _histo[i] = 0; | |
83 } | |
84 bool do_card_ptr(jbyte* card_ptr, int worker_i) { | |
85 if (_g1h->is_in_reserved(_ctbs->addr_for(card_ptr))) { | |
86 _calls++; | |
87 unsigned char* ujb = (unsigned char*)card_ptr; | |
88 int ind = (int)(*ujb); | |
89 _histo[ind]++; | |
90 *card_ptr = -1; | |
91 } | |
92 return true; | |
93 } | |
94 int calls() { return _calls; } | |
95 void print_histo() { | |
96 gclog_or_tty->print_cr("Card table value histogram:"); | |
97 for (int i = 0; i < 256; i++) { | |
98 if (_histo[i] != 0) { | |
99 gclog_or_tty->print_cr(" %d: %d", i, _histo[i]); | |
100 } | |
101 } | |
102 } | |
103 }; | |
104 | |
105 class RedirtyLoggedCardTableEntryClosure: public CardTableEntryClosure { | |
106 int _calls; | |
107 G1CollectedHeap* _g1h; | |
108 CardTableModRefBS* _ctbs; | |
109 public: | |
110 RedirtyLoggedCardTableEntryClosure() : | |
111 _calls(0) | |
112 { | |
113 _g1h = G1CollectedHeap::heap(); | |
114 _ctbs = (CardTableModRefBS*)_g1h->barrier_set(); | |
115 } | |
116 bool do_card_ptr(jbyte* card_ptr, int worker_i) { | |
117 if (_g1h->is_in_reserved(_ctbs->addr_for(card_ptr))) { | |
118 _calls++; | |
119 *card_ptr = 0; | |
120 } | |
121 return true; | |
122 } | |
123 int calls() { return _calls; } | |
124 }; | |
125 | |
616
4f360ec815ba
6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents:
595
diff
changeset
|
126 class RedirtyLoggedCardTableEntryFastClosure : public CardTableEntryClosure { |
4f360ec815ba
6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents:
595
diff
changeset
|
127 public: |
4f360ec815ba
6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents:
595
diff
changeset
|
128 bool do_card_ptr(jbyte* card_ptr, int worker_i) { |
4f360ec815ba
6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents:
595
diff
changeset
|
129 *card_ptr = CardTableModRefBS::dirty_card_val(); |
4f360ec815ba
6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents:
595
diff
changeset
|
130 return true; |
4f360ec815ba
6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents:
595
diff
changeset
|
131 } |
4f360ec815ba
6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents:
595
diff
changeset
|
132 }; |
4f360ec815ba
6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents:
595
diff
changeset
|
133 |
342 | 134 YoungList::YoungList(G1CollectedHeap* g1h) |
135 : _g1h(g1h), _head(NULL), | |
1394
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
136 _length(0), |
342 | 137 _last_sampled_rs_lengths(0), |
545 | 138 _survivor_head(NULL), _survivor_tail(NULL), _survivor_length(0) |
342 | 139 { |
140 guarantee( check_list_empty(false), "just making sure..." ); | |
141 } | |
142 | |
143 void YoungList::push_region(HeapRegion *hr) { | |
144 assert(!hr->is_young(), "should not already be young"); | |
145 assert(hr->get_next_young_region() == NULL, "cause it should!"); | |
146 | |
147 hr->set_next_young_region(_head); | |
148 _head = hr; | |
149 | |
150 hr->set_young(); | |
151 double yg_surv_rate = _g1h->g1_policy()->predict_yg_surv_rate((int)_length); | |
152 ++_length; | |
153 } | |
154 | |
155 void YoungList::add_survivor_region(HeapRegion* hr) { | |
545 | 156 assert(hr->is_survivor(), "should be flagged as survivor region"); |
342 | 157 assert(hr->get_next_young_region() == NULL, "cause it should!"); |
158 | |
159 hr->set_next_young_region(_survivor_head); | |
160 if (_survivor_head == NULL) { | |
545 | 161 _survivor_tail = hr; |
342 | 162 } |
163 _survivor_head = hr; | |
164 | |
165 ++_survivor_length; | |
166 } | |
167 | |
168 void YoungList::empty_list(HeapRegion* list) { | |
169 while (list != NULL) { | |
170 HeapRegion* next = list->get_next_young_region(); | |
171 list->set_next_young_region(NULL); | |
172 list->uninstall_surv_rate_group(); | |
173 list->set_not_young(); | |
174 list = next; | |
175 } | |
176 } | |
177 | |
178 void YoungList::empty_list() { | |
179 assert(check_list_well_formed(), "young list should be well formed"); | |
180 | |
181 empty_list(_head); | |
182 _head = NULL; | |
183 _length = 0; | |
184 | |
185 empty_list(_survivor_head); | |
186 _survivor_head = NULL; | |
545 | 187 _survivor_tail = NULL; |
342 | 188 _survivor_length = 0; |
189 | |
190 _last_sampled_rs_lengths = 0; | |
191 | |
192 assert(check_list_empty(false), "just making sure..."); | |
193 } | |
194 | |
195 bool YoungList::check_list_well_formed() { | |
196 bool ret = true; | |
197 | |
198 size_t length = 0; | |
199 HeapRegion* curr = _head; | |
200 HeapRegion* last = NULL; | |
201 while (curr != NULL) { | |
1394
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
202 if (!curr->is_young()) { |
342 | 203 gclog_or_tty->print_cr("### YOUNG REGION "PTR_FORMAT"-"PTR_FORMAT" " |
1394
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
204 "incorrectly tagged (y: %d, surv: %d)", |
342 | 205 curr->bottom(), curr->end(), |
1394
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
206 curr->is_young(), curr->is_survivor()); |
342 | 207 ret = false; |
208 } | |
209 ++length; | |
210 last = curr; | |
211 curr = curr->get_next_young_region(); | |
212 } | |
213 ret = ret && (length == _length); | |
214 | |
215 if (!ret) { | |
216 gclog_or_tty->print_cr("### YOUNG LIST seems not well formed!"); | |
217 gclog_or_tty->print_cr("### list has %d entries, _length is %d", | |
218 length, _length); | |
219 } | |
220 | |
1394
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
221 return ret; |
342 | 222 } |
223 | |
1394
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
224 bool YoungList::check_list_empty(bool check_sample) { |
342 | 225 bool ret = true; |
226 | |
227 if (_length != 0) { | |
228 gclog_or_tty->print_cr("### YOUNG LIST should have 0 length, not %d", | |
229 _length); | |
230 ret = false; | |
231 } | |
232 if (check_sample && _last_sampled_rs_lengths != 0) { | |
233 gclog_or_tty->print_cr("### YOUNG LIST has non-zero last sampled RS lengths"); | |
234 ret = false; | |
235 } | |
236 if (_head != NULL) { | |
237 gclog_or_tty->print_cr("### YOUNG LIST does not have a NULL head"); | |
238 ret = false; | |
239 } | |
240 if (!ret) { | |
241 gclog_or_tty->print_cr("### YOUNG LIST does not seem empty"); | |
242 } | |
243 | |
1394
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
244 return ret; |
342 | 245 } |
246 | |
247 void | |
248 YoungList::rs_length_sampling_init() { | |
249 _sampled_rs_lengths = 0; | |
250 _curr = _head; | |
251 } | |
252 | |
253 bool | |
254 YoungList::rs_length_sampling_more() { | |
255 return _curr != NULL; | |
256 } | |
257 | |
258 void | |
259 YoungList::rs_length_sampling_next() { | |
260 assert( _curr != NULL, "invariant" ); | |
1394
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
261 size_t rs_length = _curr->rem_set()->occupied(); |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
262 |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
263 _sampled_rs_lengths += rs_length; |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
264 |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
265 // The current region may not yet have been added to the |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
266 // incremental collection set (it gets added when it is |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
267 // retired as the current allocation region). |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
268 if (_curr->in_collection_set()) { |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
269 // Update the collection set policy information for this region |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
270 _g1h->g1_policy()->update_incremental_cset_info(_curr, rs_length); |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
271 } |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
272 |
342 | 273 _curr = _curr->get_next_young_region(); |
274 if (_curr == NULL) { | |
275 _last_sampled_rs_lengths = _sampled_rs_lengths; | |
276 // gclog_or_tty->print_cr("last sampled RS lengths = %d", _last_sampled_rs_lengths); | |
277 } | |
278 } | |
279 | |
280 void | |
281 YoungList::reset_auxilary_lists() { | |
282 guarantee( is_empty(), "young list should be empty" ); | |
283 assert(check_list_well_formed(), "young list should be well formed"); | |
284 | |
285 // Add survivor regions to SurvRateGroup. | |
286 _g1h->g1_policy()->note_start_adding_survivor_regions(); | |
545 | 287 _g1h->g1_policy()->finished_recalculating_age_indexes(true /* is_survivors */); |
1394
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
288 |
342 | 289 for (HeapRegion* curr = _survivor_head; |
290 curr != NULL; | |
291 curr = curr->get_next_young_region()) { | |
292 _g1h->g1_policy()->set_region_survivors(curr); | |
1394
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
293 |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
294 // The region is a non-empty survivor so let's add it to |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
295 // the incremental collection set for the next evacuation |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
296 // pause. |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
297 _g1h->g1_policy()->add_region_to_incremental_cset_rhs(curr); |
342 | 298 } |
299 _g1h->g1_policy()->note_stop_adding_survivor_regions(); | |
300 | |
1394
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
301 _head = _survivor_head; |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
302 _length = _survivor_length; |
342 | 303 if (_survivor_head != NULL) { |
1394
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
304 assert(_survivor_tail != NULL, "cause it shouldn't be"); |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
305 assert(_survivor_length > 0, "invariant"); |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
306 _survivor_tail->set_next_young_region(NULL); |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
307 } |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
308 |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
309 // Don't clear the survivor list handles until the start of |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
310 // the next evacuation pause - we need it in order to re-tag |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
311 // the survivor regions from this evacuation pause as 'young' |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
312 // at the start of the next. |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
313 |
545 | 314 _g1h->g1_policy()->finished_recalculating_age_indexes(false /* is_survivors */); |
342 | 315 |
316 assert(check_list_well_formed(), "young list should be well formed"); | |
317 } | |
318 | |
319 void YoungList::print() { | |
1394
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
320 HeapRegion* lists[] = {_head, _survivor_head}; |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
321 const char* names[] = {"YOUNG", "SURVIVOR"}; |
342 | 322 |
323 for (unsigned int list = 0; list < ARRAY_SIZE(lists); ++list) { | |
324 gclog_or_tty->print_cr("%s LIST CONTENTS", names[list]); | |
325 HeapRegion *curr = lists[list]; | |
326 if (curr == NULL) | |
327 gclog_or_tty->print_cr(" empty"); | |
328 while (curr != NULL) { | |
329 gclog_or_tty->print_cr(" [%08x-%08x], t: %08x, P: %08x, N: %08x, C: %08x, " | |
1394
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
330 "age: %4d, y: %d, surv: %d", |
342 | 331 curr->bottom(), curr->end(), |
332 curr->top(), | |
333 curr->prev_top_at_mark_start(), | |
334 curr->next_top_at_mark_start(), | |
335 curr->top_at_conc_mark_count(), | |
336 curr->age_in_surv_rate_group_cond(), | |
337 curr->is_young(), | |
338 curr->is_survivor()); | |
339 curr = curr->get_next_young_region(); | |
340 } | |
341 } | |
342 | |
343 gclog_or_tty->print_cr(""); | |
344 } | |
345 | |
796
29e7d79232b9
6819065: G1: eliminate high serial card table clearing time
apetrusenko
parents:
794
diff
changeset
|
346 void G1CollectedHeap::push_dirty_cards_region(HeapRegion* hr) |
29e7d79232b9
6819065: G1: eliminate high serial card table clearing time
apetrusenko
parents:
794
diff
changeset
|
347 { |
29e7d79232b9
6819065: G1: eliminate high serial card table clearing time
apetrusenko
parents:
794
diff
changeset
|
348 // Claim the right to put the region on the dirty cards region list |
29e7d79232b9
6819065: G1: eliminate high serial card table clearing time
apetrusenko
parents:
794
diff
changeset
|
349 // by installing a self pointer. |
29e7d79232b9
6819065: G1: eliminate high serial card table clearing time
apetrusenko
parents:
794
diff
changeset
|
350 HeapRegion* next = hr->get_next_dirty_cards_region(); |
29e7d79232b9
6819065: G1: eliminate high serial card table clearing time
apetrusenko
parents:
794
diff
changeset
|
351 if (next == NULL) { |
29e7d79232b9
6819065: G1: eliminate high serial card table clearing time
apetrusenko
parents:
794
diff
changeset
|
352 HeapRegion* res = (HeapRegion*) |
29e7d79232b9
6819065: G1: eliminate high serial card table clearing time
apetrusenko
parents:
794
diff
changeset
|
353 Atomic::cmpxchg_ptr(hr, hr->next_dirty_cards_region_addr(), |
29e7d79232b9
6819065: G1: eliminate high serial card table clearing time
apetrusenko
parents:
794
diff
changeset
|
354 NULL); |
29e7d79232b9
6819065: G1: eliminate high serial card table clearing time
apetrusenko
parents:
794
diff
changeset
|
355 if (res == NULL) { |
29e7d79232b9
6819065: G1: eliminate high serial card table clearing time
apetrusenko
parents:
794
diff
changeset
|
356 HeapRegion* head; |
29e7d79232b9
6819065: G1: eliminate high serial card table clearing time
apetrusenko
parents:
794
diff
changeset
|
357 do { |
29e7d79232b9
6819065: G1: eliminate high serial card table clearing time
apetrusenko
parents:
794
diff
changeset
|
358 // Put the region to the dirty cards region list. |
29e7d79232b9
6819065: G1: eliminate high serial card table clearing time
apetrusenko
parents:
794
diff
changeset
|
359 head = _dirty_cards_region_list; |
29e7d79232b9
6819065: G1: eliminate high serial card table clearing time
apetrusenko
parents:
794
diff
changeset
|
360 next = (HeapRegion*) |
29e7d79232b9
6819065: G1: eliminate high serial card table clearing time
apetrusenko
parents:
794
diff
changeset
|
361 Atomic::cmpxchg_ptr(hr, &_dirty_cards_region_list, head); |
29e7d79232b9
6819065: G1: eliminate high serial card table clearing time
apetrusenko
parents:
794
diff
changeset
|
362 if (next == head) { |
29e7d79232b9
6819065: G1: eliminate high serial card table clearing time
apetrusenko
parents:
794
diff
changeset
|
363 assert(hr->get_next_dirty_cards_region() == hr, |
29e7d79232b9
6819065: G1: eliminate high serial card table clearing time
apetrusenko
parents:
794
diff
changeset
|
364 "hr->get_next_dirty_cards_region() != hr"); |
29e7d79232b9
6819065: G1: eliminate high serial card table clearing time
apetrusenko
parents:
794
diff
changeset
|
365 if (next == NULL) { |
29e7d79232b9
6819065: G1: eliminate high serial card table clearing time
apetrusenko
parents:
794
diff
changeset
|
366 // The last region in the list points to itself. |
29e7d79232b9
6819065: G1: eliminate high serial card table clearing time
apetrusenko
parents:
794
diff
changeset
|
367 hr->set_next_dirty_cards_region(hr); |
29e7d79232b9
6819065: G1: eliminate high serial card table clearing time
apetrusenko
parents:
794
diff
changeset
|
368 } else { |
29e7d79232b9
6819065: G1: eliminate high serial card table clearing time
apetrusenko
parents:
794
diff
changeset
|
369 hr->set_next_dirty_cards_region(next); |
29e7d79232b9
6819065: G1: eliminate high serial card table clearing time
apetrusenko
parents:
794
diff
changeset
|
370 } |
29e7d79232b9
6819065: G1: eliminate high serial card table clearing time
apetrusenko
parents:
794
diff
changeset
|
371 } |
29e7d79232b9
6819065: G1: eliminate high serial card table clearing time
apetrusenko
parents:
794
diff
changeset
|
372 } while (next != head); |
29e7d79232b9
6819065: G1: eliminate high serial card table clearing time
apetrusenko
parents:
794
diff
changeset
|
373 } |
29e7d79232b9
6819065: G1: eliminate high serial card table clearing time
apetrusenko
parents:
794
diff
changeset
|
374 } |
29e7d79232b9
6819065: G1: eliminate high serial card table clearing time
apetrusenko
parents:
794
diff
changeset
|
375 } |
29e7d79232b9
6819065: G1: eliminate high serial card table clearing time
apetrusenko
parents:
794
diff
changeset
|
376 |
29e7d79232b9
6819065: G1: eliminate high serial card table clearing time
apetrusenko
parents:
794
diff
changeset
|
377 HeapRegion* G1CollectedHeap::pop_dirty_cards_region() |
29e7d79232b9
6819065: G1: eliminate high serial card table clearing time
apetrusenko
parents:
794
diff
changeset
|
378 { |
29e7d79232b9
6819065: G1: eliminate high serial card table clearing time
apetrusenko
parents:
794
diff
changeset
|
379 HeapRegion* head; |
29e7d79232b9
6819065: G1: eliminate high serial card table clearing time
apetrusenko
parents:
794
diff
changeset
|
380 HeapRegion* hr; |
29e7d79232b9
6819065: G1: eliminate high serial card table clearing time
apetrusenko
parents:
794
diff
changeset
|
381 do { |
29e7d79232b9
6819065: G1: eliminate high serial card table clearing time
apetrusenko
parents:
794
diff
changeset
|
382 head = _dirty_cards_region_list; |
29e7d79232b9
6819065: G1: eliminate high serial card table clearing time
apetrusenko
parents:
794
diff
changeset
|
383 if (head == NULL) { |
29e7d79232b9
6819065: G1: eliminate high serial card table clearing time
apetrusenko
parents:
794
diff
changeset
|
384 return NULL; |
29e7d79232b9
6819065: G1: eliminate high serial card table clearing time
apetrusenko
parents:
794
diff
changeset
|
385 } |
29e7d79232b9
6819065: G1: eliminate high serial card table clearing time
apetrusenko
parents:
794
diff
changeset
|
386 HeapRegion* new_head = head->get_next_dirty_cards_region(); |
29e7d79232b9
6819065: G1: eliminate high serial card table clearing time
apetrusenko
parents:
794
diff
changeset
|
387 if (head == new_head) { |
29e7d79232b9
6819065: G1: eliminate high serial card table clearing time
apetrusenko
parents:
794
diff
changeset
|
388 // The last region. |
29e7d79232b9
6819065: G1: eliminate high serial card table clearing time
apetrusenko
parents:
794
diff
changeset
|
389 new_head = NULL; |
29e7d79232b9
6819065: G1: eliminate high serial card table clearing time
apetrusenko
parents:
794
diff
changeset
|
390 } |
29e7d79232b9
6819065: G1: eliminate high serial card table clearing time
apetrusenko
parents:
794
diff
changeset
|
391 hr = (HeapRegion*)Atomic::cmpxchg_ptr(new_head, &_dirty_cards_region_list, |
29e7d79232b9
6819065: G1: eliminate high serial card table clearing time
apetrusenko
parents:
794
diff
changeset
|
392 head); |
29e7d79232b9
6819065: G1: eliminate high serial card table clearing time
apetrusenko
parents:
794
diff
changeset
|
393 } while (hr != head); |
29e7d79232b9
6819065: G1: eliminate high serial card table clearing time
apetrusenko
parents:
794
diff
changeset
|
394 assert(hr != NULL, "invariant"); |
29e7d79232b9
6819065: G1: eliminate high serial card table clearing time
apetrusenko
parents:
794
diff
changeset
|
395 hr->set_next_dirty_cards_region(NULL); |
29e7d79232b9
6819065: G1: eliminate high serial card table clearing time
apetrusenko
parents:
794
diff
changeset
|
396 return hr; |
29e7d79232b9
6819065: G1: eliminate high serial card table clearing time
apetrusenko
parents:
794
diff
changeset
|
397 } |
29e7d79232b9
6819065: G1: eliminate high serial card table clearing time
apetrusenko
parents:
794
diff
changeset
|
398 |
342 | 399 void G1CollectedHeap::stop_conc_gc_threads() { |
794 | 400 _cg1r->stop(); |
342 | 401 _czft->stop(); |
402 _cmThread->stop(); | |
403 } | |
404 | |
405 | |
406 void G1CollectedHeap::check_ct_logs_at_safepoint() { | |
407 DirtyCardQueueSet& dcqs = JavaThread::dirty_card_queue_set(); | |
408 CardTableModRefBS* ct_bs = (CardTableModRefBS*)barrier_set(); | |
409 | |
410 // Count the dirty cards at the start. | |
411 CountNonCleanMemRegionClosure count1(this); | |
412 ct_bs->mod_card_iterate(&count1); | |
413 int orig_count = count1.n(); | |
414 | |
415 // First clear the logged cards. | |
416 ClearLoggedCardTableEntryClosure clear; | |
417 dcqs.set_closure(&clear); | |
418 dcqs.apply_closure_to_all_completed_buffers(); | |
419 dcqs.iterate_closure_all_threads(false); | |
420 clear.print_histo(); | |
421 | |
422 // Now ensure that there's no dirty cards. | |
423 CountNonCleanMemRegionClosure count2(this); | |
424 ct_bs->mod_card_iterate(&count2); | |
425 if (count2.n() != 0) { | |
426 gclog_or_tty->print_cr("Card table has %d entries; %d originally", | |
427 count2.n(), orig_count); | |
428 } | |
429 guarantee(count2.n() == 0, "Card table should be clean."); | |
430 | |
431 RedirtyLoggedCardTableEntryClosure redirty; | |
432 JavaThread::dirty_card_queue_set().set_closure(&redirty); | |
433 dcqs.apply_closure_to_all_completed_buffers(); | |
434 dcqs.iterate_closure_all_threads(false); | |
435 gclog_or_tty->print_cr("Log entries = %d, dirty cards = %d.", | |
436 clear.calls(), orig_count); | |
437 guarantee(redirty.calls() == clear.calls(), | |
438 "Or else mechanism is broken."); | |
439 | |
440 CountNonCleanMemRegionClosure count3(this); | |
441 ct_bs->mod_card_iterate(&count3); | |
442 if (count3.n() != orig_count) { | |
443 gclog_or_tty->print_cr("Should have restored them all: orig = %d, final = %d.", | |
444 orig_count, count3.n()); | |
445 guarantee(count3.n() >= orig_count, "Should have restored them all."); | |
446 } | |
447 | |
448 JavaThread::dirty_card_queue_set().set_closure(_refine_cte_cl); | |
449 } | |
450 | |
451 // Private class members. | |
452 | |
453 G1CollectedHeap* G1CollectedHeap::_g1h; | |
454 | |
455 // Private methods. | |
456 | |
457 // Finds a HeapRegion that can be used to allocate a given size of block. | |
458 | |
459 | |
460 HeapRegion* G1CollectedHeap::newAllocRegion_work(size_t word_size, | |
461 bool do_expand, | |
462 bool zero_filled) { | |
463 ConcurrentZFThread::note_region_alloc(); | |
464 HeapRegion* res = alloc_free_region_from_lists(zero_filled); | |
465 if (res == NULL && do_expand) { | |
466 expand(word_size * HeapWordSize); | |
467 res = alloc_free_region_from_lists(zero_filled); | |
468 assert(res == NULL || | |
469 (!res->isHumongous() && | |
470 (!zero_filled || | |
471 res->zero_fill_state() == HeapRegion::Allocated)), | |
472 "Alloc Regions must be zero filled (and non-H)"); | |
473 } | |
1545
cc387008223e
6921317: (partial) G1: assert(top() == bottom() || zfs == Allocated,"Region must be empty, or we must be setting it to
apetrusenko
parents:
1489
diff
changeset
|
474 if (res != NULL) { |
cc387008223e
6921317: (partial) G1: assert(top() == bottom() || zfs == Allocated,"Region must be empty, or we must be setting it to
apetrusenko
parents:
1489
diff
changeset
|
475 if (res->is_empty()) { |
cc387008223e
6921317: (partial) G1: assert(top() == bottom() || zfs == Allocated,"Region must be empty, or we must be setting it to
apetrusenko
parents:
1489
diff
changeset
|
476 _free_regions--; |
cc387008223e
6921317: (partial) G1: assert(top() == bottom() || zfs == Allocated,"Region must be empty, or we must be setting it to
apetrusenko
parents:
1489
diff
changeset
|
477 } |
cc387008223e
6921317: (partial) G1: assert(top() == bottom() || zfs == Allocated,"Region must be empty, or we must be setting it to
apetrusenko
parents:
1489
diff
changeset
|
478 assert(!res->isHumongous() && |
cc387008223e
6921317: (partial) G1: assert(top() == bottom() || zfs == Allocated,"Region must be empty, or we must be setting it to
apetrusenko
parents:
1489
diff
changeset
|
479 (!zero_filled || res->zero_fill_state() == HeapRegion::Allocated), |
cc387008223e
6921317: (partial) G1: assert(top() == bottom() || zfs == Allocated,"Region must be empty, or we must be setting it to
apetrusenko
parents:
1489
diff
changeset
|
480 err_msg("Non-young alloc Regions must be zero filled (and non-H):" |
cc387008223e
6921317: (partial) G1: assert(top() == bottom() || zfs == Allocated,"Region must be empty, or we must be setting it to
apetrusenko
parents:
1489
diff
changeset
|
481 " res->isHumongous()=%d, zero_filled=%d, res->zero_fill_state()=%d", |
cc387008223e
6921317: (partial) G1: assert(top() == bottom() || zfs == Allocated,"Region must be empty, or we must be setting it to
apetrusenko
parents:
1489
diff
changeset
|
482 res->isHumongous(), zero_filled, res->zero_fill_state())); |
cc387008223e
6921317: (partial) G1: assert(top() == bottom() || zfs == Allocated,"Region must be empty, or we must be setting it to
apetrusenko
parents:
1489
diff
changeset
|
483 assert(!res->is_on_unclean_list(), |
cc387008223e
6921317: (partial) G1: assert(top() == bottom() || zfs == Allocated,"Region must be empty, or we must be setting it to
apetrusenko
parents:
1489
diff
changeset
|
484 "Alloc Regions must not be on the unclean list"); |
cc387008223e
6921317: (partial) G1: assert(top() == bottom() || zfs == Allocated,"Region must be empty, or we must be setting it to
apetrusenko
parents:
1489
diff
changeset
|
485 if (G1PrintHeapRegions) { |
342 | 486 gclog_or_tty->print_cr("new alloc region %d:["PTR_FORMAT", "PTR_FORMAT"], " |
487 "top "PTR_FORMAT, | |
488 res->hrs_index(), res->bottom(), res->end(), res->top()); | |
489 } | |
490 } | |
491 return res; | |
492 } | |
493 | |
494 HeapRegion* G1CollectedHeap::newAllocRegionWithExpansion(int purpose, | |
495 size_t word_size, | |
496 bool zero_filled) { | |
497 HeapRegion* alloc_region = NULL; | |
498 if (_gc_alloc_region_counts[purpose] < g1_policy()->max_regions(purpose)) { | |
499 alloc_region = newAllocRegion_work(word_size, true, zero_filled); | |
500 if (purpose == GCAllocForSurvived && alloc_region != NULL) { | |
545 | 501 alloc_region->set_survivor(); |
342 | 502 } |
503 ++_gc_alloc_region_counts[purpose]; | |
504 } else { | |
505 g1_policy()->note_alloc_region_limit_reached(purpose); | |
506 } | |
507 return alloc_region; | |
508 } | |
509 | |
510 // If could fit into free regions w/o expansion, try. | |
511 // Otherwise, if can expand, do so. | |
512 // Otherwise, if using ex regions might help, try with ex given back. | |
513 HeapWord* G1CollectedHeap::humongousObjAllocate(size_t word_size) { | |
514 assert(regions_accounted_for(), "Region leakage!"); | |
515 | |
516 // We can't allocate H regions while cleanupComplete is running, since | |
517 // some of the regions we find to be empty might not yet be added to the | |
518 // unclean list. (If we're already at a safepoint, this call is | |
519 // unnecessary, not to mention wrong.) | |
520 if (!SafepointSynchronize::is_at_safepoint()) | |
521 wait_for_cleanup_complete(); | |
522 | |
523 size_t num_regions = | |
524 round_to(word_size, HeapRegion::GrainWords) / HeapRegion::GrainWords; | |
525 | |
526 // Special case if < one region??? | |
527 | |
528 // Remember the ft size. | |
529 size_t x_size = expansion_regions(); | |
530 | |
531 HeapWord* res = NULL; | |
532 bool eliminated_allocated_from_lists = false; | |
533 | |
534 // Can the allocation potentially fit in the free regions? | |
535 if (free_regions() >= num_regions) { | |
536 res = _hrs->obj_allocate(word_size); | |
537 } | |
538 if (res == NULL) { | |
539 // Try expansion. | |
540 size_t fs = _hrs->free_suffix(); | |
541 if (fs + x_size >= num_regions) { | |
542 expand((num_regions - fs) * HeapRegion::GrainBytes); | |
543 res = _hrs->obj_allocate(word_size); | |
544 assert(res != NULL, "This should have worked."); | |
545 } else { | |
546 // Expansion won't help. Are there enough free regions if we get rid | |
547 // of reservations? | |
548 size_t avail = free_regions(); | |
549 if (avail >= num_regions) { | |
550 res = _hrs->obj_allocate(word_size); | |
551 if (res != NULL) { | |
552 remove_allocated_regions_from_lists(); | |
553 eliminated_allocated_from_lists = true; | |
554 } | |
555 } | |
556 } | |
557 } | |
558 if (res != NULL) { | |
559 // Increment by the number of regions allocated. | |
560 // FIXME: Assumes regions all of size GrainBytes. | |
561 #ifndef PRODUCT | |
562 mr_bs()->verify_clean_region(MemRegion(res, res + num_regions * | |
563 HeapRegion::GrainWords)); | |
564 #endif | |
565 if (!eliminated_allocated_from_lists) | |
566 remove_allocated_regions_from_lists(); | |
567 _summary_bytes_used += word_size * HeapWordSize; | |
568 _free_regions -= num_regions; | |
569 _num_humongous_regions += (int) num_regions; | |
570 } | |
571 assert(regions_accounted_for(), "Region Leakage"); | |
572 return res; | |
573 } | |
574 | |
575 HeapWord* | |
576 G1CollectedHeap::attempt_allocation_slow(size_t word_size, | |
577 bool permit_collection_pause) { | |
578 HeapWord* res = NULL; | |
579 HeapRegion* allocated_young_region = NULL; | |
580 | |
581 assert( SafepointSynchronize::is_at_safepoint() || | |
582 Heap_lock->owned_by_self(), "pre condition of the call" ); | |
583 | |
584 if (isHumongous(word_size)) { | |
585 // Allocation of a humongous object can, in a sense, complete a | |
586 // partial region, if the previous alloc was also humongous, and | |
587 // caused the test below to succeed. | |
588 if (permit_collection_pause) | |
589 do_collection_pause_if_appropriate(word_size); | |
590 res = humongousObjAllocate(word_size); | |
591 assert(_cur_alloc_region == NULL | |
592 || !_cur_alloc_region->isHumongous(), | |
593 "Prevent a regression of this bug."); | |
594 | |
595 } else { | |
354
c0f8f7790199
6652160: G1: assert(cur_used_bytes == _g1->recalculate_used(),"It should!") at g1CollectorPolicy.cpp:1425
iveresov
parents:
353
diff
changeset
|
596 // We may have concurrent cleanup working at the time. Wait for it |
c0f8f7790199
6652160: G1: assert(cur_used_bytes == _g1->recalculate_used(),"It should!") at g1CollectorPolicy.cpp:1425
iveresov
parents:
353
diff
changeset
|
597 // to complete. In the future we would probably want to make the |
c0f8f7790199
6652160: G1: assert(cur_used_bytes == _g1->recalculate_used(),"It should!") at g1CollectorPolicy.cpp:1425
iveresov
parents:
353
diff
changeset
|
598 // concurrent cleanup truly concurrent by decoupling it from the |
c0f8f7790199
6652160: G1: assert(cur_used_bytes == _g1->recalculate_used(),"It should!") at g1CollectorPolicy.cpp:1425
iveresov
parents:
353
diff
changeset
|
599 // allocation. |
c0f8f7790199
6652160: G1: assert(cur_used_bytes == _g1->recalculate_used(),"It should!") at g1CollectorPolicy.cpp:1425
iveresov
parents:
353
diff
changeset
|
600 if (!SafepointSynchronize::is_at_safepoint()) |
c0f8f7790199
6652160: G1: assert(cur_used_bytes == _g1->recalculate_used(),"It should!") at g1CollectorPolicy.cpp:1425
iveresov
parents:
353
diff
changeset
|
601 wait_for_cleanup_complete(); |
342 | 602 // If we do a collection pause, this will be reset to a non-NULL |
603 // value. If we don't, nulling here ensures that we allocate a new | |
604 // region below. | |
605 if (_cur_alloc_region != NULL) { | |
606 // We're finished with the _cur_alloc_region. | |
1394
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
607 // As we're builing (at least the young portion) of the collection |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
608 // set incrementally we'll add the current allocation region to |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
609 // the collection set here. |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
610 if (_cur_alloc_region->is_young()) { |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
611 g1_policy()->add_region_to_incremental_cset_lhs(_cur_alloc_region); |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
612 } |
342 | 613 _summary_bytes_used += _cur_alloc_region->used(); |
614 _cur_alloc_region = NULL; | |
615 } | |
616 assert(_cur_alloc_region == NULL, "Invariant."); | |
617 // Completion of a heap region is perhaps a good point at which to do | |
618 // a collection pause. | |
619 if (permit_collection_pause) | |
620 do_collection_pause_if_appropriate(word_size); | |
621 // Make sure we have an allocation region available. | |
622 if (_cur_alloc_region == NULL) { | |
623 if (!SafepointSynchronize::is_at_safepoint()) | |
624 wait_for_cleanup_complete(); | |
625 bool next_is_young = should_set_young_locked(); | |
626 // If the next region is not young, make sure it's zero-filled. | |
627 _cur_alloc_region = newAllocRegion(word_size, !next_is_young); | |
628 if (_cur_alloc_region != NULL) { | |
629 _summary_bytes_used -= _cur_alloc_region->used(); | |
630 if (next_is_young) { | |
631 set_region_short_lived_locked(_cur_alloc_region); | |
632 allocated_young_region = _cur_alloc_region; | |
633 } | |
634 } | |
635 } | |
636 assert(_cur_alloc_region == NULL || !_cur_alloc_region->isHumongous(), | |
637 "Prevent a regression of this bug."); | |
638 | |
639 // Now retry the allocation. | |
640 if (_cur_alloc_region != NULL) { | |
641 res = _cur_alloc_region->allocate(word_size); | |
642 } | |
643 } | |
644 | |
645 // NOTE: fails frequently in PRT | |
646 assert(regions_accounted_for(), "Region leakage!"); | |
647 | |
648 if (res != NULL) { | |
649 if (!SafepointSynchronize::is_at_safepoint()) { | |
650 assert( permit_collection_pause, "invariant" ); | |
651 assert( Heap_lock->owned_by_self(), "invariant" ); | |
652 Heap_lock->unlock(); | |
653 } | |
654 | |
655 if (allocated_young_region != NULL) { | |
656 HeapRegion* hr = allocated_young_region; | |
657 HeapWord* bottom = hr->bottom(); | |
658 HeapWord* end = hr->end(); | |
659 MemRegion mr(bottom, end); | |
660 ((CardTableModRefBS*)_g1h->barrier_set())->dirty(mr); | |
661 } | |
662 } | |
663 | |
664 assert( SafepointSynchronize::is_at_safepoint() || | |
665 (res == NULL && Heap_lock->owned_by_self()) || | |
666 (res != NULL && !Heap_lock->owned_by_self()), | |
667 "post condition of the call" ); | |
668 | |
669 return res; | |
670 } | |
671 | |
672 HeapWord* | |
673 G1CollectedHeap::mem_allocate(size_t word_size, | |
674 bool is_noref, | |
675 bool is_tlab, | |
676 bool* gc_overhead_limit_was_exceeded) { | |
677 debug_only(check_for_valid_allocation_state()); | |
678 assert(no_gc_in_progress(), "Allocation during gc not allowed"); | |
679 HeapWord* result = NULL; | |
680 | |
681 // Loop until the allocation is satisified, | |
682 // or unsatisfied after GC. | |
683 for (int try_count = 1; /* return or throw */; try_count += 1) { | |
684 int gc_count_before; | |
685 { | |
686 Heap_lock->lock(); | |
687 result = attempt_allocation(word_size); | |
688 if (result != NULL) { | |
689 // attempt_allocation should have unlocked the heap lock | |
690 assert(is_in(result), "result not in heap"); | |
691 return result; | |
692 } | |
693 // Read the gc count while the heap lock is held. | |
694 gc_count_before = SharedHeap::heap()->total_collections(); | |
695 Heap_lock->unlock(); | |
696 } | |
697 | |
698 // Create the garbage collection operation... | |
699 VM_G1CollectForAllocation op(word_size, | |
700 gc_count_before); | |
701 | |
702 // ...and get the VM thread to execute it. | |
703 VMThread::execute(&op); | |
704 if (op.prologue_succeeded()) { | |
705 result = op.result(); | |
706 assert(result == NULL || is_in(result), "result not in heap"); | |
707 return result; | |
708 } | |
709 | |
710 // Give a warning if we seem to be looping forever. | |
711 if ((QueuedAllocationWarningCount > 0) && | |
712 (try_count % QueuedAllocationWarningCount == 0)) { | |
713 warning("G1CollectedHeap::mem_allocate_work retries %d times", | |
714 try_count); | |
715 } | |
716 } | |
717 } | |
718 | |
719 void G1CollectedHeap::abandon_cur_alloc_region() { | |
720 if (_cur_alloc_region != NULL) { | |
721 // We're finished with the _cur_alloc_region. | |
722 if (_cur_alloc_region->is_empty()) { | |
723 _free_regions++; | |
724 free_region(_cur_alloc_region); | |
725 } else { | |
1394
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
726 // As we're builing (at least the young portion) of the collection |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
727 // set incrementally we'll add the current allocation region to |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
728 // the collection set here. |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
729 if (_cur_alloc_region->is_young()) { |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
730 g1_policy()->add_region_to_incremental_cset_lhs(_cur_alloc_region); |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
731 } |
342 | 732 _summary_bytes_used += _cur_alloc_region->used(); |
733 } | |
734 _cur_alloc_region = NULL; | |
735 } | |
736 } | |
737 | |
636 | 738 void G1CollectedHeap::abandon_gc_alloc_regions() { |
739 // first, make sure that the GC alloc region list is empty (it should!) | |
740 assert(_gc_alloc_region_list == NULL, "invariant"); | |
741 release_gc_alloc_regions(true /* totally */); | |
742 } | |
743 | |
342 | 744 class PostMCRemSetClearClosure: public HeapRegionClosure { |
745 ModRefBarrierSet* _mr_bs; | |
746 public: | |
747 PostMCRemSetClearClosure(ModRefBarrierSet* mr_bs) : _mr_bs(mr_bs) {} | |
748 bool doHeapRegion(HeapRegion* r) { | |
749 r->reset_gc_time_stamp(); | |
750 if (r->continuesHumongous()) | |
751 return false; | |
752 HeapRegionRemSet* hrrs = r->rem_set(); | |
753 if (hrrs != NULL) hrrs->clear(); | |
754 // You might think here that we could clear just the cards | |
755 // corresponding to the used region. But no: if we leave a dirty card | |
756 // in a region we might allocate into, then it would prevent that card | |
757 // from being enqueued, and cause it to be missed. | |
758 // Re: the performance cost: we shouldn't be doing full GC anyway! | |
759 _mr_bs->clear(MemRegion(r->bottom(), r->end())); | |
760 return false; | |
761 } | |
762 }; | |
763 | |
764 | |
765 class PostMCRemSetInvalidateClosure: public HeapRegionClosure { | |
766 ModRefBarrierSet* _mr_bs; | |
767 public: | |
768 PostMCRemSetInvalidateClosure(ModRefBarrierSet* mr_bs) : _mr_bs(mr_bs) {} | |
769 bool doHeapRegion(HeapRegion* r) { | |
770 if (r->continuesHumongous()) return false; | |
771 if (r->used_region().word_size() != 0) { | |
772 _mr_bs->invalidate(r->used_region(), true /*whole heap*/); | |
773 } | |
774 return false; | |
775 } | |
776 }; | |
777 | |
626
87fa6e083d82
6760309: G1: update remembered sets during Full GCs
apetrusenko
parents:
620
diff
changeset
|
778 class RebuildRSOutOfRegionClosure: public HeapRegionClosure { |
87fa6e083d82
6760309: G1: update remembered sets during Full GCs
apetrusenko
parents:
620
diff
changeset
|
779 G1CollectedHeap* _g1h; |
87fa6e083d82
6760309: G1: update remembered sets during Full GCs
apetrusenko
parents:
620
diff
changeset
|
780 UpdateRSOopClosure _cl; |
87fa6e083d82
6760309: G1: update remembered sets during Full GCs
apetrusenko
parents:
620
diff
changeset
|
781 int _worker_i; |
87fa6e083d82
6760309: G1: update remembered sets during Full GCs
apetrusenko
parents:
620
diff
changeset
|
782 public: |
87fa6e083d82
6760309: G1: update remembered sets during Full GCs
apetrusenko
parents:
620
diff
changeset
|
783 RebuildRSOutOfRegionClosure(G1CollectedHeap* g1, int worker_i = 0) : |
87fa6e083d82
6760309: G1: update remembered sets during Full GCs
apetrusenko
parents:
620
diff
changeset
|
784 _cl(g1->g1_rem_set()->as_HRInto_G1RemSet(), worker_i), |
87fa6e083d82
6760309: G1: update remembered sets during Full GCs
apetrusenko
parents:
620
diff
changeset
|
785 _worker_i(worker_i), |
87fa6e083d82
6760309: G1: update remembered sets during Full GCs
apetrusenko
parents:
620
diff
changeset
|
786 _g1h(g1) |
87fa6e083d82
6760309: G1: update remembered sets during Full GCs
apetrusenko
parents:
620
diff
changeset
|
787 { } |
87fa6e083d82
6760309: G1: update remembered sets during Full GCs
apetrusenko
parents:
620
diff
changeset
|
788 bool doHeapRegion(HeapRegion* r) { |
87fa6e083d82
6760309: G1: update remembered sets during Full GCs
apetrusenko
parents:
620
diff
changeset
|
789 if (!r->continuesHumongous()) { |
87fa6e083d82
6760309: G1: update remembered sets during Full GCs
apetrusenko
parents:
620
diff
changeset
|
790 _cl.set_from(r); |
87fa6e083d82
6760309: G1: update remembered sets during Full GCs
apetrusenko
parents:
620
diff
changeset
|
791 r->oop_iterate(&_cl); |
87fa6e083d82
6760309: G1: update remembered sets during Full GCs
apetrusenko
parents:
620
diff
changeset
|
792 } |
87fa6e083d82
6760309: G1: update remembered sets during Full GCs
apetrusenko
parents:
620
diff
changeset
|
793 return false; |
87fa6e083d82
6760309: G1: update remembered sets during Full GCs
apetrusenko
parents:
620
diff
changeset
|
794 } |
87fa6e083d82
6760309: G1: update remembered sets during Full GCs
apetrusenko
parents:
620
diff
changeset
|
795 }; |
87fa6e083d82
6760309: G1: update remembered sets during Full GCs
apetrusenko
parents:
620
diff
changeset
|
796 |
87fa6e083d82
6760309: G1: update remembered sets during Full GCs
apetrusenko
parents:
620
diff
changeset
|
797 class ParRebuildRSTask: public AbstractGangTask { |
87fa6e083d82
6760309: G1: update remembered sets during Full GCs
apetrusenko
parents:
620
diff
changeset
|
798 G1CollectedHeap* _g1; |
87fa6e083d82
6760309: G1: update remembered sets during Full GCs
apetrusenko
parents:
620
diff
changeset
|
799 public: |
87fa6e083d82
6760309: G1: update remembered sets during Full GCs
apetrusenko
parents:
620
diff
changeset
|
800 ParRebuildRSTask(G1CollectedHeap* g1) |
87fa6e083d82
6760309: G1: update remembered sets during Full GCs
apetrusenko
parents:
620
diff
changeset
|
801 : AbstractGangTask("ParRebuildRSTask"), |
87fa6e083d82
6760309: G1: update remembered sets during Full GCs
apetrusenko
parents:
620
diff
changeset
|
802 _g1(g1) |
87fa6e083d82
6760309: G1: update remembered sets during Full GCs
apetrusenko
parents:
620
diff
changeset
|
803 { } |
87fa6e083d82
6760309: G1: update remembered sets during Full GCs
apetrusenko
parents:
620
diff
changeset
|
804 |
87fa6e083d82
6760309: G1: update remembered sets during Full GCs
apetrusenko
parents:
620
diff
changeset
|
805 void work(int i) { |
87fa6e083d82
6760309: G1: update remembered sets during Full GCs
apetrusenko
parents:
620
diff
changeset
|
806 RebuildRSOutOfRegionClosure rebuild_rs(_g1, i); |
87fa6e083d82
6760309: G1: update remembered sets during Full GCs
apetrusenko
parents:
620
diff
changeset
|
807 _g1->heap_region_par_iterate_chunked(&rebuild_rs, i, |
87fa6e083d82
6760309: G1: update remembered sets during Full GCs
apetrusenko
parents:
620
diff
changeset
|
808 HeapRegion::RebuildRSClaimValue); |
87fa6e083d82
6760309: G1: update remembered sets during Full GCs
apetrusenko
parents:
620
diff
changeset
|
809 } |
87fa6e083d82
6760309: G1: update remembered sets during Full GCs
apetrusenko
parents:
620
diff
changeset
|
810 }; |
87fa6e083d82
6760309: G1: update remembered sets during Full GCs
apetrusenko
parents:
620
diff
changeset
|
811 |
1656
4e5661ba9d98
6944166: G1: explicit GCs are not always handled correctly
tonyp
parents:
1611
diff
changeset
|
812 void G1CollectedHeap::do_collection(bool explicit_gc, |
4e5661ba9d98
6944166: G1: explicit GCs are not always handled correctly
tonyp
parents:
1611
diff
changeset
|
813 bool clear_all_soft_refs, |
342 | 814 size_t word_size) { |
1359
23b1b27ac76c
6909756: G1: guarantee(G1CollectedHeap::heap()->mark_in_progress(),"Precondition.")
tonyp
parents:
1313
diff
changeset
|
815 if (GC_locker::check_active_before_gc()) { |
23b1b27ac76c
6909756: G1: guarantee(G1CollectedHeap::heap()->mark_in_progress(),"Precondition.")
tonyp
parents:
1313
diff
changeset
|
816 return; // GC is disabled (e.g. JNI GetXXXCritical operation) |
23b1b27ac76c
6909756: G1: guarantee(G1CollectedHeap::heap()->mark_in_progress(),"Precondition.")
tonyp
parents:
1313
diff
changeset
|
817 } |
23b1b27ac76c
6909756: G1: guarantee(G1CollectedHeap::heap()->mark_in_progress(),"Precondition.")
tonyp
parents:
1313
diff
changeset
|
818 |
342 | 819 ResourceMark rm; |
820 | |
838
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
821 if (PrintHeapAtGC) { |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
822 Universe::print_heap_before_gc(); |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
823 } |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
824 |
342 | 825 assert(SafepointSynchronize::is_at_safepoint(), "should be at safepoint"); |
826 assert(Thread::current() == VMThread::vm_thread(), "should be in vm thread"); | |
827 | |
1387
0bfd3fb24150
6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents:
1360
diff
changeset
|
828 const bool do_clear_all_soft_refs = clear_all_soft_refs || |
0bfd3fb24150
6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents:
1360
diff
changeset
|
829 collector_policy()->should_clear_all_soft_refs(); |
0bfd3fb24150
6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents:
1360
diff
changeset
|
830 |
0bfd3fb24150
6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents:
1360
diff
changeset
|
831 ClearedAllSoftRefs casr(do_clear_all_soft_refs, collector_policy()); |
0bfd3fb24150
6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents:
1360
diff
changeset
|
832 |
342 | 833 { |
834 IsGCActiveMark x; | |
835 | |
836 // Timing | |
1656
4e5661ba9d98
6944166: G1: explicit GCs are not always handled correctly
tonyp
parents:
1611
diff
changeset
|
837 bool system_gc = (gc_cause() == GCCause::_java_lang_system_gc); |
4e5661ba9d98
6944166: G1: explicit GCs are not always handled correctly
tonyp
parents:
1611
diff
changeset
|
838 assert(!system_gc || explicit_gc, "invariant"); |
342 | 839 gclog_or_tty->date_stamp(PrintGC && PrintGCDateStamps); |
840 TraceCPUTime tcpu(PrintGCDetails, true, gclog_or_tty); | |
1656
4e5661ba9d98
6944166: G1: explicit GCs are not always handled correctly
tonyp
parents:
1611
diff
changeset
|
841 TraceTime t(system_gc ? "Full GC (System.gc())" : "Full GC", |
1387
0bfd3fb24150
6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents:
1360
diff
changeset
|
842 PrintGC, true, gclog_or_tty); |
342 | 843 |
1089
db0d5eba9d20
6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
1088
diff
changeset
|
844 TraceMemoryManagerStats tms(true /* fullGC */); |
db0d5eba9d20
6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
1088
diff
changeset
|
845 |
342 | 846 double start = os::elapsedTime(); |
847 g1_policy()->record_full_collection_start(); | |
848 | |
849 gc_prologue(true); | |
838
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
850 increment_total_collections(true /* full gc */); |
342 | 851 |
852 size_t g1h_prev_used = used(); | |
853 assert(used() == recalculate_used(), "Should be equal"); | |
854 | |
855 if (VerifyBeforeGC && total_collections() >= VerifyGCStartAt) { | |
856 HandleMark hm; // Discard invalid handles created during verification | |
857 prepare_for_verify(); | |
858 gclog_or_tty->print(" VerifyBeforeGC:"); | |
859 Universe::verify(true); | |
860 } | |
861 assert(regions_accounted_for(), "Region leakage!"); | |
862 | |
863 COMPILER2_PRESENT(DerivedPointerTable::clear()); | |
864 | |
865 // We want to discover references, but not process them yet. | |
866 // This mode is disabled in | |
867 // instanceRefKlass::process_discovered_references if the | |
868 // generation does some collection work, or | |
869 // instanceRefKlass::enqueue_discovered_references if the | |
870 // generation returns without doing any work. | |
871 ref_processor()->disable_discovery(); | |
872 ref_processor()->abandon_partial_discovery(); | |
873 ref_processor()->verify_no_references_recorded(); | |
874 | |
875 // Abandon current iterations of concurrent marking and concurrent | |
876 // refinement, if any are in progress. | |
877 concurrent_mark()->abort(); | |
878 | |
879 // Make sure we'll choose a new allocation region afterwards. | |
880 abandon_cur_alloc_region(); | |
636 | 881 abandon_gc_alloc_regions(); |
342 | 882 assert(_cur_alloc_region == NULL, "Invariant."); |
883 g1_rem_set()->as_HRInto_G1RemSet()->cleanupHRRS(); | |
884 tear_down_region_lists(); | |
885 set_used_regions_to_need_zero_fill(); | |
1394
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
886 |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
887 // We may have added regions to the current incremental collection |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
888 // set between the last GC or pause and now. We need to clear the |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
889 // incremental collection set and then start rebuilding it afresh |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
890 // after this full GC. |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
891 abandon_collection_set(g1_policy()->inc_cset_head()); |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
892 g1_policy()->clear_incremental_cset(); |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
893 g1_policy()->stop_incremental_cset_building(); |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
894 |
342 | 895 if (g1_policy()->in_young_gc_mode()) { |
896 empty_young_list(); | |
897 g1_policy()->set_full_young_gcs(true); | |
898 } | |
899 | |
900 // Temporarily make reference _discovery_ single threaded (non-MT). | |
901 ReferenceProcessorMTMutator rp_disc_ser(ref_processor(), false); | |
902 | |
903 // Temporarily make refs discovery atomic | |
904 ReferenceProcessorAtomicMutator rp_disc_atomic(ref_processor(), true); | |
905 | |
906 // Temporarily clear _is_alive_non_header | |
907 ReferenceProcessorIsAliveMutator rp_is_alive_null(ref_processor(), NULL); | |
908 | |
909 ref_processor()->enable_discovery(); | |
1387
0bfd3fb24150
6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents:
1360
diff
changeset
|
910 ref_processor()->setup_policy(do_clear_all_soft_refs); |
342 | 911 |
912 // Do collection work | |
913 { | |
914 HandleMark hm; // Discard invalid handles created during gc | |
1387
0bfd3fb24150
6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents:
1360
diff
changeset
|
915 G1MarkSweep::invoke_at_safepoint(ref_processor(), do_clear_all_soft_refs); |
342 | 916 } |
917 // Because freeing humongous regions may have added some unclean | |
918 // regions, it is necessary to tear down again before rebuilding. | |
919 tear_down_region_lists(); | |
920 rebuild_region_lists(); | |
921 | |
922 _summary_bytes_used = recalculate_used(); | |
923 | |
924 ref_processor()->enqueue_discovered_references(); | |
925 | |
926 COMPILER2_PRESENT(DerivedPointerTable::update_pointers()); | |
927 | |
1089
db0d5eba9d20
6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
1088
diff
changeset
|
928 MemoryService::track_memory_usage(); |
db0d5eba9d20
6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
1088
diff
changeset
|
929 |
342 | 930 if (VerifyAfterGC && total_collections() >= VerifyGCStartAt) { |
931 HandleMark hm; // Discard invalid handles created during verification | |
932 gclog_or_tty->print(" VerifyAfterGC:"); | |
637
25e146966e7c
6817419: G1: Enable extensive verification for humongous regions
iveresov
parents:
636
diff
changeset
|
933 prepare_for_verify(); |
342 | 934 Universe::verify(false); |
935 } | |
936 NOT_PRODUCT(ref_processor()->verify_no_references_recorded()); | |
937 | |
938 reset_gc_time_stamp(); | |
939 // Since everything potentially moved, we will clear all remembered | |
626
87fa6e083d82
6760309: G1: update remembered sets during Full GCs
apetrusenko
parents:
620
diff
changeset
|
940 // sets, and clear all cards. Later we will rebuild remebered |
87fa6e083d82
6760309: G1: update remembered sets during Full GCs
apetrusenko
parents:
620
diff
changeset
|
941 // sets. We will also reset the GC time stamps of the regions. |
342 | 942 PostMCRemSetClearClosure rs_clear(mr_bs()); |
943 heap_region_iterate(&rs_clear); | |
944 | |
945 // Resize the heap if necessary. | |
1656
4e5661ba9d98
6944166: G1: explicit GCs are not always handled correctly
tonyp
parents:
1611
diff
changeset
|
946 resize_if_necessary_after_full_collection(explicit_gc ? 0 : word_size); |
342 | 947 |
948 if (_cg1r->use_cache()) { | |
949 _cg1r->clear_and_record_card_counts(); | |
950 _cg1r->clear_hot_cache(); | |
951 } | |
952 | |
626
87fa6e083d82
6760309: G1: update remembered sets during Full GCs
apetrusenko
parents:
620
diff
changeset
|
953 // Rebuild remembered sets of all regions. |
87fa6e083d82
6760309: G1: update remembered sets during Full GCs
apetrusenko
parents:
620
diff
changeset
|
954 if (ParallelGCThreads > 0) { |
87fa6e083d82
6760309: G1: update remembered sets during Full GCs
apetrusenko
parents:
620
diff
changeset
|
955 ParRebuildRSTask rebuild_rs_task(this); |
87fa6e083d82
6760309: G1: update remembered sets during Full GCs
apetrusenko
parents:
620
diff
changeset
|
956 assert(check_heap_region_claim_values( |
87fa6e083d82
6760309: G1: update remembered sets during Full GCs
apetrusenko
parents:
620
diff
changeset
|
957 HeapRegion::InitialClaimValue), "sanity check"); |
87fa6e083d82
6760309: G1: update remembered sets during Full GCs
apetrusenko
parents:
620
diff
changeset
|
958 set_par_threads(workers()->total_workers()); |
87fa6e083d82
6760309: G1: update remembered sets during Full GCs
apetrusenko
parents:
620
diff
changeset
|
959 workers()->run_task(&rebuild_rs_task); |
87fa6e083d82
6760309: G1: update remembered sets during Full GCs
apetrusenko
parents:
620
diff
changeset
|
960 set_par_threads(0); |
87fa6e083d82
6760309: G1: update remembered sets during Full GCs
apetrusenko
parents:
620
diff
changeset
|
961 assert(check_heap_region_claim_values( |
87fa6e083d82
6760309: G1: update remembered sets during Full GCs
apetrusenko
parents:
620
diff
changeset
|
962 HeapRegion::RebuildRSClaimValue), "sanity check"); |
87fa6e083d82
6760309: G1: update remembered sets during Full GCs
apetrusenko
parents:
620
diff
changeset
|
963 reset_heap_region_claim_values(); |
87fa6e083d82
6760309: G1: update remembered sets during Full GCs
apetrusenko
parents:
620
diff
changeset
|
964 } else { |
87fa6e083d82
6760309: G1: update remembered sets during Full GCs
apetrusenko
parents:
620
diff
changeset
|
965 RebuildRSOutOfRegionClosure rebuild_rs(this); |
87fa6e083d82
6760309: G1: update remembered sets during Full GCs
apetrusenko
parents:
620
diff
changeset
|
966 heap_region_iterate(&rebuild_rs); |
87fa6e083d82
6760309: G1: update remembered sets during Full GCs
apetrusenko
parents:
620
diff
changeset
|
967 } |
87fa6e083d82
6760309: G1: update remembered sets during Full GCs
apetrusenko
parents:
620
diff
changeset
|
968 |
342 | 969 if (PrintGC) { |
970 print_size_transition(gclog_or_tty, g1h_prev_used, used(), capacity()); | |
971 } | |
972 | |
973 if (true) { // FIXME | |
974 // Ask the permanent generation to adjust size for full collections | |
975 perm()->compute_new_size(); | |
976 } | |
977 | |
1394
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
978 // Start a new incremental collection set for the next pause |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
979 assert(g1_policy()->collection_set() == NULL, "must be"); |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
980 g1_policy()->start_incremental_cset_building(); |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
981 |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
982 // Clear the _cset_fast_test bitmap in anticipation of adding |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
983 // regions to the incremental collection set for the next |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
984 // evacuation pause. |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
985 clear_cset_fast_test(); |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
986 |
342 | 987 double end = os::elapsedTime(); |
988 g1_policy()->record_full_collection_end(); | |
989 | |
546
05c6d52fa7a9
6690928: Use spinning in combination with yields for workstealing termination.
jmasa
parents:
545
diff
changeset
|
990 #ifdef TRACESPINNING |
05c6d52fa7a9
6690928: Use spinning in combination with yields for workstealing termination.
jmasa
parents:
545
diff
changeset
|
991 ParallelTaskTerminator::print_termination_counts(); |
05c6d52fa7a9
6690928: Use spinning in combination with yields for workstealing termination.
jmasa
parents:
545
diff
changeset
|
992 #endif |
05c6d52fa7a9
6690928: Use spinning in combination with yields for workstealing termination.
jmasa
parents:
545
diff
changeset
|
993 |
342 | 994 gc_epilogue(true); |
995 | |
794 | 996 // Discard all rset updates |
997 JavaThread::dirty_card_queue_set().abandon_logs(); | |
616
4f360ec815ba
6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents:
595
diff
changeset
|
998 assert(!G1DeferredRSUpdate |
4f360ec815ba
6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents:
595
diff
changeset
|
999 || (G1DeferredRSUpdate && (dirty_card_queue_set().completed_buffers_num() == 0)), "Should not be any"); |
342 | 1000 assert(regions_accounted_for(), "Region leakage!"); |
1001 } | |
1002 | |
1003 if (g1_policy()->in_young_gc_mode()) { | |
1004 _young_list->reset_sampled_info(); | |
1394
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
1005 // At this point there should be no regions in the |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
1006 // entire heap tagged as young. |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
1007 assert( check_young_list_empty(true /* check_heap */), |
342 | 1008 "young list should be empty at this point"); |
1009 } | |
838
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
1010 |
1656
4e5661ba9d98
6944166: G1: explicit GCs are not always handled correctly
tonyp
parents:
1611
diff
changeset
|
1011 // Update the number of full collections that have been completed. |
4e5661ba9d98
6944166: G1: explicit GCs are not always handled correctly
tonyp
parents:
1611
diff
changeset
|
1012 increment_full_collections_completed(false /* outer */); |
4e5661ba9d98
6944166: G1: explicit GCs are not always handled correctly
tonyp
parents:
1611
diff
changeset
|
1013 |
838
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
1014 if (PrintHeapAtGC) { |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
1015 Universe::print_heap_after_gc(); |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
1016 } |
342 | 1017 } |
1018 | |
1019 void G1CollectedHeap::do_full_collection(bool clear_all_soft_refs) { | |
1656
4e5661ba9d98
6944166: G1: explicit GCs are not always handled correctly
tonyp
parents:
1611
diff
changeset
|
1020 do_collection(true, /* explicit_gc */ |
4e5661ba9d98
6944166: G1: explicit GCs are not always handled correctly
tonyp
parents:
1611
diff
changeset
|
1021 clear_all_soft_refs, |
4e5661ba9d98
6944166: G1: explicit GCs are not always handled correctly
tonyp
parents:
1611
diff
changeset
|
1022 0 /* word_size */); |
342 | 1023 } |
1024 | |
1025 // This code is mostly copied from TenuredGeneration. | |
1026 void | |
1027 G1CollectedHeap:: | |
1028 resize_if_necessary_after_full_collection(size_t word_size) { | |
1029 assert(MinHeapFreeRatio <= MaxHeapFreeRatio, "sanity check"); | |
1030 | |
1031 // Include the current allocation, if any, and bytes that will be | |
1032 // pre-allocated to support collections, as "used". | |
1033 const size_t used_after_gc = used(); | |
1034 const size_t capacity_after_gc = capacity(); | |
1035 const size_t free_after_gc = capacity_after_gc - used_after_gc; | |
1036 | |
1037 // We don't have floating point command-line arguments | |
1038 const double minimum_free_percentage = (double) MinHeapFreeRatio / 100; | |
1039 const double maximum_used_percentage = 1.0 - minimum_free_percentage; | |
1040 const double maximum_free_percentage = (double) MaxHeapFreeRatio / 100; | |
1041 const double minimum_used_percentage = 1.0 - maximum_free_percentage; | |
1042 | |
1043 size_t minimum_desired_capacity = (size_t) (used_after_gc / maximum_used_percentage); | |
1044 size_t maximum_desired_capacity = (size_t) (used_after_gc / minimum_used_percentage); | |
1045 | |
1046 // Don't shrink less than the initial size. | |
1047 minimum_desired_capacity = | |
1048 MAX2(minimum_desired_capacity, | |
1049 collector_policy()->initial_heap_byte_size()); | |
1050 maximum_desired_capacity = | |
1051 MAX2(maximum_desired_capacity, | |
1052 collector_policy()->initial_heap_byte_size()); | |
1053 | |
1054 // We are failing here because minimum_desired_capacity is | |
1055 assert(used_after_gc <= minimum_desired_capacity, "sanity check"); | |
1056 assert(minimum_desired_capacity <= maximum_desired_capacity, "sanity check"); | |
1057 | |
1058 if (PrintGC && Verbose) { | |
1059 const double free_percentage = ((double)free_after_gc) / capacity(); | |
1060 gclog_or_tty->print_cr("Computing new size after full GC "); | |
1061 gclog_or_tty->print_cr(" " | |
1062 " minimum_free_percentage: %6.2f", | |
1063 minimum_free_percentage); | |
1064 gclog_or_tty->print_cr(" " | |
1065 " maximum_free_percentage: %6.2f", | |
1066 maximum_free_percentage); | |
1067 gclog_or_tty->print_cr(" " | |
1068 " capacity: %6.1fK" | |
1069 " minimum_desired_capacity: %6.1fK" | |
1070 " maximum_desired_capacity: %6.1fK", | |
1071 capacity() / (double) K, | |
1072 minimum_desired_capacity / (double) K, | |
1073 maximum_desired_capacity / (double) K); | |
1074 gclog_or_tty->print_cr(" " | |
1075 " free_after_gc : %6.1fK" | |
1076 " used_after_gc : %6.1fK", | |
1077 free_after_gc / (double) K, | |
1078 used_after_gc / (double) K); | |
1079 gclog_or_tty->print_cr(" " | |
1080 " free_percentage: %6.2f", | |
1081 free_percentage); | |
1082 } | |
1083 if (capacity() < minimum_desired_capacity) { | |
1084 // Don't expand unless it's significant | |
1085 size_t expand_bytes = minimum_desired_capacity - capacity_after_gc; | |
1086 expand(expand_bytes); | |
1087 if (PrintGC && Verbose) { | |
1088 gclog_or_tty->print_cr(" expanding:" | |
1089 " minimum_desired_capacity: %6.1fK" | |
1090 " expand_bytes: %6.1fK", | |
1091 minimum_desired_capacity / (double) K, | |
1092 expand_bytes / (double) K); | |
1093 } | |
1094 | |
1095 // No expansion, now see if we want to shrink | |
1096 } else if (capacity() > maximum_desired_capacity) { | |
1097 // Capacity too large, compute shrinking size | |
1098 size_t shrink_bytes = capacity_after_gc - maximum_desired_capacity; | |
1099 shrink(shrink_bytes); | |
1100 if (PrintGC && Verbose) { | |
1101 gclog_or_tty->print_cr(" " | |
1102 " shrinking:" | |
1103 " initSize: %.1fK" | |
1104 " maximum_desired_capacity: %.1fK", | |
1105 collector_policy()->initial_heap_byte_size() / (double) K, | |
1106 maximum_desired_capacity / (double) K); | |
1107 gclog_or_tty->print_cr(" " | |
1108 " shrink_bytes: %.1fK", | |
1109 shrink_bytes / (double) K); | |
1110 } | |
1111 } | |
1112 } | |
1113 | |
1114 | |
1115 HeapWord* | |
1116 G1CollectedHeap::satisfy_failed_allocation(size_t word_size) { | |
1117 HeapWord* result = NULL; | |
1118 | |
1119 // In a G1 heap, we're supposed to keep allocation from failing by | |
1120 // incremental pauses. Therefore, at least for now, we'll favor | |
1121 // expansion over collection. (This might change in the future if we can | |
1122 // do something smarter than full collection to satisfy a failed alloc.) | |
1123 | |
1124 result = expand_and_allocate(word_size); | |
1125 if (result != NULL) { | |
1126 assert(is_in(result), "result not in heap"); | |
1127 return result; | |
1128 } | |
1129 | |
1130 // OK, I guess we have to try collection. | |
1131 | |
1132 do_collection(false, false, word_size); | |
1133 | |
1134 result = attempt_allocation(word_size, /*permit_collection_pause*/false); | |
1135 | |
1136 if (result != NULL) { | |
1137 assert(is_in(result), "result not in heap"); | |
1138 return result; | |
1139 } | |
1140 | |
1141 // Try collecting soft references. | |
1142 do_collection(false, true, word_size); | |
1143 result = attempt_allocation(word_size, /*permit_collection_pause*/false); | |
1144 if (result != NULL) { | |
1145 assert(is_in(result), "result not in heap"); | |
1146 return result; | |
1147 } | |
1148 | |
1387
0bfd3fb24150
6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents:
1360
diff
changeset
|
1149 assert(!collector_policy()->should_clear_all_soft_refs(), |
0bfd3fb24150
6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents:
1360
diff
changeset
|
1150 "Flag should have been handled and cleared prior to this point"); |
0bfd3fb24150
6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents:
1360
diff
changeset
|
1151 |
342 | 1152 // What else? We might try synchronous finalization later. If the total |
1153 // space available is large enough for the allocation, then a more | |
1154 // complete compaction phase than we've tried so far might be | |
1155 // appropriate. | |
1156 return NULL; | |
1157 } | |
1158 | |
1159 // Attempting to expand the heap sufficiently | |
1160 // to support an allocation of the given "word_size". If | |
1161 // successful, perform the allocation and return the address of the | |
1162 // allocated block, or else "NULL". | |
1163 | |
1164 HeapWord* G1CollectedHeap::expand_and_allocate(size_t word_size) { | |
1165 size_t expand_bytes = word_size * HeapWordSize; | |
1166 if (expand_bytes < MinHeapDeltaBytes) { | |
1167 expand_bytes = MinHeapDeltaBytes; | |
1168 } | |
1169 expand(expand_bytes); | |
1170 assert(regions_accounted_for(), "Region leakage!"); | |
1171 HeapWord* result = attempt_allocation(word_size, false /* permit_collection_pause */); | |
1172 return result; | |
1173 } | |
1174 | |
1175 size_t G1CollectedHeap::free_region_if_totally_empty(HeapRegion* hr) { | |
1176 size_t pre_used = 0; | |
1177 size_t cleared_h_regions = 0; | |
1178 size_t freed_regions = 0; | |
1179 UncleanRegionList local_list; | |
1180 free_region_if_totally_empty_work(hr, pre_used, cleared_h_regions, | |
1181 freed_regions, &local_list); | |
1182 | |
1183 finish_free_region_work(pre_used, cleared_h_regions, freed_regions, | |
1184 &local_list); | |
1185 return pre_used; | |
1186 } | |
1187 | |
1188 void | |
1189 G1CollectedHeap::free_region_if_totally_empty_work(HeapRegion* hr, | |
1190 size_t& pre_used, | |
1191 size_t& cleared_h, | |
1192 size_t& freed_regions, | |
1193 UncleanRegionList* list, | |
1194 bool par) { | |
1195 assert(!hr->continuesHumongous(), "should have filtered these out"); | |
1196 size_t res = 0; | |
677 | 1197 if (hr->used() > 0 && hr->garbage_bytes() == hr->used() && |
1198 !hr->is_young()) { | |
1199 if (G1PolicyVerbose > 0) | |
1200 gclog_or_tty->print_cr("Freeing empty region "PTR_FORMAT "(" SIZE_FORMAT " bytes)" | |
1201 " during cleanup", hr, hr->used()); | |
1202 free_region_work(hr, pre_used, cleared_h, freed_regions, list, par); | |
342 | 1203 } |
1204 } | |
1205 | |
1206 // FIXME: both this and shrink could probably be more efficient by | |
1207 // doing one "VirtualSpace::expand_by" call rather than several. | |
1208 void G1CollectedHeap::expand(size_t expand_bytes) { | |
1209 size_t old_mem_size = _g1_storage.committed_size(); | |
1210 // We expand by a minimum of 1K. | |
1211 expand_bytes = MAX2(expand_bytes, (size_t)K); | |
1212 size_t aligned_expand_bytes = | |
1213 ReservedSpace::page_align_size_up(expand_bytes); | |
1214 aligned_expand_bytes = align_size_up(aligned_expand_bytes, | |
1215 HeapRegion::GrainBytes); | |
1216 expand_bytes = aligned_expand_bytes; | |
1217 while (expand_bytes > 0) { | |
1218 HeapWord* base = (HeapWord*)_g1_storage.high(); | |
1219 // Commit more storage. | |
1220 bool successful = _g1_storage.expand_by(HeapRegion::GrainBytes); | |
1221 if (!successful) { | |
1222 expand_bytes = 0; | |
1223 } else { | |
1224 expand_bytes -= HeapRegion::GrainBytes; | |
1225 // Expand the committed region. | |
1226 HeapWord* high = (HeapWord*) _g1_storage.high(); | |
1227 _g1_committed.set_end(high); | |
1228 // Create a new HeapRegion. | |
1229 MemRegion mr(base, high); | |
1230 bool is_zeroed = !_g1_max_committed.contains(base); | |
1231 HeapRegion* hr = new HeapRegion(_bot_shared, mr, is_zeroed); | |
1232 | |
1233 // Now update max_committed if necessary. | |
1234 _g1_max_committed.set_end(MAX2(_g1_max_committed.end(), high)); | |
1235 | |
1236 // Add it to the HeapRegionSeq. | |
1237 _hrs->insert(hr); | |
1238 // Set the zero-fill state, according to whether it's already | |
1239 // zeroed. | |
1240 { | |
1241 MutexLockerEx x(ZF_mon, Mutex::_no_safepoint_check_flag); | |
1242 if (is_zeroed) { | |
1243 hr->set_zero_fill_complete(); | |
1244 put_free_region_on_list_locked(hr); | |
1245 } else { | |
1246 hr->set_zero_fill_needed(); | |
1247 put_region_on_unclean_list_locked(hr); | |
1248 } | |
1249 } | |
1250 _free_regions++; | |
1251 // And we used up an expansion region to create it. | |
1252 _expansion_regions--; | |
1253 // Tell the cardtable about it. | |
1254 Universe::heap()->barrier_set()->resize_covered_region(_g1_committed); | |
1255 // And the offset table as well. | |
1256 _bot_shared->resize(_g1_committed.word_size()); | |
1257 } | |
1258 } | |
1259 if (Verbose && PrintGC) { | |
1260 size_t new_mem_size = _g1_storage.committed_size(); | |
1261 gclog_or_tty->print_cr("Expanding garbage-first heap from %ldK by %ldK to %ldK", | |
1262 old_mem_size/K, aligned_expand_bytes/K, | |
1263 new_mem_size/K); | |
1264 } | |
1265 } | |
1266 | |
1267 void G1CollectedHeap::shrink_helper(size_t shrink_bytes) | |
1268 { | |
1269 size_t old_mem_size = _g1_storage.committed_size(); | |
1270 size_t aligned_shrink_bytes = | |
1271 ReservedSpace::page_align_size_down(shrink_bytes); | |
1272 aligned_shrink_bytes = align_size_down(aligned_shrink_bytes, | |
1273 HeapRegion::GrainBytes); | |
1274 size_t num_regions_deleted = 0; | |
1275 MemRegion mr = _hrs->shrink_by(aligned_shrink_bytes, num_regions_deleted); | |
1276 | |
1277 assert(mr.end() == (HeapWord*)_g1_storage.high(), "Bad shrink!"); | |
1278 if (mr.byte_size() > 0) | |
1279 _g1_storage.shrink_by(mr.byte_size()); | |
1280 assert(mr.start() == (HeapWord*)_g1_storage.high(), "Bad shrink!"); | |
1281 | |
1282 _g1_committed.set_end(mr.start()); | |
1283 _free_regions -= num_regions_deleted; | |
1284 _expansion_regions += num_regions_deleted; | |
1285 | |
1286 // Tell the cardtable about it. | |
1287 Universe::heap()->barrier_set()->resize_covered_region(_g1_committed); | |
1288 | |
1289 // And the offset table as well. | |
1290 _bot_shared->resize(_g1_committed.word_size()); | |
1291 | |
1292 HeapRegionRemSet::shrink_heap(n_regions()); | |
1293 | |
1294 if (Verbose && PrintGC) { | |
1295 size_t new_mem_size = _g1_storage.committed_size(); | |
1296 gclog_or_tty->print_cr("Shrinking garbage-first heap from %ldK by %ldK to %ldK", | |
1297 old_mem_size/K, aligned_shrink_bytes/K, | |
1298 new_mem_size/K); | |
1299 } | |
1300 } | |
1301 | |
1302 void G1CollectedHeap::shrink(size_t shrink_bytes) { | |
636 | 1303 release_gc_alloc_regions(true /* totally */); |
342 | 1304 tear_down_region_lists(); // We will rebuild them in a moment. |
1305 shrink_helper(shrink_bytes); | |
1306 rebuild_region_lists(); | |
1307 } | |
1308 | |
1309 // Public methods. | |
1310 | |
1311 #ifdef _MSC_VER // the use of 'this' below gets a warning, make it go away | |
1312 #pragma warning( disable:4355 ) // 'this' : used in base member initializer list | |
1313 #endif // _MSC_VER | |
1314 | |
1315 | |
1316 G1CollectedHeap::G1CollectedHeap(G1CollectorPolicy* policy_) : | |
1317 SharedHeap(policy_), | |
1318 _g1_policy(policy_), | |
1111 | 1319 _dirty_card_queue_set(false), |
342 | 1320 _ref_processor(NULL), |
1321 _process_strong_tasks(new SubTasksDone(G1H_PS_NumElements)), | |
1322 _bot_shared(NULL), | |
1323 _par_alloc_during_gc_lock(Mutex::leaf, "par alloc during GC lock"), | |
1324 _objs_with_preserved_marks(NULL), _preserved_marks_of_objs(NULL), | |
1325 _evac_failure_scan_stack(NULL) , | |
1326 _mark_in_progress(false), | |
1327 _cg1r(NULL), _czft(NULL), _summary_bytes_used(0), | |
1328 _cur_alloc_region(NULL), | |
1329 _refine_cte_cl(NULL), | |
1330 _free_region_list(NULL), _free_region_list_size(0), | |
1331 _free_regions(0), | |
1332 _full_collection(false), | |
1333 _unclean_region_list(), | |
1334 _unclean_regions_coming(false), | |
1335 _young_list(new YoungList(this)), | |
1336 _gc_time_stamp(0), | |
526 | 1337 _surviving_young_words(NULL), |
1656
4e5661ba9d98
6944166: G1: explicit GCs are not always handled correctly
tonyp
parents:
1611
diff
changeset
|
1338 _full_collections_completed(0), |
526 | 1339 _in_cset_fast_test(NULL), |
796
29e7d79232b9
6819065: G1: eliminate high serial card table clearing time
apetrusenko
parents:
794
diff
changeset
|
1340 _in_cset_fast_test_base(NULL), |
29e7d79232b9
6819065: G1: eliminate high serial card table clearing time
apetrusenko
parents:
794
diff
changeset
|
1341 _dirty_cards_region_list(NULL) { |
342 | 1342 _g1h = this; // To catch bugs. |
1343 if (_process_strong_tasks == NULL || !_process_strong_tasks->valid()) { | |
1344 vm_exit_during_initialization("Failed necessary allocation."); | |
1345 } | |
942
2c79770d1f6e
6819085: G1: use larger and/or user settable region size
tonyp
parents:
941
diff
changeset
|
1346 |
2c79770d1f6e
6819085: G1: use larger and/or user settable region size
tonyp
parents:
941
diff
changeset
|
1347 _humongous_object_threshold_in_words = HeapRegion::GrainWords / 2; |
2c79770d1f6e
6819085: G1: use larger and/or user settable region size
tonyp
parents:
941
diff
changeset
|
1348 |
342 | 1349 int n_queues = MAX2((int)ParallelGCThreads, 1); |
1350 _task_queues = new RefToScanQueueSet(n_queues); | |
1351 | |
1352 int n_rem_sets = HeapRegionRemSet::num_par_rem_sets(); | |
1353 assert(n_rem_sets > 0, "Invariant."); | |
1354 | |
1355 HeapRegionRemSetIterator** iter_arr = | |
1356 NEW_C_HEAP_ARRAY(HeapRegionRemSetIterator*, n_queues); | |
1357 for (int i = 0; i < n_queues; i++) { | |
1358 iter_arr[i] = new HeapRegionRemSetIterator(); | |
1359 } | |
1360 _rem_set_iterator = iter_arr; | |
1361 | |
1362 for (int i = 0; i < n_queues; i++) { | |
1363 RefToScanQueue* q = new RefToScanQueue(); | |
1364 q->initialize(); | |
1365 _task_queues->register_queue(i, q); | |
1366 } | |
1367 | |
1368 for (int ap = 0; ap < GCAllocPurposeCount; ++ap) { | |
636 | 1369 _gc_alloc_regions[ap] = NULL; |
1370 _gc_alloc_region_counts[ap] = 0; | |
1371 _retained_gc_alloc_regions[ap] = NULL; | |
1372 // by default, we do not retain a GC alloc region for each ap; | |
1373 // we'll override this, when appropriate, below | |
1374 _retain_gc_alloc_region[ap] = false; | |
1375 } | |
1376 | |
1377 // We will try to remember the last half-full tenured region we | |
1378 // allocated to at the end of a collection so that we can re-use it | |
1379 // during the next collection. | |
1380 _retain_gc_alloc_region[GCAllocForTenured] = true; | |
1381 | |
342 | 1382 guarantee(_task_queues != NULL, "task_queues allocation failure."); |
1383 } | |
1384 | |
1385 jint G1CollectedHeap::initialize() { | |
1166 | 1386 CollectedHeap::pre_initialize(); |
342 | 1387 os::enable_vtime(); |
1388 | |
1389 // Necessary to satisfy locking discipline assertions. | |
1390 | |
1391 MutexLocker x(Heap_lock); | |
1392 | |
1393 // While there are no constraints in the GC code that HeapWordSize | |
1394 // be any particular value, there are multiple other areas in the | |
1395 // system which believe this to be true (e.g. oop->object_size in some | |
1396 // cases incorrectly returns the size in wordSize units rather than | |
1397 // HeapWordSize). | |
1398 guarantee(HeapWordSize == wordSize, "HeapWordSize must equal wordSize"); | |
1399 | |
1400 size_t init_byte_size = collector_policy()->initial_heap_byte_size(); | |
1401 size_t max_byte_size = collector_policy()->max_heap_byte_size(); | |
1402 | |
1403 // Ensure that the sizes are properly aligned. | |
1404 Universe::check_alignment(init_byte_size, HeapRegion::GrainBytes, "g1 heap"); | |
1405 Universe::check_alignment(max_byte_size, HeapRegion::GrainBytes, "g1 heap"); | |
1406 | |
1407 _cg1r = new ConcurrentG1Refine(); | |
1408 | |
1409 // Reserve the maximum. | |
1410 PermanentGenerationSpec* pgs = collector_policy()->permanent_generation(); | |
1411 // Includes the perm-gen. | |
642
660978a2a31a
6791178: Specialize for zero as the compressed oop vm heap base
kvn
parents:
620
diff
changeset
|
1412 |
660978a2a31a
6791178: Specialize for zero as the compressed oop vm heap base
kvn
parents:
620
diff
changeset
|
1413 const size_t total_reserved = max_byte_size + pgs->max_size(); |
660978a2a31a
6791178: Specialize for zero as the compressed oop vm heap base
kvn
parents:
620
diff
changeset
|
1414 char* addr = Universe::preferred_heap_base(total_reserved, Universe::UnscaledNarrowOop); |
660978a2a31a
6791178: Specialize for zero as the compressed oop vm heap base
kvn
parents:
620
diff
changeset
|
1415 |
342 | 1416 ReservedSpace heap_rs(max_byte_size + pgs->max_size(), |
1417 HeapRegion::GrainBytes, | |
642
660978a2a31a
6791178: Specialize for zero as the compressed oop vm heap base
kvn
parents:
620
diff
changeset
|
1418 false /*ism*/, addr); |
660978a2a31a
6791178: Specialize for zero as the compressed oop vm heap base
kvn
parents:
620
diff
changeset
|
1419 |
660978a2a31a
6791178: Specialize for zero as the compressed oop vm heap base
kvn
parents:
620
diff
changeset
|
1420 if (UseCompressedOops) { |
660978a2a31a
6791178: Specialize for zero as the compressed oop vm heap base
kvn
parents:
620
diff
changeset
|
1421 if (addr != NULL && !heap_rs.is_reserved()) { |
660978a2a31a
6791178: Specialize for zero as the compressed oop vm heap base
kvn
parents:
620
diff
changeset
|
1422 // Failed to reserve at specified address - the requested memory |
660978a2a31a
6791178: Specialize for zero as the compressed oop vm heap base
kvn
parents:
620
diff
changeset
|
1423 // region is taken already, for example, by 'java' launcher. |
660978a2a31a
6791178: Specialize for zero as the compressed oop vm heap base
kvn
parents:
620
diff
changeset
|
1424 // Try again to reserver heap higher. |
660978a2a31a
6791178: Specialize for zero as the compressed oop vm heap base
kvn
parents:
620
diff
changeset
|
1425 addr = Universe::preferred_heap_base(total_reserved, Universe::ZeroBasedNarrowOop); |
660978a2a31a
6791178: Specialize for zero as the compressed oop vm heap base
kvn
parents:
620
diff
changeset
|
1426 ReservedSpace heap_rs0(total_reserved, HeapRegion::GrainBytes, |
660978a2a31a
6791178: Specialize for zero as the compressed oop vm heap base
kvn
parents:
620
diff
changeset
|
1427 false /*ism*/, addr); |
660978a2a31a
6791178: Specialize for zero as the compressed oop vm heap base
kvn
parents:
620
diff
changeset
|
1428 if (addr != NULL && !heap_rs0.is_reserved()) { |
660978a2a31a
6791178: Specialize for zero as the compressed oop vm heap base
kvn
parents:
620
diff
changeset
|
1429 // Failed to reserve at specified address again - give up. |
660978a2a31a
6791178: Specialize for zero as the compressed oop vm heap base
kvn
parents:
620
diff
changeset
|
1430 addr = Universe::preferred_heap_base(total_reserved, Universe::HeapBasedNarrowOop); |
660978a2a31a
6791178: Specialize for zero as the compressed oop vm heap base
kvn
parents:
620
diff
changeset
|
1431 assert(addr == NULL, ""); |
660978a2a31a
6791178: Specialize for zero as the compressed oop vm heap base
kvn
parents:
620
diff
changeset
|
1432 ReservedSpace heap_rs1(total_reserved, HeapRegion::GrainBytes, |
660978a2a31a
6791178: Specialize for zero as the compressed oop vm heap base
kvn
parents:
620
diff
changeset
|
1433 false /*ism*/, addr); |
660978a2a31a
6791178: Specialize for zero as the compressed oop vm heap base
kvn
parents:
620
diff
changeset
|
1434 heap_rs = heap_rs1; |
660978a2a31a
6791178: Specialize for zero as the compressed oop vm heap base
kvn
parents:
620
diff
changeset
|
1435 } else { |
660978a2a31a
6791178: Specialize for zero as the compressed oop vm heap base
kvn
parents:
620
diff
changeset
|
1436 heap_rs = heap_rs0; |
660978a2a31a
6791178: Specialize for zero as the compressed oop vm heap base
kvn
parents:
620
diff
changeset
|
1437 } |
660978a2a31a
6791178: Specialize for zero as the compressed oop vm heap base
kvn
parents:
620
diff
changeset
|
1438 } |
660978a2a31a
6791178: Specialize for zero as the compressed oop vm heap base
kvn
parents:
620
diff
changeset
|
1439 } |
342 | 1440 |
1441 if (!heap_rs.is_reserved()) { | |
1442 vm_exit_during_initialization("Could not reserve enough space for object heap"); | |
1443 return JNI_ENOMEM; | |
1444 } | |
1445 | |
1446 // It is important to do this in a way such that concurrent readers can't | |
1447 // temporarily think somethings in the heap. (I've actually seen this | |
1448 // happen in asserts: DLD.) | |
1449 _reserved.set_word_size(0); | |
1450 _reserved.set_start((HeapWord*)heap_rs.base()); | |
1451 _reserved.set_end((HeapWord*)(heap_rs.base() + heap_rs.size())); | |
1452 | |
1453 _expansion_regions = max_byte_size/HeapRegion::GrainBytes; | |
1454 | |
1455 _num_humongous_regions = 0; | |
1456 | |
1457 // Create the gen rem set (and barrier set) for the entire reserved region. | |
1458 _rem_set = collector_policy()->create_rem_set(_reserved, 2); | |
1459 set_barrier_set(rem_set()->bs()); | |
1460 if (barrier_set()->is_a(BarrierSet::ModRef)) { | |
1461 _mr_bs = (ModRefBarrierSet*)_barrier_set; | |
1462 } else { | |
1463 vm_exit_during_initialization("G1 requires a mod ref bs."); | |
1464 return JNI_ENOMEM; | |
1465 } | |
1466 | |
1467 // Also create a G1 rem set. | |
1468 if (G1UseHRIntoRS) { | |
1469 if (mr_bs()->is_a(BarrierSet::CardTableModRef)) { | |
1470 _g1_rem_set = new HRInto_G1RemSet(this, (CardTableModRefBS*)mr_bs()); | |
1471 } else { | |
1472 vm_exit_during_initialization("G1 requires a cardtable mod ref bs."); | |
1473 return JNI_ENOMEM; | |
1474 } | |
1475 } else { | |
1476 _g1_rem_set = new StupidG1RemSet(this); | |
1477 } | |
1478 | |
1479 // Carve out the G1 part of the heap. | |
1480 | |
1481 ReservedSpace g1_rs = heap_rs.first_part(max_byte_size); | |
1482 _g1_reserved = MemRegion((HeapWord*)g1_rs.base(), | |
1483 g1_rs.size()/HeapWordSize); | |
1484 ReservedSpace perm_gen_rs = heap_rs.last_part(max_byte_size); | |
1485 | |
1486 _perm_gen = pgs->init(perm_gen_rs, pgs->init_size(), rem_set()); | |
1487 | |
1488 _g1_storage.initialize(g1_rs, 0); | |
1489 _g1_committed = MemRegion((HeapWord*)_g1_storage.low(), (size_t) 0); | |
1490 _g1_max_committed = _g1_committed; | |
393 | 1491 _hrs = new HeapRegionSeq(_expansion_regions); |
342 | 1492 guarantee(_hrs != NULL, "Couldn't allocate HeapRegionSeq"); |
1493 guarantee(_cur_alloc_region == NULL, "from constructor"); | |
1494 | |
807
d44bdab1c03d
6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents:
796
diff
changeset
|
1495 // 6843694 - ensure that the maximum region index can fit |
d44bdab1c03d
6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents:
796
diff
changeset
|
1496 // in the remembered set structures. |
d44bdab1c03d
6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents:
796
diff
changeset
|
1497 const size_t max_region_idx = ((size_t)1 << (sizeof(RegionIdx_t)*BitsPerByte-1)) - 1; |
d44bdab1c03d
6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents:
796
diff
changeset
|
1498 guarantee((max_regions() - 1) <= max_region_idx, "too many regions"); |
d44bdab1c03d
6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents:
796
diff
changeset
|
1499 |
d44bdab1c03d
6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents:
796
diff
changeset
|
1500 size_t max_cards_per_region = ((size_t)1 << (sizeof(CardIdx_t)*BitsPerByte-1)) - 1; |
942
2c79770d1f6e
6819085: G1: use larger and/or user settable region size
tonyp
parents:
941
diff
changeset
|
1501 guarantee(HeapRegion::CardsPerRegion > 0, "make sure it's initialized"); |
2c79770d1f6e
6819085: G1: use larger and/or user settable region size
tonyp
parents:
941
diff
changeset
|
1502 guarantee((size_t) HeapRegion::CardsPerRegion < max_cards_per_region, |
2c79770d1f6e
6819085: G1: use larger and/or user settable region size
tonyp
parents:
941
diff
changeset
|
1503 "too many cards per region"); |
807
d44bdab1c03d
6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents:
796
diff
changeset
|
1504 |
342 | 1505 _bot_shared = new G1BlockOffsetSharedArray(_reserved, |
1506 heap_word_size(init_byte_size)); | |
1507 | |
1508 _g1h = this; | |
1509 | |
1394
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
1510 _in_cset_fast_test_length = max_regions(); |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
1511 _in_cset_fast_test_base = NEW_C_HEAP_ARRAY(bool, _in_cset_fast_test_length); |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
1512 |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
1513 // We're biasing _in_cset_fast_test to avoid subtracting the |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
1514 // beginning of the heap every time we want to index; basically |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
1515 // it's the same with what we do with the card table. |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
1516 _in_cset_fast_test = _in_cset_fast_test_base - |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
1517 ((size_t) _g1_reserved.start() >> HeapRegion::LogOfHRGrainBytes); |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
1518 |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
1519 // Clear the _cset_fast_test bitmap in anticipation of adding |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
1520 // regions to the incremental collection set for the first |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
1521 // evacuation pause. |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
1522 clear_cset_fast_test(); |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
1523 |
342 | 1524 // Create the ConcurrentMark data structure and thread. |
1525 // (Must do this late, so that "max_regions" is defined.) | |
1526 _cm = new ConcurrentMark(heap_rs, (int) max_regions()); | |
1527 _cmThread = _cm->cmThread(); | |
1528 | |
1529 // ...and the concurrent zero-fill thread, if necessary. | |
1530 if (G1ConcZeroFill) { | |
1531 _czft = new ConcurrentZFThread(); | |
1532 } | |
1533 | |
1534 // Initialize the from_card cache structure of HeapRegionRemSet. | |
1535 HeapRegionRemSet::init_heap(max_regions()); | |
1536 | |
677 | 1537 // Now expand into the initial heap size. |
1538 expand(init_byte_size); | |
342 | 1539 |
1540 // Perform any initialization actions delegated to the policy. | |
1541 g1_policy()->init(); | |
1542 | |
1543 g1_policy()->note_start_of_mark_thread(); | |
1544 | |
1545 _refine_cte_cl = | |
1546 new RefineCardTableEntryClosure(ConcurrentG1RefineThread::sts(), | |
1547 g1_rem_set(), | |
1548 concurrent_g1_refine()); | |
1549 JavaThread::dirty_card_queue_set().set_closure(_refine_cte_cl); | |
1550 | |
1551 JavaThread::satb_mark_queue_set().initialize(SATB_Q_CBL_mon, | |
1552 SATB_Q_FL_lock, | |
1111 | 1553 G1SATBProcessCompletedThreshold, |
342 | 1554 Shared_SATB_Q_lock); |
794 | 1555 |
1556 JavaThread::dirty_card_queue_set().initialize(DirtyCardQ_CBL_mon, | |
1557 DirtyCardQ_FL_lock, | |
1111 | 1558 concurrent_g1_refine()->yellow_zone(), |
1559 concurrent_g1_refine()->red_zone(), | |
794 | 1560 Shared_DirtyCardQ_lock); |
1561 | |
616
4f360ec815ba
6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents:
595
diff
changeset
|
1562 if (G1DeferredRSUpdate) { |
4f360ec815ba
6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents:
595
diff
changeset
|
1563 dirty_card_queue_set().initialize(DirtyCardQ_CBL_mon, |
4f360ec815ba
6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents:
595
diff
changeset
|
1564 DirtyCardQ_FL_lock, |
1111 | 1565 -1, // never trigger processing |
1566 -1, // no limit on length | |
616
4f360ec815ba
6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents:
595
diff
changeset
|
1567 Shared_DirtyCardQ_lock, |
4f360ec815ba
6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents:
595
diff
changeset
|
1568 &JavaThread::dirty_card_queue_set()); |
4f360ec815ba
6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents:
595
diff
changeset
|
1569 } |
342 | 1570 // In case we're keeping closure specialization stats, initialize those |
1571 // counts and that mechanism. | |
1572 SpecializationStats::clear(); | |
1573 | |
1574 _gc_alloc_region_list = NULL; | |
1575 | |
1576 // Do later initialization work for concurrent refinement. | |
1577 _cg1r->init(); | |
1578 | |
1579 return JNI_OK; | |
1580 } | |
1581 | |
1582 void G1CollectedHeap::ref_processing_init() { | |
1583 SharedHeap::ref_processing_init(); | |
1584 MemRegion mr = reserved_region(); | |
1585 _ref_processor = ReferenceProcessor::create_ref_processor( | |
1586 mr, // span | |
1587 false, // Reference discovery is not atomic | |
1588 // (though it shouldn't matter here.) | |
1589 true, // mt_discovery | |
1590 NULL, // is alive closure: need to fill this in for efficiency | |
1591 ParallelGCThreads, | |
1592 ParallelRefProcEnabled, | |
1593 true); // Setting next fields of discovered | |
1594 // lists requires a barrier. | |
1595 } | |
1596 | |
1597 size_t G1CollectedHeap::capacity() const { | |
1598 return _g1_committed.byte_size(); | |
1599 } | |
1600 | |
1601 void G1CollectedHeap::iterate_dirty_card_closure(bool concurrent, | |
1602 int worker_i) { | |
889 | 1603 // Clean cards in the hot card cache |
1604 concurrent_g1_refine()->clean_up_cache(worker_i, g1_rem_set()); | |
1605 | |
342 | 1606 DirtyCardQueueSet& dcqs = JavaThread::dirty_card_queue_set(); |
1607 int n_completed_buffers = 0; | |
1608 while (dcqs.apply_closure_to_completed_buffer(worker_i, 0, true)) { | |
1609 n_completed_buffers++; | |
1610 } | |
1611 g1_policy()->record_update_rs_processed_buffers(worker_i, | |
1612 (double) n_completed_buffers); | |
1613 dcqs.clear_n_completed_buffers(); | |
1614 assert(!dcqs.completed_buffers_exist_dirty(), "Completed buffers exist!"); | |
1615 } | |
1616 | |
1617 | |
1618 // Computes the sum of the storage used by the various regions. | |
1619 | |
1620 size_t G1CollectedHeap::used() const { | |
862
36b5611220a7
6863216: Clean up debugging debris inadvertently pushed with 6700789
ysr
parents:
861
diff
changeset
|
1621 assert(Heap_lock->owner() != NULL, |
36b5611220a7
6863216: Clean up debugging debris inadvertently pushed with 6700789
ysr
parents:
861
diff
changeset
|
1622 "Should be owned on this thread's behalf."); |
342 | 1623 size_t result = _summary_bytes_used; |
845
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
1624 // Read only once in case it is set to NULL concurrently |
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
1625 HeapRegion* hr = _cur_alloc_region; |
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
1626 if (hr != NULL) |
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
1627 result += hr->used(); |
342 | 1628 return result; |
1629 } | |
1630 | |
846
42d84bbbecf4
6859911: G1: assert(Heap_lock->owner() = NULL, "Should be owned on this thread's behalf")
tonyp
parents:
845
diff
changeset
|
1631 size_t G1CollectedHeap::used_unlocked() const { |
42d84bbbecf4
6859911: G1: assert(Heap_lock->owner() = NULL, "Should be owned on this thread's behalf")
tonyp
parents:
845
diff
changeset
|
1632 size_t result = _summary_bytes_used; |
42d84bbbecf4
6859911: G1: assert(Heap_lock->owner() = NULL, "Should be owned on this thread's behalf")
tonyp
parents:
845
diff
changeset
|
1633 return result; |
42d84bbbecf4
6859911: G1: assert(Heap_lock->owner() = NULL, "Should be owned on this thread's behalf")
tonyp
parents:
845
diff
changeset
|
1634 } |
42d84bbbecf4
6859911: G1: assert(Heap_lock->owner() = NULL, "Should be owned on this thread's behalf")
tonyp
parents:
845
diff
changeset
|
1635 |
342 | 1636 class SumUsedClosure: public HeapRegionClosure { |
1637 size_t _used; | |
1638 public: | |
1639 SumUsedClosure() : _used(0) {} | |
1640 bool doHeapRegion(HeapRegion* r) { | |
1641 if (!r->continuesHumongous()) { | |
1642 _used += r->used(); | |
1643 } | |
1644 return false; | |
1645 } | |
1646 size_t result() { return _used; } | |
1647 }; | |
1648 | |
1649 size_t G1CollectedHeap::recalculate_used() const { | |
1650 SumUsedClosure blk; | |
1651 _hrs->iterate(&blk); | |
1652 return blk.result(); | |
1653 } | |
1654 | |
1655 #ifndef PRODUCT | |
1656 class SumUsedRegionsClosure: public HeapRegionClosure { | |
1657 size_t _num; | |
1658 public: | |
677 | 1659 SumUsedRegionsClosure() : _num(0) {} |
342 | 1660 bool doHeapRegion(HeapRegion* r) { |
1661 if (r->continuesHumongous() || r->used() > 0 || r->is_gc_alloc_region()) { | |
1662 _num += 1; | |
1663 } | |
1664 return false; | |
1665 } | |
1666 size_t result() { return _num; } | |
1667 }; | |
1668 | |
1669 size_t G1CollectedHeap::recalculate_used_regions() const { | |
1670 SumUsedRegionsClosure blk; | |
1671 _hrs->iterate(&blk); | |
1672 return blk.result(); | |
1673 } | |
1674 #endif // PRODUCT | |
1675 | |
1676 size_t G1CollectedHeap::unsafe_max_alloc() { | |
1677 if (_free_regions > 0) return HeapRegion::GrainBytes; | |
1678 // otherwise, is there space in the current allocation region? | |
1679 | |
1680 // We need to store the current allocation region in a local variable | |
1681 // here. The problem is that this method doesn't take any locks and | |
1682 // there may be other threads which overwrite the current allocation | |
1683 // region field. attempt_allocation(), for example, sets it to NULL | |
1684 // and this can happen *after* the NULL check here but before the call | |
1685 // to free(), resulting in a SIGSEGV. Note that this doesn't appear | |
1686 // to be a problem in the optimized build, since the two loads of the | |
1687 // current allocation region field are optimized away. | |
1688 HeapRegion* car = _cur_alloc_region; | |
1689 | |
1690 // FIXME: should iterate over all regions? | |
1691 if (car == NULL) { | |
1692 return 0; | |
1693 } | |
1694 return car->free(); | |
1695 } | |
1696 | |
1656
4e5661ba9d98
6944166: G1: explicit GCs are not always handled correctly
tonyp
parents:
1611
diff
changeset
|
1697 bool G1CollectedHeap::should_do_concurrent_full_gc(GCCause::Cause cause) { |
4e5661ba9d98
6944166: G1: explicit GCs are not always handled correctly
tonyp
parents:
1611
diff
changeset
|
1698 return |
4e5661ba9d98
6944166: G1: explicit GCs are not always handled correctly
tonyp
parents:
1611
diff
changeset
|
1699 ((cause == GCCause::_gc_locker && GCLockerInvokesConcurrent) || |
4e5661ba9d98
6944166: G1: explicit GCs are not always handled correctly
tonyp
parents:
1611
diff
changeset
|
1700 (cause == GCCause::_java_lang_system_gc && ExplicitGCInvokesConcurrent)); |
4e5661ba9d98
6944166: G1: explicit GCs are not always handled correctly
tonyp
parents:
1611
diff
changeset
|
1701 } |
4e5661ba9d98
6944166: G1: explicit GCs are not always handled correctly
tonyp
parents:
1611
diff
changeset
|
1702 |
4e5661ba9d98
6944166: G1: explicit GCs are not always handled correctly
tonyp
parents:
1611
diff
changeset
|
1703 void G1CollectedHeap::increment_full_collections_completed(bool outer) { |
4e5661ba9d98
6944166: G1: explicit GCs are not always handled correctly
tonyp
parents:
1611
diff
changeset
|
1704 MonitorLockerEx x(FullGCCount_lock, Mutex::_no_safepoint_check_flag); |
4e5661ba9d98
6944166: G1: explicit GCs are not always handled correctly
tonyp
parents:
1611
diff
changeset
|
1705 |
4e5661ba9d98
6944166: G1: explicit GCs are not always handled correctly
tonyp
parents:
1611
diff
changeset
|
1706 // We have already incremented _total_full_collections at the start |
4e5661ba9d98
6944166: G1: explicit GCs are not always handled correctly
tonyp
parents:
1611
diff
changeset
|
1707 // of the GC, so total_full_collections() represents how many full |
4e5661ba9d98
6944166: G1: explicit GCs are not always handled correctly
tonyp
parents:
1611
diff
changeset
|
1708 // collections have been started. |
4e5661ba9d98
6944166: G1: explicit GCs are not always handled correctly
tonyp
parents:
1611
diff
changeset
|
1709 unsigned int full_collections_started = total_full_collections(); |
4e5661ba9d98
6944166: G1: explicit GCs are not always handled correctly
tonyp
parents:
1611
diff
changeset
|
1710 |
4e5661ba9d98
6944166: G1: explicit GCs are not always handled correctly
tonyp
parents:
1611
diff
changeset
|
1711 // Given that this method is called at the end of a Full GC or of a |
4e5661ba9d98
6944166: G1: explicit GCs are not always handled correctly
tonyp
parents:
1611
diff
changeset
|
1712 // concurrent cycle, and those can be nested (i.e., a Full GC can |
4e5661ba9d98
6944166: G1: explicit GCs are not always handled correctly
tonyp
parents:
1611
diff
changeset
|
1713 // interrupt a concurrent cycle), the number of full collections |
4e5661ba9d98
6944166: G1: explicit GCs are not always handled correctly
tonyp
parents:
1611
diff
changeset
|
1714 // completed should be either one (in the case where there was no |
4e5661ba9d98
6944166: G1: explicit GCs are not always handled correctly
tonyp
parents:
1611
diff
changeset
|
1715 // nesting) or two (when a Full GC interrupted a concurrent cycle) |
4e5661ba9d98
6944166: G1: explicit GCs are not always handled correctly
tonyp
parents:
1611
diff
changeset
|
1716 // behind the number of full collections started. |
4e5661ba9d98
6944166: G1: explicit GCs are not always handled correctly
tonyp
parents:
1611
diff
changeset
|
1717 |
4e5661ba9d98
6944166: G1: explicit GCs are not always handled correctly
tonyp
parents:
1611
diff
changeset
|
1718 // This is the case for the inner caller, i.e. a Full GC. |
4e5661ba9d98
6944166: G1: explicit GCs are not always handled correctly
tonyp
parents:
1611
diff
changeset
|
1719 assert(outer || |
4e5661ba9d98
6944166: G1: explicit GCs are not always handled correctly
tonyp
parents:
1611
diff
changeset
|
1720 (full_collections_started == _full_collections_completed + 1) || |
4e5661ba9d98
6944166: G1: explicit GCs are not always handled correctly
tonyp
parents:
1611
diff
changeset
|
1721 (full_collections_started == _full_collections_completed + 2), |
4e5661ba9d98
6944166: G1: explicit GCs are not always handled correctly
tonyp
parents:
1611
diff
changeset
|
1722 err_msg("for inner caller: full_collections_started = %u " |
4e5661ba9d98
6944166: G1: explicit GCs are not always handled correctly
tonyp
parents:
1611
diff
changeset
|
1723 "is inconsistent with _full_collections_completed = %u", |
4e5661ba9d98
6944166: G1: explicit GCs are not always handled correctly
tonyp
parents:
1611
diff
changeset
|
1724 full_collections_started, _full_collections_completed)); |
4e5661ba9d98
6944166: G1: explicit GCs are not always handled correctly
tonyp
parents:
1611
diff
changeset
|
1725 |
4e5661ba9d98
6944166: G1: explicit GCs are not always handled correctly
tonyp
parents:
1611
diff
changeset
|
1726 // This is the case for the outer caller, i.e. the concurrent cycle. |
4e5661ba9d98
6944166: G1: explicit GCs are not always handled correctly
tonyp
parents:
1611
diff
changeset
|
1727 assert(!outer || |
4e5661ba9d98
6944166: G1: explicit GCs are not always handled correctly
tonyp
parents:
1611
diff
changeset
|
1728 (full_collections_started == _full_collections_completed + 1), |
4e5661ba9d98
6944166: G1: explicit GCs are not always handled correctly
tonyp
parents:
1611
diff
changeset
|
1729 err_msg("for outer caller: full_collections_started = %u " |
4e5661ba9d98
6944166: G1: explicit GCs are not always handled correctly
tonyp
parents:
1611
diff
changeset
|
1730 "is inconsistent with _full_collections_completed = %u", |
4e5661ba9d98
6944166: G1: explicit GCs are not always handled correctly
tonyp
parents:
1611
diff
changeset
|
1731 full_collections_started, _full_collections_completed)); |
4e5661ba9d98
6944166: G1: explicit GCs are not always handled correctly
tonyp
parents:
1611
diff
changeset
|
1732 |
4e5661ba9d98
6944166: G1: explicit GCs are not always handled correctly
tonyp
parents:
1611
diff
changeset
|
1733 _full_collections_completed += 1; |
4e5661ba9d98
6944166: G1: explicit GCs are not always handled correctly
tonyp
parents:
1611
diff
changeset
|
1734 |
4e5661ba9d98
6944166: G1: explicit GCs are not always handled correctly
tonyp
parents:
1611
diff
changeset
|
1735 // This notify_all() will ensure that a thread that called |
4e5661ba9d98
6944166: G1: explicit GCs are not always handled correctly
tonyp
parents:
1611
diff
changeset
|
1736 // System.gc() with (with ExplicitGCInvokesConcurrent set or not) |
4e5661ba9d98
6944166: G1: explicit GCs are not always handled correctly
tonyp
parents:
1611
diff
changeset
|
1737 // and it's waiting for a full GC to finish will be woken up. It is |
4e5661ba9d98
6944166: G1: explicit GCs are not always handled correctly
tonyp
parents:
1611
diff
changeset
|
1738 // waiting in VM_G1IncCollectionPause::doit_epilogue(). |
4e5661ba9d98
6944166: G1: explicit GCs are not always handled correctly
tonyp
parents:
1611
diff
changeset
|
1739 FullGCCount_lock->notify_all(); |
4e5661ba9d98
6944166: G1: explicit GCs are not always handled correctly
tonyp
parents:
1611
diff
changeset
|
1740 } |
4e5661ba9d98
6944166: G1: explicit GCs are not always handled correctly
tonyp
parents:
1611
diff
changeset
|
1741 |
342 | 1742 void G1CollectedHeap::collect_as_vm_thread(GCCause::Cause cause) { |
1743 assert(Thread::current()->is_VM_thread(), "Precondition#1"); | |
1744 assert(Heap_lock->is_locked(), "Precondition#2"); | |
1745 GCCauseSetter gcs(this, cause); | |
1746 switch (cause) { | |
1747 case GCCause::_heap_inspection: | |
1748 case GCCause::_heap_dump: { | |
1749 HandleMark hm; | |
1750 do_full_collection(false); // don't clear all soft refs | |
1751 break; | |
1752 } | |
1753 default: // XXX FIX ME | |
1754 ShouldNotReachHere(); // Unexpected use of this function | |
1755 } | |
1756 } | |
1757 | |
1088
3fc996d4edd2
6902303: G1: ScavengeALot should cause an incremental, rather than a full, collection
ysr
parents:
1045
diff
changeset
|
1758 void G1CollectedHeap::collect(GCCause::Cause cause) { |
3fc996d4edd2
6902303: G1: ScavengeALot should cause an incremental, rather than a full, collection
ysr
parents:
1045
diff
changeset
|
1759 // The caller doesn't have the Heap_lock |
3fc996d4edd2
6902303: G1: ScavengeALot should cause an incremental, rather than a full, collection
ysr
parents:
1045
diff
changeset
|
1760 assert(!Heap_lock->owned_by_self(), "this thread should not own the Heap_lock"); |
3fc996d4edd2
6902303: G1: ScavengeALot should cause an incremental, rather than a full, collection
ysr
parents:
1045
diff
changeset
|
1761 |
1656
4e5661ba9d98
6944166: G1: explicit GCs are not always handled correctly
tonyp
parents:
1611
diff
changeset
|
1762 unsigned int gc_count_before; |
4e5661ba9d98
6944166: G1: explicit GCs are not always handled correctly
tonyp
parents:
1611
diff
changeset
|
1763 unsigned int full_gc_count_before; |
342 | 1764 { |
1088
3fc996d4edd2
6902303: G1: ScavengeALot should cause an incremental, rather than a full, collection
ysr
parents:
1045
diff
changeset
|
1765 MutexLocker ml(Heap_lock); |
3fc996d4edd2
6902303: G1: ScavengeALot should cause an incremental, rather than a full, collection
ysr
parents:
1045
diff
changeset
|
1766 // Read the GC count while holding the Heap_lock |
3fc996d4edd2
6902303: G1: ScavengeALot should cause an incremental, rather than a full, collection
ysr
parents:
1045
diff
changeset
|
1767 gc_count_before = SharedHeap::heap()->total_collections(); |
1656
4e5661ba9d98
6944166: G1: explicit GCs are not always handled correctly
tonyp
parents:
1611
diff
changeset
|
1768 full_gc_count_before = SharedHeap::heap()->total_full_collections(); |
1088
3fc996d4edd2
6902303: G1: ScavengeALot should cause an incremental, rather than a full, collection
ysr
parents:
1045
diff
changeset
|
1769 |
3fc996d4edd2
6902303: G1: ScavengeALot should cause an incremental, rather than a full, collection
ysr
parents:
1045
diff
changeset
|
1770 // Don't want to do a GC until cleanup is completed. |
3fc996d4edd2
6902303: G1: ScavengeALot should cause an incremental, rather than a full, collection
ysr
parents:
1045
diff
changeset
|
1771 wait_for_cleanup_complete(); |
1656
4e5661ba9d98
6944166: G1: explicit GCs are not always handled correctly
tonyp
parents:
1611
diff
changeset
|
1772 |
4e5661ba9d98
6944166: G1: explicit GCs are not always handled correctly
tonyp
parents:
1611
diff
changeset
|
1773 // We give up heap lock; VMThread::execute gets it back below |
4e5661ba9d98
6944166: G1: explicit GCs are not always handled correctly
tonyp
parents:
1611
diff
changeset
|
1774 } |
4e5661ba9d98
6944166: G1: explicit GCs are not always handled correctly
tonyp
parents:
1611
diff
changeset
|
1775 |
4e5661ba9d98
6944166: G1: explicit GCs are not always handled correctly
tonyp
parents:
1611
diff
changeset
|
1776 if (should_do_concurrent_full_gc(cause)) { |
4e5661ba9d98
6944166: G1: explicit GCs are not always handled correctly
tonyp
parents:
1611
diff
changeset
|
1777 // Schedule an initial-mark evacuation pause that will start a |
4e5661ba9d98
6944166: G1: explicit GCs are not always handled correctly
tonyp
parents:
1611
diff
changeset
|
1778 // concurrent cycle. |
4e5661ba9d98
6944166: G1: explicit GCs are not always handled correctly
tonyp
parents:
1611
diff
changeset
|
1779 VM_G1IncCollectionPause op(gc_count_before, |
4e5661ba9d98
6944166: G1: explicit GCs are not always handled correctly
tonyp
parents:
1611
diff
changeset
|
1780 true, /* should_initiate_conc_mark */ |
4e5661ba9d98
6944166: G1: explicit GCs are not always handled correctly
tonyp
parents:
1611
diff
changeset
|
1781 g1_policy()->max_pause_time_ms(), |
4e5661ba9d98
6944166: G1: explicit GCs are not always handled correctly
tonyp
parents:
1611
diff
changeset
|
1782 cause); |
4e5661ba9d98
6944166: G1: explicit GCs are not always handled correctly
tonyp
parents:
1611
diff
changeset
|
1783 VMThread::execute(&op); |
4e5661ba9d98
6944166: G1: explicit GCs are not always handled correctly
tonyp
parents:
1611
diff
changeset
|
1784 } else { |
4e5661ba9d98
6944166: G1: explicit GCs are not always handled correctly
tonyp
parents:
1611
diff
changeset
|
1785 if (cause == GCCause::_gc_locker |
4e5661ba9d98
6944166: G1: explicit GCs are not always handled correctly
tonyp
parents:
1611
diff
changeset
|
1786 DEBUG_ONLY(|| cause == GCCause::_scavenge_alot)) { |
4e5661ba9d98
6944166: G1: explicit GCs are not always handled correctly
tonyp
parents:
1611
diff
changeset
|
1787 |
4e5661ba9d98
6944166: G1: explicit GCs are not always handled correctly
tonyp
parents:
1611
diff
changeset
|
1788 // Schedule a standard evacuation pause. |
4e5661ba9d98
6944166: G1: explicit GCs are not always handled correctly
tonyp
parents:
1611
diff
changeset
|
1789 VM_G1IncCollectionPause op(gc_count_before, |
4e5661ba9d98
6944166: G1: explicit GCs are not always handled correctly
tonyp
parents:
1611
diff
changeset
|
1790 false, /* should_initiate_conc_mark */ |
4e5661ba9d98
6944166: G1: explicit GCs are not always handled correctly
tonyp
parents:
1611
diff
changeset
|
1791 g1_policy()->max_pause_time_ms(), |
4e5661ba9d98
6944166: G1: explicit GCs are not always handled correctly
tonyp
parents:
1611
diff
changeset
|
1792 cause); |
1088
3fc996d4edd2
6902303: G1: ScavengeALot should cause an incremental, rather than a full, collection
ysr
parents:
1045
diff
changeset
|
1793 VMThread::execute(&op); |
1656
4e5661ba9d98
6944166: G1: explicit GCs are not always handled correctly
tonyp
parents:
1611
diff
changeset
|
1794 } else { |
4e5661ba9d98
6944166: G1: explicit GCs are not always handled correctly
tonyp
parents:
1611
diff
changeset
|
1795 // Schedule a Full GC. |
4e5661ba9d98
6944166: G1: explicit GCs are not always handled correctly
tonyp
parents:
1611
diff
changeset
|
1796 VM_G1CollectFull op(gc_count_before, full_gc_count_before, cause); |
1088
3fc996d4edd2
6902303: G1: ScavengeALot should cause an incremental, rather than a full, collection
ysr
parents:
1045
diff
changeset
|
1797 VMThread::execute(&op); |
3fc996d4edd2
6902303: G1: ScavengeALot should cause an incremental, rather than a full, collection
ysr
parents:
1045
diff
changeset
|
1798 } |
342 | 1799 } |
1800 } | |
1801 | |
1802 bool G1CollectedHeap::is_in(const void* p) const { | |
1803 if (_g1_committed.contains(p)) { | |
1804 HeapRegion* hr = _hrs->addr_to_region(p); | |
1805 return hr->is_in(p); | |
1806 } else { | |
1807 return _perm_gen->as_gen()->is_in(p); | |
1808 } | |
1809 } | |
1810 | |
1811 // Iteration functions. | |
1812 | |
1813 // Iterates an OopClosure over all ref-containing fields of objects | |
1814 // within a HeapRegion. | |
1815 | |
1816 class IterateOopClosureRegionClosure: public HeapRegionClosure { | |
1817 MemRegion _mr; | |
1818 OopClosure* _cl; | |
1819 public: | |
1820 IterateOopClosureRegionClosure(MemRegion mr, OopClosure* cl) | |
1821 : _mr(mr), _cl(cl) {} | |
1822 bool doHeapRegion(HeapRegion* r) { | |
1823 if (! r->continuesHumongous()) { | |
1824 r->oop_iterate(_cl); | |
1825 } | |
1826 return false; | |
1827 } | |
1828 }; | |
1829 | |
678 | 1830 void G1CollectedHeap::oop_iterate(OopClosure* cl, bool do_perm) { |
342 | 1831 IterateOopClosureRegionClosure blk(_g1_committed, cl); |
1832 _hrs->iterate(&blk); | |
678 | 1833 if (do_perm) { |
1834 perm_gen()->oop_iterate(cl); | |
1835 } | |
342 | 1836 } |
1837 | |
678 | 1838 void G1CollectedHeap::oop_iterate(MemRegion mr, OopClosure* cl, bool do_perm) { |
342 | 1839 IterateOopClosureRegionClosure blk(mr, cl); |
1840 _hrs->iterate(&blk); | |
678 | 1841 if (do_perm) { |
1842 perm_gen()->oop_iterate(cl); | |
1843 } | |
342 | 1844 } |
1845 | |
1846 // Iterates an ObjectClosure over all objects within a HeapRegion. | |
1847 | |
1848 class IterateObjectClosureRegionClosure: public HeapRegionClosure { | |
1849 ObjectClosure* _cl; | |
1850 public: | |
1851 IterateObjectClosureRegionClosure(ObjectClosure* cl) : _cl(cl) {} | |
1852 bool doHeapRegion(HeapRegion* r) { | |
1853 if (! r->continuesHumongous()) { | |
1854 r->object_iterate(_cl); | |
1855 } | |
1856 return false; | |
1857 } | |
1858 }; | |
1859 | |
678 | 1860 void G1CollectedHeap::object_iterate(ObjectClosure* cl, bool do_perm) { |
342 | 1861 IterateObjectClosureRegionClosure blk(cl); |
1862 _hrs->iterate(&blk); | |
678 | 1863 if (do_perm) { |
1864 perm_gen()->object_iterate(cl); | |
1865 } | |
342 | 1866 } |
1867 | |
1868 void G1CollectedHeap::object_iterate_since_last_GC(ObjectClosure* cl) { | |
1869 // FIXME: is this right? | |
1870 guarantee(false, "object_iterate_since_last_GC not supported by G1 heap"); | |
1871 } | |
1872 | |
1873 // Calls a SpaceClosure on a HeapRegion. | |
1874 | |
1875 class SpaceClosureRegionClosure: public HeapRegionClosure { | |
1876 SpaceClosure* _cl; | |
1877 public: | |
1878 SpaceClosureRegionClosure(SpaceClosure* cl) : _cl(cl) {} | |
1879 bool doHeapRegion(HeapRegion* r) { | |
1880 _cl->do_space(r); | |
1881 return false; | |
1882 } | |
1883 }; | |
1884 | |
1885 void G1CollectedHeap::space_iterate(SpaceClosure* cl) { | |
1886 SpaceClosureRegionClosure blk(cl); | |
1887 _hrs->iterate(&blk); | |
1888 } | |
1889 | |
1890 void G1CollectedHeap::heap_region_iterate(HeapRegionClosure* cl) { | |
1891 _hrs->iterate(cl); | |
1892 } | |
1893 | |
1894 void G1CollectedHeap::heap_region_iterate_from(HeapRegion* r, | |
1895 HeapRegionClosure* cl) { | |
1896 _hrs->iterate_from(r, cl); | |
1897 } | |
1898 | |
1899 void | |
1900 G1CollectedHeap::heap_region_iterate_from(int idx, HeapRegionClosure* cl) { | |
1901 _hrs->iterate_from(idx, cl); | |
1902 } | |
1903 | |
1904 HeapRegion* G1CollectedHeap::region_at(size_t idx) { return _hrs->at(idx); } | |
1905 | |
1906 void | |
1907 G1CollectedHeap::heap_region_par_iterate_chunked(HeapRegionClosure* cl, | |
1908 int worker, | |
1909 jint claim_value) { | |
355 | 1910 const size_t regions = n_regions(); |
1911 const size_t worker_num = (ParallelGCThreads > 0 ? ParallelGCThreads : 1); | |
1912 // try to spread out the starting points of the workers | |
1913 const size_t start_index = regions / worker_num * (size_t) worker; | |
1914 | |
1915 // each worker will actually look at all regions | |
1916 for (size_t count = 0; count < regions; ++count) { | |
1917 const size_t index = (start_index + count) % regions; | |
1918 assert(0 <= index && index < regions, "sanity"); | |
1919 HeapRegion* r = region_at(index); | |
1920 // we'll ignore "continues humongous" regions (we'll process them | |
1921 // when we come across their corresponding "start humongous" | |
1922 // region) and regions already claimed | |
1923 if (r->claim_value() == claim_value || r->continuesHumongous()) { | |
1924 continue; | |
1925 } | |
1926 // OK, try to claim it | |
342 | 1927 if (r->claimHeapRegion(claim_value)) { |
355 | 1928 // success! |
1929 assert(!r->continuesHumongous(), "sanity"); | |
1930 if (r->startsHumongous()) { | |
1931 // If the region is "starts humongous" we'll iterate over its | |
1932 // "continues humongous" first; in fact we'll do them | |
1933 // first. The order is important. In on case, calling the | |
1934 // closure on the "starts humongous" region might de-allocate | |
1935 // and clear all its "continues humongous" regions and, as a | |
1936 // result, we might end up processing them twice. So, we'll do | |
1937 // them first (notice: most closures will ignore them anyway) and | |
1938 // then we'll do the "starts humongous" region. | |
1939 for (size_t ch_index = index + 1; ch_index < regions; ++ch_index) { | |
1940 HeapRegion* chr = region_at(ch_index); | |
1941 | |
1942 // if the region has already been claimed or it's not | |
1943 // "continues humongous" we're done | |
1944 if (chr->claim_value() == claim_value || | |
1945 !chr->continuesHumongous()) { | |
1946 break; | |
1947 } | |
1948 | |
1949 // Noone should have claimed it directly. We can given | |
1950 // that we claimed its "starts humongous" region. | |
1951 assert(chr->claim_value() != claim_value, "sanity"); | |
1952 assert(chr->humongous_start_region() == r, "sanity"); | |
1953 | |
1954 if (chr->claimHeapRegion(claim_value)) { | |
1955 // we should always be able to claim it; noone else should | |
1956 // be trying to claim this region | |
1957 | |
1958 bool res2 = cl->doHeapRegion(chr); | |
1959 assert(!res2, "Should not abort"); | |
1960 | |
1961 // Right now, this holds (i.e., no closure that actually | |
1962 // does something with "continues humongous" regions | |
1963 // clears them). We might have to weaken it in the future, | |
1964 // but let's leave these two asserts here for extra safety. | |
1965 assert(chr->continuesHumongous(), "should still be the case"); | |
1966 assert(chr->humongous_start_region() == r, "sanity"); | |
1967 } else { | |
1968 guarantee(false, "we should not reach here"); | |
1969 } | |
1970 } | |
1971 } | |
1972 | |
1973 assert(!r->continuesHumongous(), "sanity"); | |
1974 bool res = cl->doHeapRegion(r); | |
1975 assert(!res, "Should not abort"); | |
1976 } | |
1977 } | |
1978 } | |
1979 | |
390 | 1980 class ResetClaimValuesClosure: public HeapRegionClosure { |
1981 public: | |
1982 bool doHeapRegion(HeapRegion* r) { | |
1983 r->set_claim_value(HeapRegion::InitialClaimValue); | |
1984 return false; | |
1985 } | |
1986 }; | |
1987 | |
1988 void | |
1989 G1CollectedHeap::reset_heap_region_claim_values() { | |
1990 ResetClaimValuesClosure blk; | |
1991 heap_region_iterate(&blk); | |
1992 } | |
1993 | |
355 | 1994 #ifdef ASSERT |
1995 // This checks whether all regions in the heap have the correct claim | |
1996 // value. I also piggy-backed on this a check to ensure that the | |
1997 // humongous_start_region() information on "continues humongous" | |
1998 // regions is correct. | |
1999 | |
2000 class CheckClaimValuesClosure : public HeapRegionClosure { | |
2001 private: | |
2002 jint _claim_value; | |
2003 size_t _failures; | |
2004 HeapRegion* _sh_region; | |
2005 public: | |
2006 CheckClaimValuesClosure(jint claim_value) : | |
2007 _claim_value(claim_value), _failures(0), _sh_region(NULL) { } | |
2008 bool doHeapRegion(HeapRegion* r) { | |
2009 if (r->claim_value() != _claim_value) { | |
2010 gclog_or_tty->print_cr("Region ["PTR_FORMAT","PTR_FORMAT"), " | |
2011 "claim value = %d, should be %d", | |
2012 r->bottom(), r->end(), r->claim_value(), | |
2013 _claim_value); | |
2014 ++_failures; | |
2015 } | |
2016 if (!r->isHumongous()) { | |
2017 _sh_region = NULL; | |
2018 } else if (r->startsHumongous()) { | |
2019 _sh_region = r; | |
2020 } else if (r->continuesHumongous()) { | |
2021 if (r->humongous_start_region() != _sh_region) { | |
2022 gclog_or_tty->print_cr("Region ["PTR_FORMAT","PTR_FORMAT"), " | |
2023 "HS = "PTR_FORMAT", should be "PTR_FORMAT, | |
2024 r->bottom(), r->end(), | |
2025 r->humongous_start_region(), | |
2026 _sh_region); | |
2027 ++_failures; | |
342 | 2028 } |
2029 } | |
355 | 2030 return false; |
2031 } | |
2032 size_t failures() { | |
2033 return _failures; | |
2034 } | |
2035 }; | |
2036 | |
2037 bool G1CollectedHeap::check_heap_region_claim_values(jint claim_value) { | |
2038 CheckClaimValuesClosure cl(claim_value); | |
2039 heap_region_iterate(&cl); | |
2040 return cl.failures() == 0; | |
2041 } | |
2042 #endif // ASSERT | |
342 | 2043 |
2044 void G1CollectedHeap::collection_set_iterate(HeapRegionClosure* cl) { | |
2045 HeapRegion* r = g1_policy()->collection_set(); | |
2046 while (r != NULL) { | |
2047 HeapRegion* next = r->next_in_collection_set(); | |
2048 if (cl->doHeapRegion(r)) { | |
2049 cl->incomplete(); | |
2050 return; | |
2051 } | |
2052 r = next; | |
2053 } | |
2054 } | |
2055 | |
2056 void G1CollectedHeap::collection_set_iterate_from(HeapRegion* r, | |
2057 HeapRegionClosure *cl) { | |
1656
4e5661ba9d98
6944166: G1: explicit GCs are not always handled correctly
tonyp
parents:
1611
diff
changeset
|
2058 if (r == NULL) { |
4e5661ba9d98
6944166: G1: explicit GCs are not always handled correctly
tonyp
parents:
1611
diff
changeset
|
2059 // The CSet is empty so there's nothing to do. |
4e5661ba9d98
6944166: G1: explicit GCs are not always handled correctly
tonyp
parents:
1611
diff
changeset
|
2060 return; |
4e5661ba9d98
6944166: G1: explicit GCs are not always handled correctly
tonyp
parents:
1611
diff
changeset
|
2061 } |
4e5661ba9d98
6944166: G1: explicit GCs are not always handled correctly
tonyp
parents:
1611
diff
changeset
|
2062 |
342 | 2063 assert(r->in_collection_set(), |
2064 "Start region must be a member of the collection set."); | |
2065 HeapRegion* cur = r; | |
2066 while (cur != NULL) { | |
2067 HeapRegion* next = cur->next_in_collection_set(); | |
2068 if (cl->doHeapRegion(cur) && false) { | |
2069 cl->incomplete(); | |
2070 return; | |
2071 } | |
2072 cur = next; | |
2073 } | |
2074 cur = g1_policy()->collection_set(); | |
2075 while (cur != r) { | |
2076 HeapRegion* next = cur->next_in_collection_set(); | |
2077 if (cl->doHeapRegion(cur) && false) { | |
2078 cl->incomplete(); | |
2079 return; | |
2080 } | |
2081 cur = next; | |
2082 } | |
2083 } | |
2084 | |
2085 CompactibleSpace* G1CollectedHeap::first_compactible_space() { | |
2086 return _hrs->length() > 0 ? _hrs->at(0) : NULL; | |
2087 } | |
2088 | |
2089 | |
2090 Space* G1CollectedHeap::space_containing(const void* addr) const { | |
2091 Space* res = heap_region_containing(addr); | |
2092 if (res == NULL) | |
2093 res = perm_gen()->space_containing(addr); | |
2094 return res; | |
2095 } | |
2096 | |
2097 HeapWord* G1CollectedHeap::block_start(const void* addr) const { | |
2098 Space* sp = space_containing(addr); | |
2099 if (sp != NULL) { | |
2100 return sp->block_start(addr); | |
2101 } | |
2102 return NULL; | |
2103 } | |
2104 | |
2105 size_t G1CollectedHeap::block_size(const HeapWord* addr) const { | |
2106 Space* sp = space_containing(addr); | |
2107 assert(sp != NULL, "block_size of address outside of heap"); | |
2108 return sp->block_size(addr); | |
2109 } | |
2110 | |
2111 bool G1CollectedHeap::block_is_obj(const HeapWord* addr) const { | |
2112 Space* sp = space_containing(addr); | |
2113 return sp->block_is_obj(addr); | |
2114 } | |
2115 | |
2116 bool G1CollectedHeap::supports_tlab_allocation() const { | |
2117 return true; | |
2118 } | |
2119 | |
2120 size_t G1CollectedHeap::tlab_capacity(Thread* ignored) const { | |
2121 return HeapRegion::GrainBytes; | |
2122 } | |
2123 | |
2124 size_t G1CollectedHeap::unsafe_max_tlab_alloc(Thread* ignored) const { | |
2125 // Return the remaining space in the cur alloc region, but not less than | |
2126 // the min TLAB size. | |
1313
664ae0c5e0e5
6755988: G1: assert(new_obj != 0 || ... "should be forwarded")
johnc
parents:
1282
diff
changeset
|
2127 |
664ae0c5e0e5
6755988: G1: assert(new_obj != 0 || ... "should be forwarded")
johnc
parents:
1282
diff
changeset
|
2128 // Also, this value can be at most the humongous object threshold, |
664ae0c5e0e5
6755988: G1: assert(new_obj != 0 || ... "should be forwarded")
johnc
parents:
1282
diff
changeset
|
2129 // since we can't allow tlabs to grow big enough to accomodate |
664ae0c5e0e5
6755988: G1: assert(new_obj != 0 || ... "should be forwarded")
johnc
parents:
1282
diff
changeset
|
2130 // humongous objects. |
664ae0c5e0e5
6755988: G1: assert(new_obj != 0 || ... "should be forwarded")
johnc
parents:
1282
diff
changeset
|
2131 |
664ae0c5e0e5
6755988: G1: assert(new_obj != 0 || ... "should be forwarded")
johnc
parents:
1282
diff
changeset
|
2132 // We need to store the cur alloc region locally, since it might change |
664ae0c5e0e5
6755988: G1: assert(new_obj != 0 || ... "should be forwarded")
johnc
parents:
1282
diff
changeset
|
2133 // between when we test for NULL and when we use it later. |
342 | 2134 ContiguousSpace* cur_alloc_space = _cur_alloc_region; |
1313
664ae0c5e0e5
6755988: G1: assert(new_obj != 0 || ... "should be forwarded")
johnc
parents:
1282
diff
changeset
|
2135 size_t max_tlab_size = _humongous_object_threshold_in_words * wordSize; |
664ae0c5e0e5
6755988: G1: assert(new_obj != 0 || ... "should be forwarded")
johnc
parents:
1282
diff
changeset
|
2136 |
342 | 2137 if (cur_alloc_space == NULL) { |
1313
664ae0c5e0e5
6755988: G1: assert(new_obj != 0 || ... "should be forwarded")
johnc
parents:
1282
diff
changeset
|
2138 return max_tlab_size; |
342 | 2139 } else { |
1313
664ae0c5e0e5
6755988: G1: assert(new_obj != 0 || ... "should be forwarded")
johnc
parents:
1282
diff
changeset
|
2140 return MIN2(MAX2(cur_alloc_space->free(), (size_t)MinTLABSize), |
664ae0c5e0e5
6755988: G1: assert(new_obj != 0 || ... "should be forwarded")
johnc
parents:
1282
diff
changeset
|
2141 max_tlab_size); |
342 | 2142 } |
2143 } | |
2144 | |
2145 HeapWord* G1CollectedHeap::allocate_new_tlab(size_t size) { | |
2146 bool dummy; | |
2147 return G1CollectedHeap::mem_allocate(size, false, true, &dummy); | |
2148 } | |
2149 | |
2150 bool G1CollectedHeap::allocs_are_zero_filled() { | |
2151 return false; | |
2152 } | |
2153 | |
2154 size_t G1CollectedHeap::large_typearray_limit() { | |
2155 // FIXME | |
2156 return HeapRegion::GrainBytes/HeapWordSize; | |
2157 } | |
2158 | |
2159 size_t G1CollectedHeap::max_capacity() const { | |
1092
ed52bcc32739
6880903: G1: G1 reports incorrect Runtime.maxMemory()
tonyp
parents:
1089
diff
changeset
|
2160 return g1_reserved_obj_bytes(); |
342 | 2161 } |
2162 | |
2163 jlong G1CollectedHeap::millis_since_last_gc() { | |
2164 // assert(false, "NYI"); | |
2165 return 0; | |
2166 } | |
2167 | |
2168 | |
2169 void G1CollectedHeap::prepare_for_verify() { | |
2170 if (SafepointSynchronize::is_at_safepoint() || ! UseTLAB) { | |
2171 ensure_parsability(false); | |
2172 } | |
2173 g1_rem_set()->prepare_for_verify(); | |
2174 } | |
2175 | |
2176 class VerifyLivenessOopClosure: public OopClosure { | |
2177 G1CollectedHeap* g1h; | |
2178 public: | |
2179 VerifyLivenessOopClosure(G1CollectedHeap* _g1h) { | |
2180 g1h = _g1h; | |
2181 } | |
845
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
2182 void do_oop(narrowOop *p) { do_oop_work(p); } |
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
2183 void do_oop( oop *p) { do_oop_work(p); } |
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
2184 |
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
2185 template <class T> void do_oop_work(T *p) { |
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
2186 oop obj = oopDesc::load_decode_heap_oop(p); |
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
2187 guarantee(obj == NULL || !g1h->is_obj_dead(obj), |
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
2188 "Dead object referenced by a not dead object"); |
342 | 2189 } |
2190 }; | |
2191 | |
2192 class VerifyObjsInRegionClosure: public ObjectClosure { | |
811 | 2193 private: |
342 | 2194 G1CollectedHeap* _g1h; |
2195 size_t _live_bytes; | |
2196 HeapRegion *_hr; | |
811 | 2197 bool _use_prev_marking; |
342 | 2198 public: |
811 | 2199 // use_prev_marking == true -> use "prev" marking information, |
2200 // use_prev_marking == false -> use "next" marking information | |
2201 VerifyObjsInRegionClosure(HeapRegion *hr, bool use_prev_marking) | |
2202 : _live_bytes(0), _hr(hr), _use_prev_marking(use_prev_marking) { | |
342 | 2203 _g1h = G1CollectedHeap::heap(); |
2204 } | |
2205 void do_object(oop o) { | |
2206 VerifyLivenessOopClosure isLive(_g1h); | |
2207 assert(o != NULL, "Huh?"); | |
811 | 2208 if (!_g1h->is_obj_dead_cond(o, _use_prev_marking)) { |
342 | 2209 o->oop_iterate(&isLive); |
1389
5dbd9300cf9c
6943926: G1: Integer overflow during heap region verification
johnc
parents:
1388
diff
changeset
|
2210 if (!_hr->obj_allocated_since_prev_marking(o)) { |
5dbd9300cf9c
6943926: G1: Integer overflow during heap region verification
johnc
parents:
1388
diff
changeset
|
2211 size_t obj_size = o->size(); // Make sure we don't overflow |
5dbd9300cf9c
6943926: G1: Integer overflow during heap region verification
johnc
parents:
1388
diff
changeset
|
2212 _live_bytes += (obj_size * HeapWordSize); |
5dbd9300cf9c
6943926: G1: Integer overflow during heap region verification
johnc
parents:
1388
diff
changeset
|
2213 } |
342 | 2214 } |
2215 } | |
2216 size_t live_bytes() { return _live_bytes; } | |
2217 }; | |
2218 | |
2219 class PrintObjsInRegionClosure : public ObjectClosure { | |
2220 HeapRegion *_hr; | |
2221 G1CollectedHeap *_g1; | |
2222 public: | |
2223 PrintObjsInRegionClosure(HeapRegion *hr) : _hr(hr) { | |
2224 _g1 = G1CollectedHeap::heap(); | |
2225 }; | |
2226 | |
2227 void do_object(oop o) { | |
2228 if (o != NULL) { | |
2229 HeapWord *start = (HeapWord *) o; | |
2230 size_t word_sz = o->size(); | |
2231 gclog_or_tty->print("\nPrinting obj "PTR_FORMAT" of size " SIZE_FORMAT | |
2232 " isMarkedPrev %d isMarkedNext %d isAllocSince %d\n", | |
2233 (void*) o, word_sz, | |
2234 _g1->isMarkedPrev(o), | |
2235 _g1->isMarkedNext(o), | |
2236 _hr->obj_allocated_since_prev_marking(o)); | |
2237 HeapWord *end = start + word_sz; | |
2238 HeapWord *cur; | |
2239 int *val; | |
2240 for (cur = start; cur < end; cur++) { | |
2241 val = (int *) cur; | |
2242 gclog_or_tty->print("\t "PTR_FORMAT":"PTR_FORMAT"\n", val, *val); | |
2243 } | |
2244 } | |
2245 } | |
2246 }; | |
2247 | |
2248 class VerifyRegionClosure: public HeapRegionClosure { | |
811 | 2249 private: |
342 | 2250 bool _allow_dirty; |
390 | 2251 bool _par; |
811 | 2252 bool _use_prev_marking; |
1020
ff2402f6a50b
6882730: G1: parallel heap verification messes up region dump
tonyp
parents:
1019
diff
changeset
|
2253 bool _failures; |
811 | 2254 public: |
2255 // use_prev_marking == true -> use "prev" marking information, | |
2256 // use_prev_marking == false -> use "next" marking information | |
2257 VerifyRegionClosure(bool allow_dirty, bool par, bool use_prev_marking) | |
845
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
2258 : _allow_dirty(allow_dirty), |
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
2259 _par(par), |
1020
ff2402f6a50b
6882730: G1: parallel heap verification messes up region dump
tonyp
parents:
1019
diff
changeset
|
2260 _use_prev_marking(use_prev_marking), |
ff2402f6a50b
6882730: G1: parallel heap verification messes up region dump
tonyp
parents:
1019
diff
changeset
|
2261 _failures(false) {} |
ff2402f6a50b
6882730: G1: parallel heap verification messes up region dump
tonyp
parents:
1019
diff
changeset
|
2262 |
ff2402f6a50b
6882730: G1: parallel heap verification messes up region dump
tonyp
parents:
1019
diff
changeset
|
2263 bool failures() { |
ff2402f6a50b
6882730: G1: parallel heap verification messes up region dump
tonyp
parents:
1019
diff
changeset
|
2264 return _failures; |
ff2402f6a50b
6882730: G1: parallel heap verification messes up region dump
tonyp
parents:
1019
diff
changeset
|
2265 } |
845
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
2266 |
342 | 2267 bool doHeapRegion(HeapRegion* r) { |
390 | 2268 guarantee(_par || r->claim_value() == HeapRegion::InitialClaimValue, |
2269 "Should be unclaimed at verify points."); | |
637
25e146966e7c
6817419: G1: Enable extensive verification for humongous regions
iveresov
parents:
636
diff
changeset
|
2270 if (!r->continuesHumongous()) { |
1020
ff2402f6a50b
6882730: G1: parallel heap verification messes up region dump
tonyp
parents:
1019
diff
changeset
|
2271 bool failures = false; |
ff2402f6a50b
6882730: G1: parallel heap verification messes up region dump
tonyp
parents:
1019
diff
changeset
|
2272 r->verify(_allow_dirty, _use_prev_marking, &failures); |
ff2402f6a50b
6882730: G1: parallel heap verification messes up region dump
tonyp
parents:
1019
diff
changeset
|
2273 if (failures) { |
ff2402f6a50b
6882730: G1: parallel heap verification messes up region dump
tonyp
parents:
1019
diff
changeset
|
2274 _failures = true; |
ff2402f6a50b
6882730: G1: parallel heap verification messes up region dump
tonyp
parents:
1019
diff
changeset
|
2275 } else { |
ff2402f6a50b
6882730: G1: parallel heap verification messes up region dump
tonyp
parents:
1019
diff
changeset
|
2276 VerifyObjsInRegionClosure not_dead_yet_cl(r, _use_prev_marking); |
ff2402f6a50b
6882730: G1: parallel heap verification messes up region dump
tonyp
parents:
1019
diff
changeset
|
2277 r->object_iterate(¬_dead_yet_cl); |
ff2402f6a50b
6882730: G1: parallel heap verification messes up region dump
tonyp
parents:
1019
diff
changeset
|
2278 if (r->max_live_bytes() < not_dead_yet_cl.live_bytes()) { |
ff2402f6a50b
6882730: G1: parallel heap verification messes up region dump
tonyp
parents:
1019
diff
changeset
|
2279 gclog_or_tty->print_cr("["PTR_FORMAT","PTR_FORMAT"] " |
ff2402f6a50b
6882730: G1: parallel heap verification messes up region dump
tonyp
parents:
1019
diff
changeset
|
2280 "max_live_bytes "SIZE_FORMAT" " |
ff2402f6a50b
6882730: G1: parallel heap verification messes up region dump
tonyp
parents:
1019
diff
changeset
|
2281 "< calculated "SIZE_FORMAT, |
ff2402f6a50b
6882730: G1: parallel heap verification messes up region dump
tonyp
parents:
1019
diff
changeset
|
2282 r->bottom(), r->end(), |
ff2402f6a50b
6882730: G1: parallel heap verification messes up region dump
tonyp
parents:
1019
diff
changeset
|
2283 r->max_live_bytes(), |
ff2402f6a50b
6882730: G1: parallel heap verification messes up region dump
tonyp
parents:
1019
diff
changeset
|
2284 not_dead_yet_cl.live_bytes()); |
ff2402f6a50b
6882730: G1: parallel heap verification messes up region dump
tonyp
parents:
1019
diff
changeset
|
2285 _failures = true; |
ff2402f6a50b
6882730: G1: parallel heap verification messes up region dump
tonyp
parents:
1019
diff
changeset
|
2286 } |
ff2402f6a50b
6882730: G1: parallel heap verification messes up region dump
tonyp
parents:
1019
diff
changeset
|
2287 } |
342 | 2288 } |
1020
ff2402f6a50b
6882730: G1: parallel heap verification messes up region dump
tonyp
parents:
1019
diff
changeset
|
2289 return false; // stop the region iteration if we hit a failure |
342 | 2290 } |
2291 }; | |
2292 | |
2293 class VerifyRootsClosure: public OopsInGenClosure { | |
2294 private: | |
2295 G1CollectedHeap* _g1h; | |
1020
ff2402f6a50b
6882730: G1: parallel heap verification messes up region dump
tonyp
parents:
1019
diff
changeset
|
2296 bool _use_prev_marking; |
342 | 2297 bool _failures; |
2298 public: | |
811 | 2299 // use_prev_marking == true -> use "prev" marking information, |
2300 // use_prev_marking == false -> use "next" marking information | |
2301 VerifyRootsClosure(bool use_prev_marking) : | |
845
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
2302 _g1h(G1CollectedHeap::heap()), |
1020
ff2402f6a50b
6882730: G1: parallel heap verification messes up region dump
tonyp
parents:
1019
diff
changeset
|
2303 _use_prev_marking(use_prev_marking), |
ff2402f6a50b
6882730: G1: parallel heap verification messes up region dump
tonyp
parents:
1019
diff
changeset
|
2304 _failures(false) { } |
342 | 2305 |
2306 bool failures() { return _failures; } | |
2307 | |
845
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
2308 template <class T> void do_oop_nv(T* p) { |
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
2309 T heap_oop = oopDesc::load_heap_oop(p); |
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
2310 if (!oopDesc::is_null(heap_oop)) { |
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
2311 oop obj = oopDesc::decode_heap_oop_not_null(heap_oop); |
811 | 2312 if (_g1h->is_obj_dead_cond(obj, _use_prev_marking)) { |
342 | 2313 gclog_or_tty->print_cr("Root location "PTR_FORMAT" " |
1020
ff2402f6a50b
6882730: G1: parallel heap verification messes up region dump
tonyp
parents:
1019
diff
changeset
|
2314 "points to dead obj "PTR_FORMAT, p, (void*) obj); |
342 | 2315 obj->print_on(gclog_or_tty); |
2316 _failures = true; | |
2317 } | |
2318 } | |
2319 } | |
845
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
2320 |
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
2321 void do_oop(oop* p) { do_oop_nv(p); } |
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
2322 void do_oop(narrowOop* p) { do_oop_nv(p); } |
342 | 2323 }; |
2324 | |
390 | 2325 // This is the task used for parallel heap verification. |
2326 | |
2327 class G1ParVerifyTask: public AbstractGangTask { | |
2328 private: | |
2329 G1CollectedHeap* _g1h; | |
2330 bool _allow_dirty; | |
811 | 2331 bool _use_prev_marking; |
1020
ff2402f6a50b
6882730: G1: parallel heap verification messes up region dump
tonyp
parents:
1019
diff
changeset
|
2332 bool _failures; |
390 | 2333 |
2334 public: | |
811 | 2335 // use_prev_marking == true -> use "prev" marking information, |
2336 // use_prev_marking == false -> use "next" marking information | |
2337 G1ParVerifyTask(G1CollectedHeap* g1h, bool allow_dirty, | |
2338 bool use_prev_marking) : | |
390 | 2339 AbstractGangTask("Parallel verify task"), |
845
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
2340 _g1h(g1h), |
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
2341 _allow_dirty(allow_dirty), |
1020
ff2402f6a50b
6882730: G1: parallel heap verification messes up region dump
tonyp
parents:
1019
diff
changeset
|
2342 _use_prev_marking(use_prev_marking), |
ff2402f6a50b
6882730: G1: parallel heap verification messes up region dump
tonyp
parents:
1019
diff
changeset
|
2343 _failures(false) { } |
ff2402f6a50b
6882730: G1: parallel heap verification messes up region dump
tonyp
parents:
1019
diff
changeset
|
2344 |
ff2402f6a50b
6882730: G1: parallel heap verification messes up region dump
tonyp
parents:
1019
diff
changeset
|
2345 bool failures() { |
ff2402f6a50b
6882730: G1: parallel heap verification messes up region dump
tonyp
parents:
1019
diff
changeset
|
2346 return _failures; |
ff2402f6a50b
6882730: G1: parallel heap verification messes up region dump
tonyp
parents:
1019
diff
changeset
|
2347 } |
390 | 2348 |
2349 void work(int worker_i) { | |
637
25e146966e7c
6817419: G1: Enable extensive verification for humongous regions
iveresov
parents:
636
diff
changeset
|
2350 HandleMark hm; |
811 | 2351 VerifyRegionClosure blk(_allow_dirty, true, _use_prev_marking); |
390 | 2352 _g1h->heap_region_par_iterate_chunked(&blk, worker_i, |
2353 HeapRegion::ParVerifyClaimValue); | |
1020
ff2402f6a50b
6882730: G1: parallel heap verification messes up region dump
tonyp
parents:
1019
diff
changeset
|
2354 if (blk.failures()) { |
ff2402f6a50b
6882730: G1: parallel heap verification messes up region dump
tonyp
parents:
1019
diff
changeset
|
2355 _failures = true; |
ff2402f6a50b
6882730: G1: parallel heap verification messes up region dump
tonyp
parents:
1019
diff
changeset
|
2356 } |
390 | 2357 } |
2358 }; | |
2359 | |
342 | 2360 void G1CollectedHeap::verify(bool allow_dirty, bool silent) { |
811 | 2361 verify(allow_dirty, silent, /* use_prev_marking */ true); |
2362 } | |
2363 | |
2364 void G1CollectedHeap::verify(bool allow_dirty, | |
2365 bool silent, | |
2366 bool use_prev_marking) { | |
342 | 2367 if (SafepointSynchronize::is_at_safepoint() || ! UseTLAB) { |
2368 if (!silent) { gclog_or_tty->print("roots "); } | |
811 | 2369 VerifyRootsClosure rootsCl(use_prev_marking); |
989
148e5441d916
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
890
diff
changeset
|
2370 CodeBlobToOopClosure blobsCl(&rootsCl, /*do_marking=*/ false); |
148e5441d916
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
890
diff
changeset
|
2371 process_strong_roots(true, // activate StrongRootsScope |
148e5441d916
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
890
diff
changeset
|
2372 false, |
342 | 2373 SharedHeap::SO_AllClasses, |
2374 &rootsCl, | |
989
148e5441d916
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
890
diff
changeset
|
2375 &blobsCl, |
342 | 2376 &rootsCl); |
1020
ff2402f6a50b
6882730: G1: parallel heap verification messes up region dump
tonyp
parents:
1019
diff
changeset
|
2377 bool failures = rootsCl.failures(); |
342 | 2378 rem_set()->invalidate(perm_gen()->used_region(), false); |
2379 if (!silent) { gclog_or_tty->print("heapRegions "); } | |
390 | 2380 if (GCParallelVerificationEnabled && ParallelGCThreads > 1) { |
2381 assert(check_heap_region_claim_values(HeapRegion::InitialClaimValue), | |
2382 "sanity check"); | |
2383 | |
811 | 2384 G1ParVerifyTask task(this, allow_dirty, use_prev_marking); |
390 | 2385 int n_workers = workers()->total_workers(); |
2386 set_par_threads(n_workers); | |
2387 workers()->run_task(&task); | |
2388 set_par_threads(0); | |
1020
ff2402f6a50b
6882730: G1: parallel heap verification messes up region dump
tonyp
parents:
1019
diff
changeset
|
2389 if (task.failures()) { |
ff2402f6a50b
6882730: G1: parallel heap verification messes up region dump
tonyp
parents:
1019
diff
changeset
|
2390 failures = true; |
ff2402f6a50b
6882730: G1: parallel heap verification messes up region dump
tonyp
parents:
1019
diff
changeset
|
2391 } |
390 | 2392 |
2393 assert(check_heap_region_claim_values(HeapRegion::ParVerifyClaimValue), | |
2394 "sanity check"); | |
2395 | |
2396 reset_heap_region_claim_values(); | |
2397 | |
2398 assert(check_heap_region_claim_values(HeapRegion::InitialClaimValue), | |
2399 "sanity check"); | |
2400 } else { | |
811 | 2401 VerifyRegionClosure blk(allow_dirty, false, use_prev_marking); |
390 | 2402 _hrs->iterate(&blk); |
1020
ff2402f6a50b
6882730: G1: parallel heap verification messes up region dump
tonyp
parents:
1019
diff
changeset
|
2403 if (blk.failures()) { |
ff2402f6a50b
6882730: G1: parallel heap verification messes up region dump
tonyp
parents:
1019
diff
changeset
|
2404 failures = true; |
ff2402f6a50b
6882730: G1: parallel heap verification messes up region dump
tonyp
parents:
1019
diff
changeset
|
2405 } |
390 | 2406 } |
342 | 2407 if (!silent) gclog_or_tty->print("remset "); |
2408 rem_set()->verify(); | |
1020
ff2402f6a50b
6882730: G1: parallel heap verification messes up region dump
tonyp
parents:
1019
diff
changeset
|
2409 |
ff2402f6a50b
6882730: G1: parallel heap verification messes up region dump
tonyp
parents:
1019
diff
changeset
|
2410 if (failures) { |
ff2402f6a50b
6882730: G1: parallel heap verification messes up region dump
tonyp
parents:
1019
diff
changeset
|
2411 gclog_or_tty->print_cr("Heap:"); |
ff2402f6a50b
6882730: G1: parallel heap verification messes up region dump
tonyp
parents:
1019
diff
changeset
|
2412 print_on(gclog_or_tty, true /* extended */); |
ff2402f6a50b
6882730: G1: parallel heap verification messes up region dump
tonyp
parents:
1019
diff
changeset
|
2413 gclog_or_tty->print_cr(""); |
1547
fb1a39993f69
6951319: enable solaris builds using Sun Studio 12 update 1
jcoomes
parents:
1545
diff
changeset
|
2414 #ifndef PRODUCT |
1044 | 2415 if (VerifyDuringGC && G1VerifyDuringGCPrintReachable) { |
1388 | 2416 concurrent_mark()->print_reachable("at-verification-failure", |
2417 use_prev_marking, false /* all */); | |
1020
ff2402f6a50b
6882730: G1: parallel heap verification messes up region dump
tonyp
parents:
1019
diff
changeset
|
2418 } |
1547
fb1a39993f69
6951319: enable solaris builds using Sun Studio 12 update 1
jcoomes
parents:
1545
diff
changeset
|
2419 #endif |
1020
ff2402f6a50b
6882730: G1: parallel heap verification messes up region dump
tonyp
parents:
1019
diff
changeset
|
2420 gclog_or_tty->flush(); |
ff2402f6a50b
6882730: G1: parallel heap verification messes up region dump
tonyp
parents:
1019
diff
changeset
|
2421 } |
ff2402f6a50b
6882730: G1: parallel heap verification messes up region dump
tonyp
parents:
1019
diff
changeset
|
2422 guarantee(!failures, "there should not have been any failures"); |
342 | 2423 } else { |
2424 if (!silent) gclog_or_tty->print("(SKIPPING roots, heapRegions, remset) "); | |
2425 } | |
2426 } | |
2427 | |
2428 class PrintRegionClosure: public HeapRegionClosure { | |
2429 outputStream* _st; | |
2430 public: | |
2431 PrintRegionClosure(outputStream* st) : _st(st) {} | |
2432 bool doHeapRegion(HeapRegion* r) { | |
2433 r->print_on(_st); | |
2434 return false; | |
2435 } | |
2436 }; | |
2437 | |
838
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2438 void G1CollectedHeap::print() const { print_on(tty); } |
342 | 2439 |
2440 void G1CollectedHeap::print_on(outputStream* st) const { | |
838
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2441 print_on(st, PrintHeapAtGCExtended); |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2442 } |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2443 |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2444 void G1CollectedHeap::print_on(outputStream* st, bool extended) const { |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2445 st->print(" %-20s", "garbage-first heap"); |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2446 st->print(" total " SIZE_FORMAT "K, used " SIZE_FORMAT "K", |
846
42d84bbbecf4
6859911: G1: assert(Heap_lock->owner() = NULL, "Should be owned on this thread's behalf")
tonyp
parents:
845
diff
changeset
|
2447 capacity()/K, used_unlocked()/K); |
838
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2448 st->print(" [" INTPTR_FORMAT ", " INTPTR_FORMAT ", " INTPTR_FORMAT ")", |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2449 _g1_storage.low_boundary(), |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2450 _g1_storage.high(), |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2451 _g1_storage.high_boundary()); |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2452 st->cr(); |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2453 st->print(" region size " SIZE_FORMAT "K, ", |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2454 HeapRegion::GrainBytes/K); |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2455 size_t young_regions = _young_list->length(); |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2456 st->print(SIZE_FORMAT " young (" SIZE_FORMAT "K), ", |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2457 young_regions, young_regions * HeapRegion::GrainBytes / K); |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2458 size_t survivor_regions = g1_policy()->recorded_survivor_regions(); |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2459 st->print(SIZE_FORMAT " survivors (" SIZE_FORMAT "K)", |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2460 survivor_regions, survivor_regions * HeapRegion::GrainBytes / K); |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2461 st->cr(); |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2462 perm()->as_gen()->print_on(st); |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2463 if (extended) { |
1020
ff2402f6a50b
6882730: G1: parallel heap verification messes up region dump
tonyp
parents:
1019
diff
changeset
|
2464 st->cr(); |
838
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2465 print_on_extended(st); |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2466 } |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2467 } |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2468 |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2469 void G1CollectedHeap::print_on_extended(outputStream* st) const { |
342 | 2470 PrintRegionClosure blk(st); |
2471 _hrs->iterate(&blk); | |
2472 } | |
2473 | |
2474 void G1CollectedHeap::print_gc_threads_on(outputStream* st) const { | |
2475 if (ParallelGCThreads > 0) { | |
1019 | 2476 workers()->print_worker_threads_on(st); |
2477 } | |
2478 | |
2479 _cmThread->print_on(st); | |
342 | 2480 st->cr(); |
1019 | 2481 |
2482 _cm->print_worker_threads_on(st); | |
2483 | |
2484 _cg1r->print_worker_threads_on(st); | |
2485 | |
342 | 2486 _czft->print_on(st); |
2487 st->cr(); | |
2488 } | |
2489 | |
2490 void G1CollectedHeap::gc_threads_do(ThreadClosure* tc) const { | |
2491 if (ParallelGCThreads > 0) { | |
2492 workers()->threads_do(tc); | |
2493 } | |
2494 tc->do_thread(_cmThread); | |
794 | 2495 _cg1r->threads_do(tc); |
342 | 2496 tc->do_thread(_czft); |
2497 } | |
2498 | |
2499 void G1CollectedHeap::print_tracing_info() const { | |
2500 // We'll overload this to mean "trace GC pause statistics." | |
2501 if (TraceGen0Time || TraceGen1Time) { | |
2502 // The "G1CollectorPolicy" is keeping track of these stats, so delegate | |
2503 // to that. | |
2504 g1_policy()->print_tracing_info(); | |
2505 } | |
751 | 2506 if (G1SummarizeRSetStats) { |
342 | 2507 g1_rem_set()->print_summary_info(); |
2508 } | |
1282 | 2509 if (G1SummarizeConcMark) { |
342 | 2510 concurrent_mark()->print_summary_info(); |
2511 } | |
751 | 2512 if (G1SummarizeZFStats) { |
342 | 2513 ConcurrentZFThread::print_summary_info(); |
2514 } | |
2515 g1_policy()->print_yg_surv_rate_info(); | |
2516 | |
2517 SpecializationStats::print(); | |
2518 } | |
2519 | |
2520 | |
2521 int G1CollectedHeap::addr_to_arena_id(void* addr) const { | |
2522 HeapRegion* hr = heap_region_containing(addr); | |
2523 if (hr == NULL) { | |
2524 return 0; | |
2525 } else { | |
2526 return 1; | |
2527 } | |
2528 } | |
2529 | |
2530 G1CollectedHeap* G1CollectedHeap::heap() { | |
2531 assert(_sh->kind() == CollectedHeap::G1CollectedHeap, | |
2532 "not a garbage-first heap"); | |
2533 return _g1h; | |
2534 } | |
2535 | |
2536 void G1CollectedHeap::gc_prologue(bool full /* Ignored */) { | |
1245
6484c4ee11cb
6904516: More object array barrier fixes, following up on 6906727
ysr
parents:
1166
diff
changeset
|
2537 // always_do_update_barrier = false; |
342 | 2538 assert(InlineCacheBuffer::is_empty(), "should have cleaned up ICBuffer"); |
2539 // Call allocation profiler | |
2540 AllocationProfiler::iterate_since_last_gc(); | |
2541 // Fill TLAB's and such | |
2542 ensure_parsability(true); | |
2543 } | |
2544 | |
2545 void G1CollectedHeap::gc_epilogue(bool full /* Ignored */) { | |
2546 // FIXME: what is this about? | |
2547 // I'm ignoring the "fill_newgen()" call if "alloc_event_enabled" | |
2548 // is set. | |
2549 COMPILER2_PRESENT(assert(DerivedPointerTable::is_empty(), | |
2550 "derived pointer present")); | |
1245
6484c4ee11cb
6904516: More object array barrier fixes, following up on 6906727
ysr
parents:
1166
diff
changeset
|
2551 // always_do_update_barrier = true; |
342 | 2552 } |
2553 | |
2554 void G1CollectedHeap::do_collection_pause() { | |
1656
4e5661ba9d98
6944166: G1: explicit GCs are not always handled correctly
tonyp
parents:
1611
diff
changeset
|
2555 assert(Heap_lock->owned_by_self(), "we assume we'reholding the Heap_lock"); |
4e5661ba9d98
6944166: G1: explicit GCs are not always handled correctly
tonyp
parents:
1611
diff
changeset
|
2556 |
342 | 2557 // Read the GC count while holding the Heap_lock |
2558 // we need to do this _before_ wait_for_cleanup_complete(), to | |
2559 // ensure that we do not give up the heap lock and potentially | |
2560 // pick up the wrong count | |
1656
4e5661ba9d98
6944166: G1: explicit GCs are not always handled correctly
tonyp
parents:
1611
diff
changeset
|
2561 unsigned int gc_count_before = SharedHeap::heap()->total_collections(); |
342 | 2562 |
2563 // Don't want to do a GC pause while cleanup is being completed! | |
2564 wait_for_cleanup_complete(); | |
2565 | |
2566 g1_policy()->record_stop_world_start(); | |
2567 { | |
2568 MutexUnlocker mu(Heap_lock); // give up heap lock, execute gets it back | |
1656
4e5661ba9d98
6944166: G1: explicit GCs are not always handled correctly
tonyp
parents:
1611
diff
changeset
|
2569 VM_G1IncCollectionPause op(gc_count_before, |
4e5661ba9d98
6944166: G1: explicit GCs are not always handled correctly
tonyp
parents:
1611
diff
changeset
|
2570 false, /* should_initiate_conc_mark */ |
4e5661ba9d98
6944166: G1: explicit GCs are not always handled correctly
tonyp
parents:
1611
diff
changeset
|
2571 g1_policy()->max_pause_time_ms(), |
4e5661ba9d98
6944166: G1: explicit GCs are not always handled correctly
tonyp
parents:
1611
diff
changeset
|
2572 GCCause::_g1_inc_collection_pause); |
342 | 2573 VMThread::execute(&op); |
2574 } | |
2575 } | |
2576 | |
2577 void | |
2578 G1CollectedHeap::doConcurrentMark() { | |
845
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
2579 MutexLockerEx x(CGC_lock, Mutex::_no_safepoint_check_flag); |
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
2580 if (!_cmThread->in_progress()) { |
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
2581 _cmThread->set_started(); |
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
2582 CGC_lock->notify(); |
342 | 2583 } |
2584 } | |
2585 | |
2586 class VerifyMarkedObjsClosure: public ObjectClosure { | |
2587 G1CollectedHeap* _g1h; | |
2588 public: | |
2589 VerifyMarkedObjsClosure(G1CollectedHeap* g1h) : _g1h(g1h) {} | |
2590 void do_object(oop obj) { | |
2591 assert(obj->mark()->is_marked() ? !_g1h->is_obj_dead(obj) : true, | |
2592 "markandsweep mark should agree with concurrent deadness"); | |
2593 } | |
2594 }; | |
2595 | |
2596 void | |
2597 G1CollectedHeap::checkConcurrentMark() { | |
2598 VerifyMarkedObjsClosure verifycl(this); | |
2599 // MutexLockerEx x(getMarkBitMapLock(), | |
2600 // Mutex::_no_safepoint_check_flag); | |
678 | 2601 object_iterate(&verifycl, false); |
342 | 2602 } |
2603 | |
2604 void G1CollectedHeap::do_sync_mark() { | |
2605 _cm->checkpointRootsInitial(); | |
2606 _cm->markFromRoots(); | |
2607 _cm->checkpointRootsFinal(false); | |
2608 } | |
2609 | |
2610 // <NEW PREDICTION> | |
2611 | |
2612 double G1CollectedHeap::predict_region_elapsed_time_ms(HeapRegion *hr, | |
2613 bool young) { | |
2614 return _g1_policy->predict_region_elapsed_time_ms(hr, young); | |
2615 } | |
2616 | |
2617 void G1CollectedHeap::check_if_region_is_too_expensive(double | |
2618 predicted_time_ms) { | |
2619 _g1_policy->check_if_region_is_too_expensive(predicted_time_ms); | |
2620 } | |
2621 | |
2622 size_t G1CollectedHeap::pending_card_num() { | |
2623 size_t extra_cards = 0; | |
2624 JavaThread *curr = Threads::first(); | |
2625 while (curr != NULL) { | |
2626 DirtyCardQueue& dcq = curr->dirty_card_queue(); | |
2627 extra_cards += dcq.size(); | |
2628 curr = curr->next(); | |
2629 } | |
2630 DirtyCardQueueSet& dcqs = JavaThread::dirty_card_queue_set(); | |
2631 size_t buffer_size = dcqs.buffer_size(); | |
2632 size_t buffer_num = dcqs.completed_buffers_num(); | |
2633 return buffer_size * buffer_num + extra_cards; | |
2634 } | |
2635 | |
2636 size_t G1CollectedHeap::max_pending_card_num() { | |
2637 DirtyCardQueueSet& dcqs = JavaThread::dirty_card_queue_set(); | |
2638 size_t buffer_size = dcqs.buffer_size(); | |
2639 size_t buffer_num = dcqs.completed_buffers_num(); | |
2640 int thread_num = Threads::number_of_threads(); | |
2641 return (buffer_num + thread_num) * buffer_size; | |
2642 } | |
2643 | |
2644 size_t G1CollectedHeap::cards_scanned() { | |
2645 HRInto_G1RemSet* g1_rset = (HRInto_G1RemSet*) g1_rem_set(); | |
2646 return g1_rset->cardsScanned(); | |
2647 } | |
2648 | |
2649 void | |
2650 G1CollectedHeap::setup_surviving_young_words() { | |
2651 guarantee( _surviving_young_words == NULL, "pre-condition" ); | |
2652 size_t array_length = g1_policy()->young_cset_length(); | |
2653 _surviving_young_words = NEW_C_HEAP_ARRAY(size_t, array_length); | |
2654 if (_surviving_young_words == NULL) { | |
2655 vm_exit_out_of_memory(sizeof(size_t) * array_length, | |
2656 "Not enough space for young surv words summary."); | |
2657 } | |
2658 memset(_surviving_young_words, 0, array_length * sizeof(size_t)); | |
845
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
2659 #ifdef ASSERT |
342 | 2660 for (size_t i = 0; i < array_length; ++i) { |
845
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
2661 assert( _surviving_young_words[i] == 0, "memset above" ); |
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
2662 } |
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
2663 #endif // !ASSERT |
342 | 2664 } |
2665 | |
2666 void | |
2667 G1CollectedHeap::update_surviving_young_words(size_t* surv_young_words) { | |
2668 MutexLockerEx x(ParGCRareEvent_lock, Mutex::_no_safepoint_check_flag); | |
2669 size_t array_length = g1_policy()->young_cset_length(); | |
2670 for (size_t i = 0; i < array_length; ++i) | |
2671 _surviving_young_words[i] += surv_young_words[i]; | |
2672 } | |
2673 | |
2674 void | |
2675 G1CollectedHeap::cleanup_surviving_young_words() { | |
2676 guarantee( _surviving_young_words != NULL, "pre-condition" ); | |
2677 FREE_C_HEAP_ARRAY(size_t, _surviving_young_words); | |
2678 _surviving_young_words = NULL; | |
2679 } | |
2680 | |
2681 // </NEW PREDICTION> | |
2682 | |
1261
0414c1049f15
6923991: G1: improve scalability of RSet scanning
iveresov
parents:
1245
diff
changeset
|
2683 struct PrepareForRSScanningClosure : public HeapRegionClosure { |
0414c1049f15
6923991: G1: improve scalability of RSet scanning
iveresov
parents:
1245
diff
changeset
|
2684 bool doHeapRegion(HeapRegion *r) { |
0414c1049f15
6923991: G1: improve scalability of RSet scanning
iveresov
parents:
1245
diff
changeset
|
2685 r->rem_set()->set_iter_claimed(0); |
0414c1049f15
6923991: G1: improve scalability of RSet scanning
iveresov
parents:
1245
diff
changeset
|
2686 return false; |
0414c1049f15
6923991: G1: improve scalability of RSet scanning
iveresov
parents:
1245
diff
changeset
|
2687 } |
0414c1049f15
6923991: G1: improve scalability of RSet scanning
iveresov
parents:
1245
diff
changeset
|
2688 }; |
0414c1049f15
6923991: G1: improve scalability of RSet scanning
iveresov
parents:
1245
diff
changeset
|
2689 |
342 | 2690 void |
1656
4e5661ba9d98
6944166: G1: explicit GCs are not always handled correctly
tonyp
parents:
1611
diff
changeset
|
2691 G1CollectedHeap::do_collection_pause_at_safepoint(double target_pause_time_ms) { |
1359
23b1b27ac76c
6909756: G1: guarantee(G1CollectedHeap::heap()->mark_in_progress(),"Precondition.")
tonyp
parents:
1313
diff
changeset
|
2692 if (GC_locker::check_active_before_gc()) { |
23b1b27ac76c
6909756: G1: guarantee(G1CollectedHeap::heap()->mark_in_progress(),"Precondition.")
tonyp
parents:
1313
diff
changeset
|
2693 return; // GC is disabled (e.g. JNI GetXXXCritical operation) |
23b1b27ac76c
6909756: G1: guarantee(G1CollectedHeap::heap()->mark_in_progress(),"Precondition.")
tonyp
parents:
1313
diff
changeset
|
2694 } |
23b1b27ac76c
6909756: G1: guarantee(G1CollectedHeap::heap()->mark_in_progress(),"Precondition.")
tonyp
parents:
1313
diff
changeset
|
2695 |
838
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2696 if (PrintHeapAtGC) { |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2697 Universe::print_heap_before_gc(); |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2698 } |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2699 |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2700 { |
1089
db0d5eba9d20
6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
1088
diff
changeset
|
2701 ResourceMark rm; |
db0d5eba9d20
6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
1088
diff
changeset
|
2702 |
1359
23b1b27ac76c
6909756: G1: guarantee(G1CollectedHeap::heap()->mark_in_progress(),"Precondition.")
tonyp
parents:
1313
diff
changeset
|
2703 // This call will decide whether this pause is an initial-mark |
23b1b27ac76c
6909756: G1: guarantee(G1CollectedHeap::heap()->mark_in_progress(),"Precondition.")
tonyp
parents:
1313
diff
changeset
|
2704 // pause. If it is, during_initial_mark_pause() will return true |
23b1b27ac76c
6909756: G1: guarantee(G1CollectedHeap::heap()->mark_in_progress(),"Precondition.")
tonyp
parents:
1313
diff
changeset
|
2705 // for the duration of this pause. |
23b1b27ac76c
6909756: G1: guarantee(G1CollectedHeap::heap()->mark_in_progress(),"Precondition.")
tonyp
parents:
1313
diff
changeset
|
2706 g1_policy()->decide_on_conc_mark_initiation(); |
23b1b27ac76c
6909756: G1: guarantee(G1CollectedHeap::heap()->mark_in_progress(),"Precondition.")
tonyp
parents:
1313
diff
changeset
|
2707 |
838
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2708 char verbose_str[128]; |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2709 sprintf(verbose_str, "GC pause "); |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2710 if (g1_policy()->in_young_gc_mode()) { |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2711 if (g1_policy()->full_young_gcs()) |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2712 strcat(verbose_str, "(young)"); |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2713 else |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2714 strcat(verbose_str, "(partial)"); |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2715 } |
1656
4e5661ba9d98
6944166: G1: explicit GCs are not always handled correctly
tonyp
parents:
1611
diff
changeset
|
2716 if (g1_policy()->during_initial_mark_pause()) { |
838
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2717 strcat(verbose_str, " (initial-mark)"); |
1656
4e5661ba9d98
6944166: G1: explicit GCs are not always handled correctly
tonyp
parents:
1611
diff
changeset
|
2718 // We are about to start a marking cycle, so we increment the |
4e5661ba9d98
6944166: G1: explicit GCs are not always handled correctly
tonyp
parents:
1611
diff
changeset
|
2719 // full collection counter. |
4e5661ba9d98
6944166: G1: explicit GCs are not always handled correctly
tonyp
parents:
1611
diff
changeset
|
2720 increment_total_full_collections(); |
4e5661ba9d98
6944166: G1: explicit GCs are not always handled correctly
tonyp
parents:
1611
diff
changeset
|
2721 } |
838
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2722 |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2723 // if PrintGCDetails is on, we'll print long statistics information |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2724 // in the collector policy code, so let's not print this as the output |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2725 // is messy if we do. |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2726 gclog_or_tty->date_stamp(PrintGC && PrintGCDateStamps); |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2727 TraceCPUTime tcpu(PrintGCDetails, true, gclog_or_tty); |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2728 TraceTime t(verbose_str, PrintGC && !PrintGCDetails, true, gclog_or_tty); |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2729 |
1089
db0d5eba9d20
6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
1088
diff
changeset
|
2730 TraceMemoryManagerStats tms(false /* fullGC */); |
db0d5eba9d20
6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
1088
diff
changeset
|
2731 |
838
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2732 assert(SafepointSynchronize::is_at_safepoint(), "should be at safepoint"); |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2733 assert(Thread::current() == VMThread::vm_thread(), "should be in vm thread"); |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2734 guarantee(!is_gc_active(), "collection is not reentrant"); |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2735 assert(regions_accounted_for(), "Region leakage!"); |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2736 |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2737 increment_gc_time_stamp(); |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2738 |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2739 if (g1_policy()->in_young_gc_mode()) { |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2740 assert(check_young_list_well_formed(), |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2741 "young list should be well formed"); |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2742 } |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2743 |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2744 { // Call to jvmpi::post_class_unload_events must occur outside of active GC |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2745 IsGCActiveMark x; |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2746 |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2747 gc_prologue(false); |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2748 increment_total_collections(false /* full gc */); |
342 | 2749 |
2750 #if G1_REM_SET_LOGGING | |
838
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2751 gclog_or_tty->print_cr("\nJust chose CS, heap:"); |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2752 print(); |
342 | 2753 #endif |
2754 | |
838
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2755 if (VerifyBeforeGC && total_collections() >= VerifyGCStartAt) { |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2756 HandleMark hm; // Discard invalid handles created during verification |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2757 prepare_for_verify(); |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2758 gclog_or_tty->print(" VerifyBeforeGC:"); |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2759 Universe::verify(false); |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2760 } |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2761 |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2762 COMPILER2_PRESENT(DerivedPointerTable::clear()); |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2763 |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2764 // We want to turn off ref discovery, if necessary, and turn it back on |
845
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
2765 // on again later if we do. XXX Dubious: why is discovery disabled? |
838
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2766 bool was_enabled = ref_processor()->discovery_enabled(); |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2767 if (was_enabled) ref_processor()->disable_discovery(); |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2768 |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2769 // Forget the current alloc region (we might even choose it to be part |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2770 // of the collection set!). |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2771 abandon_cur_alloc_region(); |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2772 |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2773 // The elapsed time induced by the start time below deliberately elides |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2774 // the possible verification above. |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2775 double start_time_sec = os::elapsedTime(); |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2776 size_t start_used_bytes = used(); |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2777 |
1394
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
2778 #if YOUNG_LIST_VERBOSE |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
2779 gclog_or_tty->print_cr("\nBefore recording pause start.\nYoung_list:"); |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
2780 _young_list->print(); |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
2781 g1_policy()->print_collection_set(g1_policy()->inc_cset_head(), gclog_or_tty); |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
2782 #endif // YOUNG_LIST_VERBOSE |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
2783 |
838
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2784 g1_policy()->record_collection_pause_start(start_time_sec, |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2785 start_used_bytes); |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2786 |
1394
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
2787 #if YOUNG_LIST_VERBOSE |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
2788 gclog_or_tty->print_cr("\nAfter recording pause start.\nYoung_list:"); |
838
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2789 _young_list->print(); |
1394
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
2790 #endif // YOUNG_LIST_VERBOSE |
342 | 2791 |
1359
23b1b27ac76c
6909756: G1: guarantee(G1CollectedHeap::heap()->mark_in_progress(),"Precondition.")
tonyp
parents:
1313
diff
changeset
|
2792 if (g1_policy()->during_initial_mark_pause()) { |
838
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2793 concurrent_mark()->checkpointRootsInitialPre(); |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2794 } |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2795 save_marks(); |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2796 |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2797 // We must do this before any possible evacuation that should propagate |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2798 // marks. |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2799 if (mark_in_progress()) { |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2800 double start_time_sec = os::elapsedTime(); |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2801 |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2802 _cm->drainAllSATBBuffers(); |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2803 double finish_mark_ms = (os::elapsedTime() - start_time_sec) * 1000.0; |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2804 g1_policy()->record_satb_drain_time(finish_mark_ms); |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2805 } |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2806 // Record the number of elements currently on the mark stack, so we |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2807 // only iterate over these. (Since evacuation may add to the mark |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2808 // stack, doing more exposes race conditions.) If no mark is in |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2809 // progress, this will be zero. |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2810 _cm->set_oops_do_bound(); |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2811 |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2812 assert(regions_accounted_for(), "Region leakage."); |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2813 |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2814 if (mark_in_progress()) |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2815 concurrent_mark()->newCSet(); |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2816 |
1394
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
2817 #if YOUNG_LIST_VERBOSE |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
2818 gclog_or_tty->print_cr("\nBefore choosing collection set.\nYoung_list:"); |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
2819 _young_list->print(); |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
2820 g1_policy()->print_collection_set(g1_policy()->inc_cset_head(), gclog_or_tty); |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
2821 #endif // YOUNG_LIST_VERBOSE |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
2822 |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
2823 // Now choose the CS. We may abandon a pause if we find no |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
2824 // region that will fit in the MMU pause. |
1656
4e5661ba9d98
6944166: G1: explicit GCs are not always handled correctly
tonyp
parents:
1611
diff
changeset
|
2825 bool abandoned = g1_policy()->choose_collection_set(target_pause_time_ms); |
838
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2826 |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2827 // Nothing to do if we were unable to choose a collection set. |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2828 if (!abandoned) { |
342 | 2829 #if G1_REM_SET_LOGGING |
838
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2830 gclog_or_tty->print_cr("\nAfter pause, heap:"); |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2831 print(); |
342 | 2832 #endif |
1261
0414c1049f15
6923991: G1: improve scalability of RSet scanning
iveresov
parents:
1245
diff
changeset
|
2833 PrepareForRSScanningClosure prepare_for_rs_scan; |
0414c1049f15
6923991: G1: improve scalability of RSet scanning
iveresov
parents:
1245
diff
changeset
|
2834 collection_set_iterate(&prepare_for_rs_scan); |
342 | 2835 |
838
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2836 setup_surviving_young_words(); |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2837 |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2838 // Set up the gc allocation regions. |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2839 get_gc_alloc_regions(); |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2840 |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2841 // Actually do the work... |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2842 evacuate_collection_set(); |
1394
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
2843 |
838
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2844 free_collection_set(g1_policy()->collection_set()); |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2845 g1_policy()->clear_collection_set(); |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2846 |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2847 cleanup_surviving_young_words(); |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2848 |
1394
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
2849 // Start a new incremental collection set for the next pause. |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
2850 g1_policy()->start_incremental_cset_building(); |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
2851 |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
2852 // Clear the _cset_fast_test bitmap in anticipation of adding |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
2853 // regions to the incremental collection set for the next |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
2854 // evacuation pause. |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
2855 clear_cset_fast_test(); |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
2856 |
838
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2857 if (g1_policy()->in_young_gc_mode()) { |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2858 _young_list->reset_sampled_info(); |
1394
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
2859 |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
2860 // Don't check the whole heap at this point as the |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
2861 // GC alloc regions from this pause have been tagged |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
2862 // as survivors and moved on to the survivor list. |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
2863 // Survivor regions will fail the !is_young() check. |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
2864 assert(check_young_list_empty(false /* check_heap */), |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
2865 "young list should be empty"); |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
2866 |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
2867 #if YOUNG_LIST_VERBOSE |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
2868 gclog_or_tty->print_cr("Before recording survivors.\nYoung List:"); |
838
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2869 _young_list->print(); |
1394
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
2870 #endif // YOUNG_LIST_VERBOSE |
342 | 2871 |
838
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2872 g1_policy()->record_survivor_regions(_young_list->survivor_length(), |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2873 _young_list->first_survivor_region(), |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2874 _young_list->last_survivor_region()); |
1394
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
2875 |
838
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2876 _young_list->reset_auxilary_lists(); |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2877 } |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2878 } else { |
1394
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
2879 // We have abandoned the current collection. This can only happen |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
2880 // if we're not doing young or partially young collections, and |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
2881 // we didn't find an old region that we're able to collect within |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
2882 // the allowed time. |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
2883 |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
2884 assert(g1_policy()->collection_set() == NULL, "should be"); |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
2885 assert(_young_list->length() == 0, "because it should be"); |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
2886 |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
2887 // This should be a no-op. |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
2888 abandon_collection_set(g1_policy()->inc_cset_head()); |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
2889 |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
2890 g1_policy()->clear_incremental_cset(); |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
2891 g1_policy()->stop_incremental_cset_building(); |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
2892 |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
2893 // Start a new incremental collection set for the next pause. |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
2894 g1_policy()->start_incremental_cset_building(); |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
2895 |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
2896 // Clear the _cset_fast_test bitmap in anticipation of adding |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
2897 // regions to the incremental collection set for the next |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
2898 // evacuation pause. |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
2899 clear_cset_fast_test(); |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
2900 |
1088
3fc996d4edd2
6902303: G1: ScavengeALot should cause an incremental, rather than a full, collection
ysr
parents:
1045
diff
changeset
|
2901 // This looks confusing, because the DPT should really be empty |
3fc996d4edd2
6902303: G1: ScavengeALot should cause an incremental, rather than a full, collection
ysr
parents:
1045
diff
changeset
|
2902 // at this point -- since we have not done any collection work, |
3fc996d4edd2
6902303: G1: ScavengeALot should cause an incremental, rather than a full, collection
ysr
parents:
1045
diff
changeset
|
2903 // there should not be any derived pointers in the table to update; |
3fc996d4edd2
6902303: G1: ScavengeALot should cause an incremental, rather than a full, collection
ysr
parents:
1045
diff
changeset
|
2904 // however, there is some additional state in the DPT which is |
3fc996d4edd2
6902303: G1: ScavengeALot should cause an incremental, rather than a full, collection
ysr
parents:
1045
diff
changeset
|
2905 // reset at the end of the (null) "gc" here via the following call. |
3fc996d4edd2
6902303: G1: ScavengeALot should cause an incremental, rather than a full, collection
ysr
parents:
1045
diff
changeset
|
2906 // A better approach might be to split off that state resetting work |
3fc996d4edd2
6902303: G1: ScavengeALot should cause an incremental, rather than a full, collection
ysr
parents:
1045
diff
changeset
|
2907 // into a separate method that asserts that the DPT is empty and call |
3fc996d4edd2
6902303: G1: ScavengeALot should cause an incremental, rather than a full, collection
ysr
parents:
1045
diff
changeset
|
2908 // that here. That is deferred for now. |
838
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2909 COMPILER2_PRESENT(DerivedPointerTable::update_pointers()); |
342 | 2910 } |
838
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2911 |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2912 if (evacuation_failed()) { |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2913 _summary_bytes_used = recalculate_used(); |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2914 } else { |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2915 // The "used" of the the collection set have already been subtracted |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2916 // when they were freed. Add in the bytes evacuated. |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2917 _summary_bytes_used += g1_policy()->bytes_in_to_space(); |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2918 } |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2919 |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2920 if (g1_policy()->in_young_gc_mode() && |
1359
23b1b27ac76c
6909756: G1: guarantee(G1CollectedHeap::heap()->mark_in_progress(),"Precondition.")
tonyp
parents:
1313
diff
changeset
|
2921 g1_policy()->during_initial_mark_pause()) { |
838
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2922 concurrent_mark()->checkpointRootsInitialPost(); |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2923 set_marking_started(); |
845
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
2924 // CAUTION: after the doConcurrentMark() call below, |
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
2925 // the concurrent marking thread(s) could be running |
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
2926 // concurrently with us. Make sure that anything after |
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
2927 // this point does not assume that we are the only GC thread |
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
2928 // running. Note: of course, the actual marking work will |
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
2929 // not start until the safepoint itself is released in |
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
2930 // ConcurrentGCThread::safepoint_desynchronize(). |
838
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2931 doConcurrentMark(); |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2932 } |
342 | 2933 |
1394
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
2934 #if YOUNG_LIST_VERBOSE |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
2935 gclog_or_tty->print_cr("\nEnd of the pause.\nYoung_list:"); |
838
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2936 _young_list->print(); |
1394
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
2937 g1_policy()->print_collection_set(g1_policy()->inc_cset_head(), gclog_or_tty); |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
2938 #endif // YOUNG_LIST_VERBOSE |
342 | 2939 |
838
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2940 double end_time_sec = os::elapsedTime(); |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2941 double pause_time_ms = (end_time_sec - start_time_sec) * MILLIUNITS; |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2942 g1_policy()->record_pause_time_ms(pause_time_ms); |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2943 g1_policy()->record_collection_pause_end(abandoned); |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2944 |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2945 assert(regions_accounted_for(), "Region leakage."); |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2946 |
1089
db0d5eba9d20
6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
1088
diff
changeset
|
2947 MemoryService::track_memory_usage(); |
db0d5eba9d20
6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
1088
diff
changeset
|
2948 |
838
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2949 if (VerifyAfterGC && total_collections() >= VerifyGCStartAt) { |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2950 HandleMark hm; // Discard invalid handles created during verification |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2951 gclog_or_tty->print(" VerifyAfterGC:"); |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2952 prepare_for_verify(); |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2953 Universe::verify(false); |
342 | 2954 } |
838
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2955 |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2956 if (was_enabled) ref_processor()->enable_discovery(); |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2957 |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2958 { |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2959 size_t expand_bytes = g1_policy()->expansion_amount(); |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2960 if (expand_bytes > 0) { |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2961 size_t bytes_before = capacity(); |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2962 expand(expand_bytes); |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2963 } |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2964 } |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2965 |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2966 if (mark_in_progress()) { |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2967 concurrent_mark()->update_g1_committed(); |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2968 } |
546
05c6d52fa7a9
6690928: Use spinning in combination with yields for workstealing termination.
jmasa
parents:
545
diff
changeset
|
2969 |
05c6d52fa7a9
6690928: Use spinning in combination with yields for workstealing termination.
jmasa
parents:
545
diff
changeset
|
2970 #ifdef TRACESPINNING |
838
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2971 ParallelTaskTerminator::print_termination_counts(); |
546
05c6d52fa7a9
6690928: Use spinning in combination with yields for workstealing termination.
jmasa
parents:
545
diff
changeset
|
2972 #endif |
342 | 2973 |
838
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2974 gc_epilogue(false); |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2975 } |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2976 |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2977 assert(verify_region_lists(), "Bad region lists."); |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2978 |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2979 if (ExitAfterGCNum > 0 && total_collections() == ExitAfterGCNum) { |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2980 gclog_or_tty->print_cr("Stopping after GC #%d", ExitAfterGCNum); |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2981 print_tracing_info(); |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2982 vm_exit(-1); |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2983 } |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2984 } |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2985 |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2986 if (PrintHeapAtGC) { |
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
2987 Universe::print_heap_after_gc(); |
342 | 2988 } |
884
83b687ce3090
6866591: G1: print update buffer processing stats more often
tonyp
parents:
883
diff
changeset
|
2989 if (G1SummarizeRSetStats && |
83b687ce3090
6866591: G1: print update buffer processing stats more often
tonyp
parents:
883
diff
changeset
|
2990 (G1SummarizeRSetStatsPeriod > 0) && |
83b687ce3090
6866591: G1: print update buffer processing stats more often
tonyp
parents:
883
diff
changeset
|
2991 (total_collections() % G1SummarizeRSetStatsPeriod == 0)) { |
83b687ce3090
6866591: G1: print update buffer processing stats more often
tonyp
parents:
883
diff
changeset
|
2992 g1_rem_set()->print_summary_info(); |
83b687ce3090
6866591: G1: print update buffer processing stats more often
tonyp
parents:
883
diff
changeset
|
2993 } |
342 | 2994 } |
2995 | |
1391
79e419e5ea3b
6942253: G1: replace G1ParallelGCAllocBufferSize with YoungPLABSize and OldPLABSize
apetrusenko
parents:
1390
diff
changeset
|
2996 size_t G1CollectedHeap::desired_plab_sz(GCAllocPurpose purpose) |
79e419e5ea3b
6942253: G1: replace G1ParallelGCAllocBufferSize with YoungPLABSize and OldPLABSize
apetrusenko
parents:
1390
diff
changeset
|
2997 { |
79e419e5ea3b
6942253: G1: replace G1ParallelGCAllocBufferSize with YoungPLABSize and OldPLABSize
apetrusenko
parents:
1390
diff
changeset
|
2998 size_t gclab_word_size; |
79e419e5ea3b
6942253: G1: replace G1ParallelGCAllocBufferSize with YoungPLABSize and OldPLABSize
apetrusenko
parents:
1390
diff
changeset
|
2999 switch (purpose) { |
79e419e5ea3b
6942253: G1: replace G1ParallelGCAllocBufferSize with YoungPLABSize and OldPLABSize
apetrusenko
parents:
1390
diff
changeset
|
3000 case GCAllocForSurvived: |
79e419e5ea3b
6942253: G1: replace G1ParallelGCAllocBufferSize with YoungPLABSize and OldPLABSize
apetrusenko
parents:
1390
diff
changeset
|
3001 gclab_word_size = YoungPLABSize; |
79e419e5ea3b
6942253: G1: replace G1ParallelGCAllocBufferSize with YoungPLABSize and OldPLABSize
apetrusenko
parents:
1390
diff
changeset
|
3002 break; |
79e419e5ea3b
6942253: G1: replace G1ParallelGCAllocBufferSize with YoungPLABSize and OldPLABSize
apetrusenko
parents:
1390
diff
changeset
|
3003 case GCAllocForTenured: |
79e419e5ea3b
6942253: G1: replace G1ParallelGCAllocBufferSize with YoungPLABSize and OldPLABSize
apetrusenko
parents:
1390
diff
changeset
|
3004 gclab_word_size = OldPLABSize; |
79e419e5ea3b
6942253: G1: replace G1ParallelGCAllocBufferSize with YoungPLABSize and OldPLABSize
apetrusenko
parents:
1390
diff
changeset
|
3005 break; |
79e419e5ea3b
6942253: G1: replace G1ParallelGCAllocBufferSize with YoungPLABSize and OldPLABSize
apetrusenko
parents:
1390
diff
changeset
|
3006 default: |
79e419e5ea3b
6942253: G1: replace G1ParallelGCAllocBufferSize with YoungPLABSize and OldPLABSize
apetrusenko
parents:
1390
diff
changeset
|
3007 assert(false, "unknown GCAllocPurpose"); |
79e419e5ea3b
6942253: G1: replace G1ParallelGCAllocBufferSize with YoungPLABSize and OldPLABSize
apetrusenko
parents:
1390
diff
changeset
|
3008 gclab_word_size = OldPLABSize; |
79e419e5ea3b
6942253: G1: replace G1ParallelGCAllocBufferSize with YoungPLABSize and OldPLABSize
apetrusenko
parents:
1390
diff
changeset
|
3009 break; |
79e419e5ea3b
6942253: G1: replace G1ParallelGCAllocBufferSize with YoungPLABSize and OldPLABSize
apetrusenko
parents:
1390
diff
changeset
|
3010 } |
79e419e5ea3b
6942253: G1: replace G1ParallelGCAllocBufferSize with YoungPLABSize and OldPLABSize
apetrusenko
parents:
1390
diff
changeset
|
3011 return gclab_word_size; |
79e419e5ea3b
6942253: G1: replace G1ParallelGCAllocBufferSize with YoungPLABSize and OldPLABSize
apetrusenko
parents:
1390
diff
changeset
|
3012 } |
79e419e5ea3b
6942253: G1: replace G1ParallelGCAllocBufferSize with YoungPLABSize and OldPLABSize
apetrusenko
parents:
1390
diff
changeset
|
3013 |
79e419e5ea3b
6942253: G1: replace G1ParallelGCAllocBufferSize with YoungPLABSize and OldPLABSize
apetrusenko
parents:
1390
diff
changeset
|
3014 |
342 | 3015 void G1CollectedHeap::set_gc_alloc_region(int purpose, HeapRegion* r) { |
3016 assert(purpose >= 0 && purpose < GCAllocPurposeCount, "invalid purpose"); | |
636 | 3017 // make sure we don't call set_gc_alloc_region() multiple times on |
3018 // the same region | |
3019 assert(r == NULL || !r->is_gc_alloc_region(), | |
3020 "shouldn't already be a GC alloc region"); | |
1360
bda703475ded
6940894: G1: assert(new_obj != 0 || ... "should be forwarded") for compaction tests
johnc
parents:
1359
diff
changeset
|
3021 assert(r == NULL || !r->isHumongous(), |
bda703475ded
6940894: G1: assert(new_obj != 0 || ... "should be forwarded") for compaction tests
johnc
parents:
1359
diff
changeset
|
3022 "humongous regions shouldn't be used as GC alloc regions"); |
bda703475ded
6940894: G1: assert(new_obj != 0 || ... "should be forwarded") for compaction tests
johnc
parents:
1359
diff
changeset
|
3023 |
342 | 3024 HeapWord* original_top = NULL; |
3025 if (r != NULL) | |
3026 original_top = r->top(); | |
3027 | |
3028 // We will want to record the used space in r as being there before gc. | |
3029 // One we install it as a GC alloc region it's eligible for allocation. | |
3030 // So record it now and use it later. | |
3031 size_t r_used = 0; | |
3032 if (r != NULL) { | |
3033 r_used = r->used(); | |
3034 | |
3035 if (ParallelGCThreads > 0) { | |
3036 // need to take the lock to guard against two threads calling | |
3037 // get_gc_alloc_region concurrently (very unlikely but...) | |
3038 MutexLockerEx x(ParGCRareEvent_lock, Mutex::_no_safepoint_check_flag); | |
3039 r->save_marks(); | |
3040 } | |
3041 } | |
3042 HeapRegion* old_alloc_region = _gc_alloc_regions[purpose]; | |
3043 _gc_alloc_regions[purpose] = r; | |
3044 if (old_alloc_region != NULL) { | |
3045 // Replace aliases too. | |
3046 for (int ap = 0; ap < GCAllocPurposeCount; ++ap) { | |
3047 if (_gc_alloc_regions[ap] == old_alloc_region) { | |
3048 _gc_alloc_regions[ap] = r; | |
3049 } | |
3050 } | |
3051 } | |
3052 if (r != NULL) { | |
3053 push_gc_alloc_region(r); | |
3054 if (mark_in_progress() && original_top != r->next_top_at_mark_start()) { | |
3055 // We are using a region as a GC alloc region after it has been used | |
3056 // as a mutator allocation region during the current marking cycle. | |
3057 // The mutator-allocated objects are currently implicitly marked, but | |
3058 // when we move hr->next_top_at_mark_start() forward at the the end | |
3059 // of the GC pause, they won't be. We therefore mark all objects in | |
3060 // the "gap". We do this object-by-object, since marking densely | |
3061 // does not currently work right with marking bitmap iteration. This | |
3062 // means we rely on TLAB filling at the start of pauses, and no | |
3063 // "resuscitation" of filled TLAB's. If we want to do this, we need | |
3064 // to fix the marking bitmap iteration. | |
3065 HeapWord* curhw = r->next_top_at_mark_start(); | |
3066 HeapWord* t = original_top; | |
3067 | |
3068 while (curhw < t) { | |
3069 oop cur = (oop)curhw; | |
3070 // We'll assume parallel for generality. This is rare code. | |
3071 concurrent_mark()->markAndGrayObjectIfNecessary(cur); // can't we just mark them? | |
3072 curhw = curhw + cur->size(); | |
3073 } | |
3074 assert(curhw == t, "Should have parsed correctly."); | |
3075 } | |
3076 if (G1PolicyVerbose > 1) { | |
3077 gclog_or_tty->print("New alloc region ["PTR_FORMAT", "PTR_FORMAT", " PTR_FORMAT") " | |
3078 "for survivors:", r->bottom(), original_top, r->end()); | |
3079 r->print(); | |
3080 } | |
3081 g1_policy()->record_before_bytes(r_used); | |
3082 } | |
3083 } | |
3084 | |
3085 void G1CollectedHeap::push_gc_alloc_region(HeapRegion* hr) { | |
3086 assert(Thread::current()->is_VM_thread() || | |
3087 par_alloc_during_gc_lock()->owned_by_self(), "Precondition"); | |
3088 assert(!hr->is_gc_alloc_region() && !hr->in_collection_set(), | |
3089 "Precondition."); | |
3090 hr->set_is_gc_alloc_region(true); | |
3091 hr->set_next_gc_alloc_region(_gc_alloc_region_list); | |
3092 _gc_alloc_region_list = hr; | |
3093 } | |
3094 | |
3095 #ifdef G1_DEBUG | |
3096 class FindGCAllocRegion: public HeapRegionClosure { | |
3097 public: | |
3098 bool doHeapRegion(HeapRegion* r) { | |
3099 if (r->is_gc_alloc_region()) { | |
3100 gclog_or_tty->print_cr("Region %d ["PTR_FORMAT"...] is still a gc_alloc_region.", | |
3101 r->hrs_index(), r->bottom()); | |
3102 } | |
3103 return false; | |
3104 } | |
3105 }; | |
3106 #endif // G1_DEBUG | |
3107 | |
3108 void G1CollectedHeap::forget_alloc_region_list() { | |
3109 assert(Thread::current()->is_VM_thread(), "Precondition"); | |
3110 while (_gc_alloc_region_list != NULL) { | |
3111 HeapRegion* r = _gc_alloc_region_list; | |
3112 assert(r->is_gc_alloc_region(), "Invariant."); | |
637
25e146966e7c
6817419: G1: Enable extensive verification for humongous regions
iveresov
parents:
636
diff
changeset
|
3113 // We need HeapRegion::oops_on_card_seq_iterate_careful() to work on |
25e146966e7c
6817419: G1: Enable extensive verification for humongous regions
iveresov
parents:
636
diff
changeset
|
3114 // newly allocated data in order to be able to apply deferred updates |
25e146966e7c
6817419: G1: Enable extensive verification for humongous regions
iveresov
parents:
636
diff
changeset
|
3115 // before the GC is done for verification purposes (i.e to allow |
25e146966e7c
6817419: G1: Enable extensive verification for humongous regions
iveresov
parents:
636
diff
changeset
|
3116 // G1HRRSFlushLogBuffersOnVerify). It's safe thing to do after the |
25e146966e7c
6817419: G1: Enable extensive verification for humongous regions
iveresov
parents:
636
diff
changeset
|
3117 // collection. |
25e146966e7c
6817419: G1: Enable extensive verification for humongous regions
iveresov
parents:
636
diff
changeset
|
3118 r->ContiguousSpace::set_saved_mark(); |
342 | 3119 _gc_alloc_region_list = r->next_gc_alloc_region(); |
3120 r->set_next_gc_alloc_region(NULL); | |
3121 r->set_is_gc_alloc_region(false); | |
545 | 3122 if (r->is_survivor()) { |
3123 if (r->is_empty()) { | |
3124 r->set_not_young(); | |
3125 } else { | |
3126 _young_list->add_survivor_region(r); | |
3127 } | |
3128 } | |
342 | 3129 if (r->is_empty()) { |
3130 ++_free_regions; | |
3131 } | |
3132 } | |
3133 #ifdef G1_DEBUG | |
3134 FindGCAllocRegion fa; | |
3135 heap_region_iterate(&fa); | |
3136 #endif // G1_DEBUG | |
3137 } | |
3138 | |
3139 | |
3140 bool G1CollectedHeap::check_gc_alloc_regions() { | |
3141 // TODO: allocation regions check | |
3142 return true; | |
3143 } | |
3144 | |
3145 void G1CollectedHeap::get_gc_alloc_regions() { | |
636 | 3146 // First, let's check that the GC alloc region list is empty (it should) |
3147 assert(_gc_alloc_region_list == NULL, "invariant"); | |
3148 | |
342 | 3149 for (int ap = 0; ap < GCAllocPurposeCount; ++ap) { |
636 | 3150 assert(_gc_alloc_regions[ap] == NULL, "invariant"); |
861
45d97a99715b
6862661: G1: _gc_alloc_region_counts is not updated properly after 6604422
apetrusenko
parents:
846
diff
changeset
|
3151 assert(_gc_alloc_region_counts[ap] == 0, "invariant"); |
636 | 3152 |
342 | 3153 // Create new GC alloc regions. |
636 | 3154 HeapRegion* alloc_region = _retained_gc_alloc_regions[ap]; |
3155 _retained_gc_alloc_regions[ap] = NULL; | |
3156 | |
3157 if (alloc_region != NULL) { | |
3158 assert(_retain_gc_alloc_region[ap], "only way to retain a GC region"); | |
3159 | |
3160 // let's make sure that the GC alloc region is not tagged as such | |
3161 // outside a GC operation | |
3162 assert(!alloc_region->is_gc_alloc_region(), "sanity"); | |
3163 | |
3164 if (alloc_region->in_collection_set() || | |
3165 alloc_region->top() == alloc_region->end() || | |
1360
bda703475ded
6940894: G1: assert(new_obj != 0 || ... "should be forwarded") for compaction tests
johnc
parents:
1359
diff
changeset
|
3166 alloc_region->top() == alloc_region->bottom() || |
bda703475ded
6940894: G1: assert(new_obj != 0 || ... "should be forwarded") for compaction tests
johnc
parents:
1359
diff
changeset
|
3167 alloc_region->isHumongous()) { |
bda703475ded
6940894: G1: assert(new_obj != 0 || ... "should be forwarded") for compaction tests
johnc
parents:
1359
diff
changeset
|
3168 // we will discard the current GC alloc region if |
bda703475ded
6940894: G1: assert(new_obj != 0 || ... "should be forwarded") for compaction tests
johnc
parents:
1359
diff
changeset
|
3169 // * it's in the collection set (it can happen!), |
bda703475ded
6940894: G1: assert(new_obj != 0 || ... "should be forwarded") for compaction tests
johnc
parents:
1359
diff
changeset
|
3170 // * it's already full (no point in using it), |
bda703475ded
6940894: G1: assert(new_obj != 0 || ... "should be forwarded") for compaction tests
johnc
parents:
1359
diff
changeset
|
3171 // * it's empty (this means that it was emptied during |
bda703475ded
6940894: G1: assert(new_obj != 0 || ... "should be forwarded") for compaction tests
johnc
parents:
1359
diff
changeset
|
3172 // a cleanup and it should be on the free list now), or |
bda703475ded
6940894: G1: assert(new_obj != 0 || ... "should be forwarded") for compaction tests
johnc
parents:
1359
diff
changeset
|
3173 // * it's humongous (this means that it was emptied |
bda703475ded
6940894: G1: assert(new_obj != 0 || ... "should be forwarded") for compaction tests
johnc
parents:
1359
diff
changeset
|
3174 // during a cleanup and was added to the free list, but |
bda703475ded
6940894: G1: assert(new_obj != 0 || ... "should be forwarded") for compaction tests
johnc
parents:
1359
diff
changeset
|
3175 // has been subseqently used to allocate a humongous |
bda703475ded
6940894: G1: assert(new_obj != 0 || ... "should be forwarded") for compaction tests
johnc
parents:
1359
diff
changeset
|
3176 // object that may be less than the region size). |
636 | 3177 |
3178 alloc_region = NULL; | |
3179 } | |
3180 } | |
3181 | |
3182 if (alloc_region == NULL) { | |
3183 // we will get a new GC alloc region | |
342 | 3184 alloc_region = newAllocRegionWithExpansion(ap, 0); |
861
45d97a99715b
6862661: G1: _gc_alloc_region_counts is not updated properly after 6604422
apetrusenko
parents:
846
diff
changeset
|
3185 } else { |
45d97a99715b
6862661: G1: _gc_alloc_region_counts is not updated properly after 6604422
apetrusenko
parents:
846
diff
changeset
|
3186 // the region was retained from the last collection |
45d97a99715b
6862661: G1: _gc_alloc_region_counts is not updated properly after 6604422
apetrusenko
parents:
846
diff
changeset
|
3187 ++_gc_alloc_region_counts[ap]; |
1388 | 3188 if (G1PrintHeapRegions) { |
3189 gclog_or_tty->print_cr("new alloc region %d:["PTR_FORMAT", "PTR_FORMAT"], " | |
3190 "top "PTR_FORMAT, | |
3191 alloc_region->hrs_index(), alloc_region->bottom(), alloc_region->end(), alloc_region->top()); | |
3192 } | |
342 | 3193 } |
636 | 3194 |
342 | 3195 if (alloc_region != NULL) { |
636 | 3196 assert(_gc_alloc_regions[ap] == NULL, "pre-condition"); |
342 | 3197 set_gc_alloc_region(ap, alloc_region); |
3198 } | |
636 | 3199 |
3200 assert(_gc_alloc_regions[ap] == NULL || | |
3201 _gc_alloc_regions[ap]->is_gc_alloc_region(), | |
3202 "the GC alloc region should be tagged as such"); | |
3203 assert(_gc_alloc_regions[ap] == NULL || | |
3204 _gc_alloc_regions[ap] == _gc_alloc_region_list, | |
3205 "the GC alloc region should be the same as the GC alloc list head"); | |
342 | 3206 } |
3207 // Set alternative regions for allocation purposes that have reached | |
636 | 3208 // their limit. |
342 | 3209 for (int ap = 0; ap < GCAllocPurposeCount; ++ap) { |
3210 GCAllocPurpose alt_purpose = g1_policy()->alternative_purpose(ap); | |
3211 if (_gc_alloc_regions[ap] == NULL && alt_purpose != ap) { | |
3212 _gc_alloc_regions[ap] = _gc_alloc_regions[alt_purpose]; | |
3213 } | |
3214 } | |
3215 assert(check_gc_alloc_regions(), "alloc regions messed up"); | |
3216 } | |
3217 | |
636 | 3218 void G1CollectedHeap::release_gc_alloc_regions(bool totally) { |
342 | 3219 // We keep a separate list of all regions that have been alloc regions in |
636 | 3220 // the current collection pause. Forget that now. This method will |
3221 // untag the GC alloc regions and tear down the GC alloc region | |
3222 // list. It's desirable that no regions are tagged as GC alloc | |
3223 // outside GCs. | |
342 | 3224 forget_alloc_region_list(); |
3225 | |
3226 // The current alloc regions contain objs that have survived | |
3227 // collection. Make them no longer GC alloc regions. | |
3228 for (int ap = 0; ap < GCAllocPurposeCount; ++ap) { | |
3229 HeapRegion* r = _gc_alloc_regions[ap]; | |
636 | 3230 _retained_gc_alloc_regions[ap] = NULL; |
861
45d97a99715b
6862661: G1: _gc_alloc_region_counts is not updated properly after 6604422
apetrusenko
parents:
846
diff
changeset
|
3231 _gc_alloc_region_counts[ap] = 0; |
636 | 3232 |
3233 if (r != NULL) { | |
3234 // we retain nothing on _gc_alloc_regions between GCs | |
3235 set_gc_alloc_region(ap, NULL); | |
3236 | |
3237 if (r->is_empty()) { | |
3238 // we didn't actually allocate anything in it; let's just put | |
3239 // it on the free list | |
342 | 3240 MutexLockerEx x(ZF_mon, Mutex::_no_safepoint_check_flag); |
3241 r->set_zero_fill_complete(); | |
3242 put_free_region_on_list_locked(r); | |
636 | 3243 } else if (_retain_gc_alloc_region[ap] && !totally) { |
3244 // retain it so that we can use it at the beginning of the next GC | |
3245 _retained_gc_alloc_regions[ap] = r; | |
342 | 3246 } |
3247 } | |
636 | 3248 } |
3249 } | |
3250 | |
3251 #ifndef PRODUCT | |
3252 // Useful for debugging | |
3253 | |
3254 void G1CollectedHeap::print_gc_alloc_regions() { | |
3255 gclog_or_tty->print_cr("GC alloc regions"); | |
3256 for (int ap = 0; ap < GCAllocPurposeCount; ++ap) { | |
3257 HeapRegion* r = _gc_alloc_regions[ap]; | |
3258 if (r == NULL) { | |
3259 gclog_or_tty->print_cr(" %2d : "PTR_FORMAT, ap, NULL); | |
3260 } else { | |
3261 gclog_or_tty->print_cr(" %2d : "PTR_FORMAT" "SIZE_FORMAT, | |
3262 ap, r->bottom(), r->used()); | |
3263 } | |
3264 } | |
3265 } | |
3266 #endif // PRODUCT | |
342 | 3267 |
3268 void G1CollectedHeap::init_for_evac_failure(OopsInHeapRegionClosure* cl) { | |
3269 _drain_in_progress = false; | |
3270 set_evac_failure_closure(cl); | |
3271 _evac_failure_scan_stack = new (ResourceObj::C_HEAP) GrowableArray<oop>(40, true); | |
3272 } | |
3273 | |
3274 void G1CollectedHeap::finalize_for_evac_failure() { | |
3275 assert(_evac_failure_scan_stack != NULL && | |
3276 _evac_failure_scan_stack->length() == 0, | |
3277 "Postcondition"); | |
3278 assert(!_drain_in_progress, "Postcondition"); | |
1045 | 3279 delete _evac_failure_scan_stack; |
342 | 3280 _evac_failure_scan_stack = NULL; |
3281 } | |
3282 | |
3283 | |
3284 | |
3285 // *** Sequential G1 Evacuation | |
3286 | |
3287 HeapWord* G1CollectedHeap::allocate_during_gc(GCAllocPurpose purpose, size_t word_size) { | |
3288 HeapRegion* alloc_region = _gc_alloc_regions[purpose]; | |
3289 // let the caller handle alloc failure | |
3290 if (alloc_region == NULL) return NULL; | |
3291 assert(isHumongous(word_size) || !alloc_region->isHumongous(), | |
3292 "Either the object is humongous or the region isn't"); | |
3293 HeapWord* block = alloc_region->allocate(word_size); | |
3294 if (block == NULL) { | |
3295 block = allocate_during_gc_slow(purpose, alloc_region, false, word_size); | |
3296 } | |
3297 return block; | |
3298 } | |
3299 | |
3300 class G1IsAliveClosure: public BoolObjectClosure { | |
3301 G1CollectedHeap* _g1; | |
3302 public: | |
3303 G1IsAliveClosure(G1CollectedHeap* g1) : _g1(g1) {} | |
3304 void do_object(oop p) { assert(false, "Do not call."); } | |
3305 bool do_object_b(oop p) { | |
3306 // It is reachable if it is outside the collection set, or is inside | |
3307 // and forwarded. | |
3308 | |
3309 #ifdef G1_DEBUG | |
3310 gclog_or_tty->print_cr("is alive "PTR_FORMAT" in CS %d forwarded %d overall %d", | |
3311 (void*) p, _g1->obj_in_cs(p), p->is_forwarded(), | |
3312 !_g1->obj_in_cs(p) || p->is_forwarded()); | |
3313 #endif // G1_DEBUG | |
3314 | |
3315 return !_g1->obj_in_cs(p) || p->is_forwarded(); | |
3316 } | |
3317 }; | |
3318 | |
3319 class G1KeepAliveClosure: public OopClosure { | |
3320 G1CollectedHeap* _g1; | |
3321 public: | |
3322 G1KeepAliveClosure(G1CollectedHeap* g1) : _g1(g1) {} | |
845
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
3323 void do_oop(narrowOop* p) { guarantee(false, "Not needed"); } |
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
3324 void do_oop( oop* p) { |
342 | 3325 oop obj = *p; |
3326 #ifdef G1_DEBUG | |
3327 if (PrintGC && Verbose) { | |
3328 gclog_or_tty->print_cr("keep alive *"PTR_FORMAT" = "PTR_FORMAT" "PTR_FORMAT, | |
3329 p, (void*) obj, (void*) *p); | |
3330 } | |
3331 #endif // G1_DEBUG | |
3332 | |
3333 if (_g1->obj_in_cs(obj)) { | |
3334 assert( obj->is_forwarded(), "invariant" ); | |
3335 *p = obj->forwardee(); | |
3336 #ifdef G1_DEBUG | |
3337 gclog_or_tty->print_cr(" in CSet: moved "PTR_FORMAT" -> "PTR_FORMAT, | |
3338 (void*) obj, (void*) *p); | |
3339 #endif // G1_DEBUG | |
3340 } | |
3341 } | |
3342 }; | |
3343 | |
616
4f360ec815ba
6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents:
595
diff
changeset
|
3344 class UpdateRSetImmediate : public OopsInHeapRegionClosure { |
342 | 3345 private: |
3346 G1CollectedHeap* _g1; | |
3347 G1RemSet* _g1_rem_set; | |
3348 public: | |
616
4f360ec815ba
6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents:
595
diff
changeset
|
3349 UpdateRSetImmediate(G1CollectedHeap* g1) : |
4f360ec815ba
6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents:
595
diff
changeset
|
3350 _g1(g1), _g1_rem_set(g1->g1_rem_set()) {} |
342 | 3351 |
845
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
3352 virtual void do_oop(narrowOop* p) { do_oop_work(p); } |
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
3353 virtual void do_oop( oop* p) { do_oop_work(p); } |
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
3354 template <class T> void do_oop_work(T* p) { |
342 | 3355 assert(_from->is_in_reserved(p), "paranoia"); |
845
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
3356 T heap_oop = oopDesc::load_heap_oop(p); |
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
3357 if (!oopDesc::is_null(heap_oop) && !_from->is_survivor()) { |
616
4f360ec815ba
6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents:
595
diff
changeset
|
3358 _g1_rem_set->par_write_ref(_from, p, 0); |
342 | 3359 } |
3360 } | |
3361 }; | |
3362 | |
616
4f360ec815ba
6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents:
595
diff
changeset
|
3363 class UpdateRSetDeferred : public OopsInHeapRegionClosure { |
4f360ec815ba
6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents:
595
diff
changeset
|
3364 private: |
4f360ec815ba
6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents:
595
diff
changeset
|
3365 G1CollectedHeap* _g1; |
4f360ec815ba
6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents:
595
diff
changeset
|
3366 DirtyCardQueue *_dcq; |
4f360ec815ba
6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents:
595
diff
changeset
|
3367 CardTableModRefBS* _ct_bs; |
4f360ec815ba
6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents:
595
diff
changeset
|
3368 |
4f360ec815ba
6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents:
595
diff
changeset
|
3369 public: |
4f360ec815ba
6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents:
595
diff
changeset
|
3370 UpdateRSetDeferred(G1CollectedHeap* g1, DirtyCardQueue* dcq) : |
4f360ec815ba
6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents:
595
diff
changeset
|
3371 _g1(g1), _ct_bs((CardTableModRefBS*)_g1->barrier_set()), _dcq(dcq) {} |
4f360ec815ba
6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents:
595
diff
changeset
|
3372 |
845
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
3373 virtual void do_oop(narrowOop* p) { do_oop_work(p); } |
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
3374 virtual void do_oop( oop* p) { do_oop_work(p); } |
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
3375 template <class T> void do_oop_work(T* p) { |
616
4f360ec815ba
6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents:
595
diff
changeset
|
3376 assert(_from->is_in_reserved(p), "paranoia"); |
845
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
3377 if (!_from->is_in_reserved(oopDesc::load_decode_heap_oop(p)) && |
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
3378 !_from->is_survivor()) { |
616
4f360ec815ba
6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents:
595
diff
changeset
|
3379 size_t card_index = _ct_bs->index_for(p); |
4f360ec815ba
6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents:
595
diff
changeset
|
3380 if (_ct_bs->mark_card_deferred(card_index)) { |
4f360ec815ba
6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents:
595
diff
changeset
|
3381 _dcq->enqueue((jbyte*)_ct_bs->byte_for_index(card_index)); |
4f360ec815ba
6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents:
595
diff
changeset
|
3382 } |
4f360ec815ba
6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents:
595
diff
changeset
|
3383 } |
4f360ec815ba
6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents:
595
diff
changeset
|
3384 } |
4f360ec815ba
6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents:
595
diff
changeset
|
3385 }; |
4f360ec815ba
6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents:
595
diff
changeset
|
3386 |
4f360ec815ba
6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents:
595
diff
changeset
|
3387 |
4f360ec815ba
6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents:
595
diff
changeset
|
3388 |
342 | 3389 class RemoveSelfPointerClosure: public ObjectClosure { |
3390 private: | |
3391 G1CollectedHeap* _g1; | |
3392 ConcurrentMark* _cm; | |
3393 HeapRegion* _hr; | |
3394 size_t _prev_marked_bytes; | |
3395 size_t _next_marked_bytes; | |
616
4f360ec815ba
6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents:
595
diff
changeset
|
3396 OopsInHeapRegionClosure *_cl; |
342 | 3397 public: |
616
4f360ec815ba
6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents:
595
diff
changeset
|
3398 RemoveSelfPointerClosure(G1CollectedHeap* g1, OopsInHeapRegionClosure* cl) : |
4f360ec815ba
6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents:
595
diff
changeset
|
3399 _g1(g1), _cm(_g1->concurrent_mark()), _prev_marked_bytes(0), |
4f360ec815ba
6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents:
595
diff
changeset
|
3400 _next_marked_bytes(0), _cl(cl) {} |
342 | 3401 |
3402 size_t prev_marked_bytes() { return _prev_marked_bytes; } | |
3403 size_t next_marked_bytes() { return _next_marked_bytes; } | |
3404 | |
352
e0c09f7ec5c4
6702387: G1: assertion failure: assert(p == current_top || oop(p)->is_oop(),"p is not a block start")
iveresov
parents:
342
diff
changeset
|
3405 // The original idea here was to coalesce evacuated and dead objects. |
e0c09f7ec5c4
6702387: G1: assertion failure: assert(p == current_top || oop(p)->is_oop(),"p is not a block start")
iveresov
parents:
342
diff
changeset
|
3406 // However that caused complications with the block offset table (BOT). |
e0c09f7ec5c4
6702387: G1: assertion failure: assert(p == current_top || oop(p)->is_oop(),"p is not a block start")
iveresov
parents:
342
diff
changeset
|
3407 // In particular if there were two TLABs, one of them partially refined. |
e0c09f7ec5c4
6702387: G1: assertion failure: assert(p == current_top || oop(p)->is_oop(),"p is not a block start")
iveresov
parents:
342
diff
changeset
|
3408 // |----- TLAB_1--------|----TLAB_2-~~~(partially refined part)~~~| |
e0c09f7ec5c4
6702387: G1: assertion failure: assert(p == current_top || oop(p)->is_oop(),"p is not a block start")
iveresov
parents:
342
diff
changeset
|
3409 // The BOT entries of the unrefined part of TLAB_2 point to the start |
e0c09f7ec5c4
6702387: G1: assertion failure: assert(p == current_top || oop(p)->is_oop(),"p is not a block start")
iveresov
parents:
342
diff
changeset
|
3410 // of TLAB_2. If the last object of the TLAB_1 and the first object |
e0c09f7ec5c4
6702387: G1: assertion failure: assert(p == current_top || oop(p)->is_oop(),"p is not a block start")
iveresov
parents:
342
diff
changeset
|
3411 // of TLAB_2 are coalesced, then the cards of the unrefined part |
e0c09f7ec5c4
6702387: G1: assertion failure: assert(p == current_top || oop(p)->is_oop(),"p is not a block start")
iveresov
parents:
342
diff
changeset
|
3412 // would point into middle of the filler object. |
e0c09f7ec5c4
6702387: G1: assertion failure: assert(p == current_top || oop(p)->is_oop(),"p is not a block start")
iveresov
parents:
342
diff
changeset
|
3413 // |
e0c09f7ec5c4
6702387: G1: assertion failure: assert(p == current_top || oop(p)->is_oop(),"p is not a block start")
iveresov
parents:
342
diff
changeset
|
3414 // The current approach is to not coalesce and leave the BOT contents intact. |
e0c09f7ec5c4
6702387: G1: assertion failure: assert(p == current_top || oop(p)->is_oop(),"p is not a block start")
iveresov
parents:
342
diff
changeset
|
3415 void do_object(oop obj) { |
e0c09f7ec5c4
6702387: G1: assertion failure: assert(p == current_top || oop(p)->is_oop(),"p is not a block start")
iveresov
parents:
342
diff
changeset
|
3416 if (obj->is_forwarded() && obj->forwardee() == obj) { |
e0c09f7ec5c4
6702387: G1: assertion failure: assert(p == current_top || oop(p)->is_oop(),"p is not a block start")
iveresov
parents:
342
diff
changeset
|
3417 // The object failed to move. |
e0c09f7ec5c4
6702387: G1: assertion failure: assert(p == current_top || oop(p)->is_oop(),"p is not a block start")
iveresov
parents:
342
diff
changeset
|
3418 assert(!_g1->is_obj_dead(obj), "We should not be preserving dead objs."); |
e0c09f7ec5c4
6702387: G1: assertion failure: assert(p == current_top || oop(p)->is_oop(),"p is not a block start")
iveresov
parents:
342
diff
changeset
|
3419 _cm->markPrev(obj); |
e0c09f7ec5c4
6702387: G1: assertion failure: assert(p == current_top || oop(p)->is_oop(),"p is not a block start")
iveresov
parents:
342
diff
changeset
|
3420 assert(_cm->isPrevMarked(obj), "Should be marked!"); |
e0c09f7ec5c4
6702387: G1: assertion failure: assert(p == current_top || oop(p)->is_oop(),"p is not a block start")
iveresov
parents:
342
diff
changeset
|
3421 _prev_marked_bytes += (obj->size() * HeapWordSize); |
e0c09f7ec5c4
6702387: G1: assertion failure: assert(p == current_top || oop(p)->is_oop(),"p is not a block start")
iveresov
parents:
342
diff
changeset
|
3422 if (_g1->mark_in_progress() && !_g1->is_obj_ill(obj)) { |
e0c09f7ec5c4
6702387: G1: assertion failure: assert(p == current_top || oop(p)->is_oop(),"p is not a block start")
iveresov
parents:
342
diff
changeset
|
3423 _cm->markAndGrayObjectIfNecessary(obj); |
e0c09f7ec5c4
6702387: G1: assertion failure: assert(p == current_top || oop(p)->is_oop(),"p is not a block start")
iveresov
parents:
342
diff
changeset
|
3424 } |
e0c09f7ec5c4
6702387: G1: assertion failure: assert(p == current_top || oop(p)->is_oop(),"p is not a block start")
iveresov
parents:
342
diff
changeset
|
3425 obj->set_mark(markOopDesc::prototype()); |
e0c09f7ec5c4
6702387: G1: assertion failure: assert(p == current_top || oop(p)->is_oop(),"p is not a block start")
iveresov
parents:
342
diff
changeset
|
3426 // While we were processing RSet buffers during the |
e0c09f7ec5c4
6702387: G1: assertion failure: assert(p == current_top || oop(p)->is_oop(),"p is not a block start")
iveresov
parents:
342
diff
changeset
|
3427 // collection, we actually didn't scan any cards on the |
e0c09f7ec5c4
6702387: G1: assertion failure: assert(p == current_top || oop(p)->is_oop(),"p is not a block start")
iveresov
parents:
342
diff
changeset
|
3428 // collection set, since we didn't want to update remebered |
e0c09f7ec5c4
6702387: G1: assertion failure: assert(p == current_top || oop(p)->is_oop(),"p is not a block start")
iveresov
parents:
342
diff
changeset
|
3429 // sets with entries that point into the collection set, given |
e0c09f7ec5c4
6702387: G1: assertion failure: assert(p == current_top || oop(p)->is_oop(),"p is not a block start")
iveresov
parents:
342
diff
changeset
|
3430 // that live objects fromthe collection set are about to move |
e0c09f7ec5c4
6702387: G1: assertion failure: assert(p == current_top || oop(p)->is_oop(),"p is not a block start")
iveresov
parents:
342
diff
changeset
|
3431 // and such entries will be stale very soon. This change also |
e0c09f7ec5c4
6702387: G1: assertion failure: assert(p == current_top || oop(p)->is_oop(),"p is not a block start")
iveresov
parents:
342
diff
changeset
|
3432 // dealt with a reliability issue which involved scanning a |
e0c09f7ec5c4
6702387: G1: assertion failure: assert(p == current_top || oop(p)->is_oop(),"p is not a block start")
iveresov
parents:
342
diff
changeset
|
3433 // card in the collection set and coming across an array that |
e0c09f7ec5c4
6702387: G1: assertion failure: assert(p == current_top || oop(p)->is_oop(),"p is not a block start")
iveresov
parents:
342
diff
changeset
|
3434 // was being chunked and looking malformed. The problem is |
e0c09f7ec5c4
6702387: G1: assertion failure: assert(p == current_top || oop(p)->is_oop(),"p is not a block start")
iveresov
parents:
342
diff
changeset
|
3435 // that, if evacuation fails, we might have remembered set |
e0c09f7ec5c4
6702387: G1: assertion failure: assert(p == current_top || oop(p)->is_oop(),"p is not a block start")
iveresov
parents:
342
diff
changeset
|
3436 // entries missing given that we skipped cards on the |
e0c09f7ec5c4
6702387: G1: assertion failure: assert(p == current_top || oop(p)->is_oop(),"p is not a block start")
iveresov
parents:
342
diff
changeset
|
3437 // collection set. So, we'll recreate such entries now. |
616
4f360ec815ba
6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents:
595
diff
changeset
|
3438 obj->oop_iterate(_cl); |
352
e0c09f7ec5c4
6702387: G1: assertion failure: assert(p == current_top || oop(p)->is_oop(),"p is not a block start")
iveresov
parents:
342
diff
changeset
|
3439 assert(_cm->isPrevMarked(obj), "Should be marked!"); |
e0c09f7ec5c4
6702387: G1: assertion failure: assert(p == current_top || oop(p)->is_oop(),"p is not a block start")
iveresov
parents:
342
diff
changeset
|
3440 } else { |
e0c09f7ec5c4
6702387: G1: assertion failure: assert(p == current_top || oop(p)->is_oop(),"p is not a block start")
iveresov
parents:
342
diff
changeset
|
3441 // The object has been either evacuated or is dead. Fill it with a |
e0c09f7ec5c4
6702387: G1: assertion failure: assert(p == current_top || oop(p)->is_oop(),"p is not a block start")
iveresov
parents:
342
diff
changeset
|
3442 // dummy object. |
e0c09f7ec5c4
6702387: G1: assertion failure: assert(p == current_top || oop(p)->is_oop(),"p is not a block start")
iveresov
parents:
342
diff
changeset
|
3443 MemRegion mr((HeapWord*)obj, obj->size()); |
481
7d7a7c599c17
6578152: fill_region_with_object has usability and safety issues
jcoomes
parents:
457
diff
changeset
|
3444 CollectedHeap::fill_with_object(mr); |
342 | 3445 _cm->clearRangeBothMaps(mr); |
3446 } | |
3447 } | |
3448 }; | |
3449 | |
3450 void G1CollectedHeap::remove_self_forwarding_pointers() { | |
616
4f360ec815ba
6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents:
595
diff
changeset
|
3451 UpdateRSetImmediate immediate_update(_g1h); |
4f360ec815ba
6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents:
595
diff
changeset
|
3452 DirtyCardQueue dcq(&_g1h->dirty_card_queue_set()); |
4f360ec815ba
6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents:
595
diff
changeset
|
3453 UpdateRSetDeferred deferred_update(_g1h, &dcq); |
4f360ec815ba
6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents:
595
diff
changeset
|
3454 OopsInHeapRegionClosure *cl; |
4f360ec815ba
6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents:
595
diff
changeset
|
3455 if (G1DeferredRSUpdate) { |
4f360ec815ba
6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents:
595
diff
changeset
|
3456 cl = &deferred_update; |
4f360ec815ba
6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents:
595
diff
changeset
|
3457 } else { |
4f360ec815ba
6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents:
595
diff
changeset
|
3458 cl = &immediate_update; |
4f360ec815ba
6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents:
595
diff
changeset
|
3459 } |
342 | 3460 HeapRegion* cur = g1_policy()->collection_set(); |
3461 while (cur != NULL) { | |
3462 assert(g1_policy()->assertMarkedBytesDataOK(), "Should be!"); | |
3463 | |
616
4f360ec815ba
6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents:
595
diff
changeset
|
3464 RemoveSelfPointerClosure rspc(_g1h, cl); |
342 | 3465 if (cur->evacuation_failed()) { |
3466 assert(cur->in_collection_set(), "bad CS"); | |
616
4f360ec815ba
6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents:
595
diff
changeset
|
3467 cl->set_region(cur); |
342 | 3468 cur->object_iterate(&rspc); |
3469 | |
3470 // A number of manipulations to make the TAMS be the current top, | |
3471 // and the marked bytes be the ones observed in the iteration. | |
3472 if (_g1h->concurrent_mark()->at_least_one_mark_complete()) { | |
3473 // The comments below are the postconditions achieved by the | |
3474 // calls. Note especially the last such condition, which says that | |
3475 // the count of marked bytes has been properly restored. | |
3476 cur->note_start_of_marking(false); | |
3477 // _next_top_at_mark_start == top, _next_marked_bytes == 0 | |
3478 cur->add_to_marked_bytes(rspc.prev_marked_bytes()); | |
3479 // _next_marked_bytes == prev_marked_bytes. | |
3480 cur->note_end_of_marking(); | |
3481 // _prev_top_at_mark_start == top(), | |
3482 // _prev_marked_bytes == prev_marked_bytes | |
3483 } | |
3484 // If there is no mark in progress, we modified the _next variables | |
3485 // above needlessly, but harmlessly. | |
3486 if (_g1h->mark_in_progress()) { | |
3487 cur->note_start_of_marking(false); | |
3488 // _next_top_at_mark_start == top, _next_marked_bytes == 0 | |
3489 // _next_marked_bytes == next_marked_bytes. | |
3490 } | |
3491 | |
3492 // Now make sure the region has the right index in the sorted array. | |
3493 g1_policy()->note_change_in_marked_bytes(cur); | |
3494 } | |
3495 cur = cur->next_in_collection_set(); | |
3496 } | |
3497 assert(g1_policy()->assertMarkedBytesDataOK(), "Should be!"); | |
3498 | |
3499 // Now restore saved marks, if any. | |
3500 if (_objs_with_preserved_marks != NULL) { | |
3501 assert(_preserved_marks_of_objs != NULL, "Both or none."); | |
3502 assert(_objs_with_preserved_marks->length() == | |
3503 _preserved_marks_of_objs->length(), "Both or none."); | |
3504 guarantee(_objs_with_preserved_marks->length() == | |
3505 _preserved_marks_of_objs->length(), "Both or none."); | |
3506 for (int i = 0; i < _objs_with_preserved_marks->length(); i++) { | |
3507 oop obj = _objs_with_preserved_marks->at(i); | |
3508 markOop m = _preserved_marks_of_objs->at(i); | |
3509 obj->set_mark(m); | |
3510 } | |
3511 // Delete the preserved marks growable arrays (allocated on the C heap). | |
3512 delete _objs_with_preserved_marks; | |
3513 delete _preserved_marks_of_objs; | |
3514 _objs_with_preserved_marks = NULL; | |
3515 _preserved_marks_of_objs = NULL; | |
3516 } | |
3517 } | |
3518 | |
3519 void G1CollectedHeap::push_on_evac_failure_scan_stack(oop obj) { | |
3520 _evac_failure_scan_stack->push(obj); | |
3521 } | |
3522 | |
3523 void G1CollectedHeap::drain_evac_failure_scan_stack() { | |
3524 assert(_evac_failure_scan_stack != NULL, "precondition"); | |
3525 | |
3526 while (_evac_failure_scan_stack->length() > 0) { | |
3527 oop obj = _evac_failure_scan_stack->pop(); | |
3528 _evac_failure_closure->set_region(heap_region_containing(obj)); | |
3529 obj->oop_iterate_backwards(_evac_failure_closure); | |
3530 } | |
3531 } | |
3532 | |
3533 void G1CollectedHeap::handle_evacuation_failure(oop old) { | |
3534 markOop m = old->mark(); | |
3535 // forward to self | |
3536 assert(!old->is_forwarded(), "precondition"); | |
3537 | |
3538 old->forward_to(old); | |
3539 handle_evacuation_failure_common(old, m); | |
3540 } | |
3541 | |
3542 oop | |
3543 G1CollectedHeap::handle_evacuation_failure_par(OopsInHeapRegionClosure* cl, | |
3544 oop old) { | |
3545 markOop m = old->mark(); | |
3546 oop forward_ptr = old->forward_to_atomic(old); | |
3547 if (forward_ptr == NULL) { | |
3548 // Forward-to-self succeeded. | |
3549 if (_evac_failure_closure != cl) { | |
3550 MutexLockerEx x(EvacFailureStack_lock, Mutex::_no_safepoint_check_flag); | |
3551 assert(!_drain_in_progress, | |
3552 "Should only be true while someone holds the lock."); | |
3553 // Set the global evac-failure closure to the current thread's. | |
3554 assert(_evac_failure_closure == NULL, "Or locking has failed."); | |
3555 set_evac_failure_closure(cl); | |
3556 // Now do the common part. | |
3557 handle_evacuation_failure_common(old, m); | |
3558 // Reset to NULL. | |
3559 set_evac_failure_closure(NULL); | |
3560 } else { | |
3561 // The lock is already held, and this is recursive. | |
3562 assert(_drain_in_progress, "This should only be the recursive case."); | |
3563 handle_evacuation_failure_common(old, m); | |
3564 } | |
3565 return old; | |
3566 } else { | |
3567 // Someone else had a place to copy it. | |
3568 return forward_ptr; | |
3569 } | |
3570 } | |
3571 | |
3572 void G1CollectedHeap::handle_evacuation_failure_common(oop old, markOop m) { | |
3573 set_evacuation_failed(true); | |
3574 | |
3575 preserve_mark_if_necessary(old, m); | |
3576 | |
3577 HeapRegion* r = heap_region_containing(old); | |
3578 if (!r->evacuation_failed()) { | |
3579 r->set_evacuation_failed(true); | |
1282 | 3580 if (G1PrintHeapRegions) { |
342 | 3581 gclog_or_tty->print("evacuation failed in heap region "PTR_FORMAT" " |
3582 "["PTR_FORMAT","PTR_FORMAT")\n", | |
3583 r, r->bottom(), r->end()); | |
3584 } | |
3585 } | |
3586 | |
3587 push_on_evac_failure_scan_stack(old); | |
3588 | |
3589 if (!_drain_in_progress) { | |
3590 // prevent recursion in copy_to_survivor_space() | |
3591 _drain_in_progress = true; | |
3592 drain_evac_failure_scan_stack(); | |
3593 _drain_in_progress = false; | |
3594 } | |
3595 } | |
3596 | |
3597 void G1CollectedHeap::preserve_mark_if_necessary(oop obj, markOop m) { | |
3598 if (m != markOopDesc::prototype()) { | |
3599 if (_objs_with_preserved_marks == NULL) { | |
3600 assert(_preserved_marks_of_objs == NULL, "Both or none."); | |
3601 _objs_with_preserved_marks = | |
3602 new (ResourceObj::C_HEAP) GrowableArray<oop>(40, true); | |
3603 _preserved_marks_of_objs = | |
3604 new (ResourceObj::C_HEAP) GrowableArray<markOop>(40, true); | |
3605 } | |
3606 _objs_with_preserved_marks->push(obj); | |
3607 _preserved_marks_of_objs->push(m); | |
3608 } | |
3609 } | |
3610 | |
3611 // *** Parallel G1 Evacuation | |
3612 | |
3613 HeapWord* G1CollectedHeap::par_allocate_during_gc(GCAllocPurpose purpose, | |
3614 size_t word_size) { | |
3615 HeapRegion* alloc_region = _gc_alloc_regions[purpose]; | |
3616 // let the caller handle alloc failure | |
3617 if (alloc_region == NULL) return NULL; | |
3618 | |
3619 HeapWord* block = alloc_region->par_allocate(word_size); | |
3620 if (block == NULL) { | |
3621 MutexLockerEx x(par_alloc_during_gc_lock(), | |
3622 Mutex::_no_safepoint_check_flag); | |
3623 block = allocate_during_gc_slow(purpose, alloc_region, true, word_size); | |
3624 } | |
3625 return block; | |
3626 } | |
3627 | |
545 | 3628 void G1CollectedHeap::retire_alloc_region(HeapRegion* alloc_region, |
3629 bool par) { | |
3630 // Another thread might have obtained alloc_region for the given | |
3631 // purpose, and might be attempting to allocate in it, and might | |
3632 // succeed. Therefore, we can't do the "finalization" stuff on the | |
3633 // region below until we're sure the last allocation has happened. | |
3634 // We ensure this by allocating the remaining space with a garbage | |
3635 // object. | |
3636 if (par) par_allocate_remaining_space(alloc_region); | |
3637 // Now we can do the post-GC stuff on the region. | |
3638 alloc_region->note_end_of_copying(); | |
3639 g1_policy()->record_after_bytes(alloc_region->used()); | |
3640 } | |
3641 | |
342 | 3642 HeapWord* |
3643 G1CollectedHeap::allocate_during_gc_slow(GCAllocPurpose purpose, | |
3644 HeapRegion* alloc_region, | |
3645 bool par, | |
3646 size_t word_size) { | |
3647 HeapWord* block = NULL; | |
3648 // In the parallel case, a previous thread to obtain the lock may have | |
3649 // already assigned a new gc_alloc_region. | |
3650 if (alloc_region != _gc_alloc_regions[purpose]) { | |
3651 assert(par, "But should only happen in parallel case."); | |
3652 alloc_region = _gc_alloc_regions[purpose]; | |
3653 if (alloc_region == NULL) return NULL; | |
3654 block = alloc_region->par_allocate(word_size); | |
3655 if (block != NULL) return block; | |
3656 // Otherwise, continue; this new region is empty, too. | |
3657 } | |
3658 assert(alloc_region != NULL, "We better have an allocation region"); | |
545 | 3659 retire_alloc_region(alloc_region, par); |
342 | 3660 |
3661 if (_gc_alloc_region_counts[purpose] >= g1_policy()->max_regions(purpose)) { | |
3662 // Cannot allocate more regions for the given purpose. | |
3663 GCAllocPurpose alt_purpose = g1_policy()->alternative_purpose(purpose); | |
3664 // Is there an alternative? | |
3665 if (purpose != alt_purpose) { | |
3666 HeapRegion* alt_region = _gc_alloc_regions[alt_purpose]; | |
3667 // Has not the alternative region been aliased? | |
545 | 3668 if (alloc_region != alt_region && alt_region != NULL) { |
342 | 3669 // Try to allocate in the alternative region. |
3670 if (par) { | |
3671 block = alt_region->par_allocate(word_size); | |
3672 } else { | |
3673 block = alt_region->allocate(word_size); | |
3674 } | |
3675 // Make an alias. | |
3676 _gc_alloc_regions[purpose] = _gc_alloc_regions[alt_purpose]; | |
545 | 3677 if (block != NULL) { |
3678 return block; | |
3679 } | |
3680 retire_alloc_region(alt_region, par); | |
342 | 3681 } |
3682 // Both the allocation region and the alternative one are full | |
3683 // and aliased, replace them with a new allocation region. | |
3684 purpose = alt_purpose; | |
3685 } else { | |
3686 set_gc_alloc_region(purpose, NULL); | |
3687 return NULL; | |
3688 } | |
3689 } | |
3690 | |
3691 // Now allocate a new region for allocation. | |
3692 alloc_region = newAllocRegionWithExpansion(purpose, word_size, false /*zero_filled*/); | |
3693 | |
3694 // let the caller handle alloc failure | |
3695 if (alloc_region != NULL) { | |
3696 | |
3697 assert(check_gc_alloc_regions(), "alloc regions messed up"); | |
3698 assert(alloc_region->saved_mark_at_top(), | |
3699 "Mark should have been saved already."); | |
3700 // We used to assert that the region was zero-filled here, but no | |
3701 // longer. | |
3702 | |
3703 // This must be done last: once it's installed, other regions may | |
3704 // allocate in it (without holding the lock.) | |
3705 set_gc_alloc_region(purpose, alloc_region); | |
3706 | |
3707 if (par) { | |
3708 block = alloc_region->par_allocate(word_size); | |
3709 } else { | |
3710 block = alloc_region->allocate(word_size); | |
3711 } | |
3712 // Caller handles alloc failure. | |
3713 } else { | |
3714 // This sets other apis using the same old alloc region to NULL, also. | |
3715 set_gc_alloc_region(purpose, NULL); | |
3716 } | |
3717 return block; // May be NULL. | |
3718 } | |
3719 | |
3720 void G1CollectedHeap::par_allocate_remaining_space(HeapRegion* r) { | |
3721 HeapWord* block = NULL; | |
3722 size_t free_words; | |
3723 do { | |
3724 free_words = r->free()/HeapWordSize; | |
3725 // If there's too little space, no one can allocate, so we're done. | |
1571
2d127394260e
6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents:
1547
diff
changeset
|
3726 if (free_words < CollectedHeap::min_fill_size()) return; |
342 | 3727 // Otherwise, try to claim it. |
3728 block = r->par_allocate(free_words); | |
3729 } while (block == NULL); | |
481
7d7a7c599c17
6578152: fill_region_with_object has usability and safety issues
jcoomes
parents:
457
diff
changeset
|
3730 fill_with_object(block, free_words); |
342 | 3731 } |
3732 | |
3733 #ifndef PRODUCT | |
3734 bool GCLabBitMapClosure::do_bit(size_t offset) { | |
3735 HeapWord* addr = _bitmap->offsetToHeapWord(offset); | |
3736 guarantee(_cm->isMarked(oop(addr)), "it should be!"); | |
3737 return true; | |
3738 } | |
3739 #endif // PRODUCT | |
3740 | |
845
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
3741 G1ParScanThreadState::G1ParScanThreadState(G1CollectedHeap* g1h, int queue_num) |
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
3742 : _g1h(g1h), |
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
3743 _refs(g1h->task_queue(queue_num)), |
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
3744 _dcq(&g1h->dirty_card_queue_set()), |
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
3745 _ct_bs((CardTableModRefBS*)_g1h->barrier_set()), |
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
3746 _g1_rem(g1h->g1_rem_set()), |
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
3747 _hash_seed(17), _queue_num(queue_num), |
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
3748 _term_attempts(0), |
1391
79e419e5ea3b
6942253: G1: replace G1ParallelGCAllocBufferSize with YoungPLABSize and OldPLABSize
apetrusenko
parents:
1390
diff
changeset
|
3749 _surviving_alloc_buffer(g1h->desired_plab_sz(GCAllocForSurvived)), |
79e419e5ea3b
6942253: G1: replace G1ParallelGCAllocBufferSize with YoungPLABSize and OldPLABSize
apetrusenko
parents:
1390
diff
changeset
|
3750 _tenured_alloc_buffer(g1h->desired_plab_sz(GCAllocForTenured)), |
845
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
3751 _age_table(false), |
342 | 3752 #if G1_DETAILED_STATS |
845
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
3753 _pushes(0), _pops(0), _steals(0), |
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
3754 _steal_attempts(0), _overflow_pushes(0), |
342 | 3755 #endif |
845
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
3756 _strong_roots_time(0), _term_time(0), |
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
3757 _alloc_buffer_waste(0), _undo_waste(0) |
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
3758 { |
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
3759 // we allocate G1YoungSurvRateNumRegions plus one entries, since |
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
3760 // we "sacrifice" entry 0 to keep track of surviving bytes for |
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
3761 // non-young regions (where the age is -1) |
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
3762 // We also add a few elements at the beginning and at the end in |
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
3763 // an attempt to eliminate cache contention |
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
3764 size_t real_length = 1 + _g1h->g1_policy()->young_cset_length(); |
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
3765 size_t array_length = PADDING_ELEM_NUM + |
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
3766 real_length + |
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
3767 PADDING_ELEM_NUM; |
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
3768 _surviving_young_words_base = NEW_C_HEAP_ARRAY(size_t, array_length); |
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
3769 if (_surviving_young_words_base == NULL) |
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
3770 vm_exit_out_of_memory(array_length * sizeof(size_t), |
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
3771 "Not enough space for young surv histo."); |
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
3772 _surviving_young_words = _surviving_young_words_base + PADDING_ELEM_NUM; |
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
3773 memset(_surviving_young_words, 0, real_length * sizeof(size_t)); |
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
3774 |
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
3775 _overflowed_refs = new OverflowQueue(10); |
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
3776 |
1391
79e419e5ea3b
6942253: G1: replace G1ParallelGCAllocBufferSize with YoungPLABSize and OldPLABSize
apetrusenko
parents:
1390
diff
changeset
|
3777 _alloc_buffers[GCAllocForSurvived] = &_surviving_alloc_buffer; |
79e419e5ea3b
6942253: G1: replace G1ParallelGCAllocBufferSize with YoungPLABSize and OldPLABSize
apetrusenko
parents:
1390
diff
changeset
|
3778 _alloc_buffers[GCAllocForTenured] = &_tenured_alloc_buffer; |
79e419e5ea3b
6942253: G1: replace G1ParallelGCAllocBufferSize with YoungPLABSize and OldPLABSize
apetrusenko
parents:
1390
diff
changeset
|
3779 |
845
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
3780 _start = os::elapsedTime(); |
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
3781 } |
342 | 3782 |
3783 G1ParClosureSuper::G1ParClosureSuper(G1CollectedHeap* g1, G1ParScanThreadState* par_scan_state) : | |
3784 _g1(g1), _g1_rem(_g1->g1_rem_set()), _cm(_g1->concurrent_mark()), | |
3785 _par_scan_state(par_scan_state) { } | |
3786 | |
845
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
3787 template <class T> void G1ParCopyHelper::mark_forwardee(T* p) { |
342 | 3788 // This is called _after_ do_oop_work has been called, hence after |
3789 // the object has been relocated to its new location and *p points | |
3790 // to its new location. | |
3791 | |
845
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
3792 T heap_oop = oopDesc::load_heap_oop(p); |
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
3793 if (!oopDesc::is_null(heap_oop)) { |
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
3794 oop obj = oopDesc::decode_heap_oop(heap_oop); |
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
3795 assert((_g1->evacuation_failed()) || (!_g1->obj_in_cs(obj)), |
342 | 3796 "shouldn't still be in the CSet if evacuation didn't fail."); |
845
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
3797 HeapWord* addr = (HeapWord*)obj; |
342 | 3798 if (_g1->is_in_g1_reserved(addr)) |
3799 _cm->grayRoot(oop(addr)); | |
3800 } | |
3801 } | |
3802 | |
3803 oop G1ParCopyHelper::copy_to_survivor_space(oop old) { | |
3804 size_t word_sz = old->size(); | |
3805 HeapRegion* from_region = _g1->heap_region_containing_raw(old); | |
3806 // +1 to make the -1 indexes valid... | |
3807 int young_index = from_region->young_index_in_cset()+1; | |
3808 assert( (from_region->is_young() && young_index > 0) || | |
3809 (!from_region->is_young() && young_index == 0), "invariant" ); | |
3810 G1CollectorPolicy* g1p = _g1->g1_policy(); | |
3811 markOop m = old->mark(); | |
545 | 3812 int age = m->has_displaced_mark_helper() ? m->displaced_mark_helper()->age() |
3813 : m->age(); | |
3814 GCAllocPurpose alloc_purpose = g1p->evacuation_destination(from_region, age, | |
342 | 3815 word_sz); |
3816 HeapWord* obj_ptr = _par_scan_state->allocate(alloc_purpose, word_sz); | |
3817 oop obj = oop(obj_ptr); | |
3818 | |
3819 if (obj_ptr == NULL) { | |
3820 // This will either forward-to-self, or detect that someone else has | |
3821 // installed a forwarding pointer. | |
3822 OopsInHeapRegionClosure* cl = _par_scan_state->evac_failure_closure(); | |
3823 return _g1->handle_evacuation_failure_par(cl, old); | |
3824 } | |
3825 | |
526 | 3826 // We're going to allocate linearly, so might as well prefetch ahead. |
3827 Prefetch::write(obj_ptr, PrefetchCopyIntervalInBytes); | |
3828 | |
342 | 3829 oop forward_ptr = old->forward_to_atomic(obj); |
3830 if (forward_ptr == NULL) { | |
3831 Copy::aligned_disjoint_words((HeapWord*) old, obj_ptr, word_sz); | |
526 | 3832 if (g1p->track_object_age(alloc_purpose)) { |
3833 // We could simply do obj->incr_age(). However, this causes a | |
3834 // performance issue. obj->incr_age() will first check whether | |
3835 // the object has a displaced mark by checking its mark word; | |
3836 // getting the mark word from the new location of the object | |
3837 // stalls. So, given that we already have the mark word and we | |
3838 // are about to install it anyway, it's better to increase the | |
3839 // age on the mark word, when the object does not have a | |
3840 // displaced mark word. We're not expecting many objects to have | |
3841 // a displaced marked word, so that case is not optimized | |
3842 // further (it could be...) and we simply call obj->incr_age(). | |
3843 | |
3844 if (m->has_displaced_mark_helper()) { | |
3845 // in this case, we have to install the mark word first, | |
3846 // otherwise obj looks to be forwarded (the old mark word, | |
3847 // which contains the forward pointer, was copied) | |
3848 obj->set_mark(m); | |
3849 obj->incr_age(); | |
3850 } else { | |
3851 m = m->incr_age(); | |
545 | 3852 obj->set_mark(m); |
526 | 3853 } |
545 | 3854 _par_scan_state->age_table()->add(obj, word_sz); |
3855 } else { | |
3856 obj->set_mark(m); | |
526 | 3857 } |
3858 | |
342 | 3859 // preserve "next" mark bit |
3860 if (_g1->mark_in_progress() && !_g1->is_obj_ill(old)) { | |
3861 if (!use_local_bitmaps || | |
3862 !_par_scan_state->alloc_buffer(alloc_purpose)->mark(obj_ptr)) { | |
3863 // if we couldn't mark it on the local bitmap (this happens when | |
3864 // the object was not allocated in the GCLab), we have to bite | |
3865 // the bullet and do the standard parallel mark | |
3866 _cm->markAndGrayObjectIfNecessary(obj); | |
3867 } | |
3868 #if 1 | |
3869 if (_g1->isMarkedNext(old)) { | |
3870 _cm->nextMarkBitMap()->parClear((HeapWord*)old); | |
3871 } | |
3872 #endif | |
3873 } | |
3874 | |
3875 size_t* surv_young_words = _par_scan_state->surviving_young_words(); | |
3876 surv_young_words[young_index] += word_sz; | |
3877 | |
3878 if (obj->is_objArray() && arrayOop(obj)->length() >= ParGCArrayScanChunk) { | |
3879 arrayOop(old)->set_length(0); | |
845
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
3880 oop* old_p = set_partial_array_mask(old); |
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
3881 _par_scan_state->push_on_queue(old_p); |
342 | 3882 } else { |
526 | 3883 // No point in using the slower heap_region_containing() method, |
3884 // given that we know obj is in the heap. | |
3885 _scanner->set_region(_g1->heap_region_containing_raw(obj)); | |
342 | 3886 obj->oop_iterate_backwards(_scanner); |
3887 } | |
3888 } else { | |
3889 _par_scan_state->undo_allocation(alloc_purpose, obj_ptr, word_sz); | |
3890 obj = forward_ptr; | |
3891 } | |
3892 return obj; | |
3893 } | |
3894 | |
1261
0414c1049f15
6923991: G1: improve scalability of RSet scanning
iveresov
parents:
1245
diff
changeset
|
3895 template <bool do_gen_barrier, G1Barrier barrier, bool do_mark_forwardee> |
845
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
3896 template <class T> |
1261
0414c1049f15
6923991: G1: improve scalability of RSet scanning
iveresov
parents:
1245
diff
changeset
|
3897 void G1ParCopyClosure <do_gen_barrier, barrier, do_mark_forwardee> |
845
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
3898 ::do_oop_work(T* p) { |
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
3899 oop obj = oopDesc::load_decode_heap_oop(p); |
342 | 3900 assert(barrier != G1BarrierRS || obj != NULL, |
3901 "Precondition: G1BarrierRS implies obj is nonNull"); | |
3902 | |
526 | 3903 // here the null check is implicit in the cset_fast_test() test |
1261
0414c1049f15
6923991: G1: improve scalability of RSet scanning
iveresov
parents:
1245
diff
changeset
|
3904 if (_g1->in_cset_fast_test(obj)) { |
342 | 3905 #if G1_REM_SET_LOGGING |
526 | 3906 gclog_or_tty->print_cr("Loc "PTR_FORMAT" contains pointer "PTR_FORMAT" " |
3907 "into CS.", p, (void*) obj); | |
342 | 3908 #endif |
526 | 3909 if (obj->is_forwarded()) { |
845
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
3910 oopDesc::encode_store_heap_oop(p, obj->forwardee()); |
526 | 3911 } else { |
845
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
3912 oop copy_oop = copy_to_survivor_space(obj); |
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
3913 oopDesc::encode_store_heap_oop(p, copy_oop); |
342 | 3914 } |
526 | 3915 // When scanning the RS, we only care about objs in CS. |
3916 if (barrier == G1BarrierRS) { | |
616
4f360ec815ba
6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents:
595
diff
changeset
|
3917 _par_scan_state->update_rs(_from, p, _par_scan_state->queue_num()); |
342 | 3918 } |
526 | 3919 } |
3920 | |
3921 if (barrier == G1BarrierEvac && obj != NULL) { | |
616
4f360ec815ba
6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents:
595
diff
changeset
|
3922 _par_scan_state->update_rs(_from, p, _par_scan_state->queue_num()); |
526 | 3923 } |
3924 | |
3925 if (do_gen_barrier && obj != NULL) { | |
3926 par_do_barrier(p); | |
3927 } | |
3928 } | |
3929 | |
1261
0414c1049f15
6923991: G1: improve scalability of RSet scanning
iveresov
parents:
1245
diff
changeset
|
3930 template void G1ParCopyClosure<false, G1BarrierEvac, false>::do_oop_work(oop* p); |
0414c1049f15
6923991: G1: improve scalability of RSet scanning
iveresov
parents:
1245
diff
changeset
|
3931 template void G1ParCopyClosure<false, G1BarrierEvac, false>::do_oop_work(narrowOop* p); |
845
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
3932 |
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
3933 template <class T> void G1ParScanPartialArrayClosure::do_oop_nv(T* p) { |
526 | 3934 assert(has_partial_array_mask(p), "invariant"); |
3935 oop old = clear_partial_array_mask(p); | |
342 | 3936 assert(old->is_objArray(), "must be obj array"); |
3937 assert(old->is_forwarded(), "must be forwarded"); | |
3938 assert(Universe::heap()->is_in_reserved(old), "must be in heap."); | |
3939 | |
3940 objArrayOop obj = objArrayOop(old->forwardee()); | |
3941 assert((void*)old != (void*)old->forwardee(), "self forwarding here?"); | |
3942 // Process ParGCArrayScanChunk elements now | |
3943 // and push the remainder back onto queue | |
3944 int start = arrayOop(old)->length(); | |
3945 int end = obj->length(); | |
3946 int remainder = end - start; | |
3947 assert(start <= end, "just checking"); | |
3948 if (remainder > 2 * ParGCArrayScanChunk) { | |
3949 // Test above combines last partial chunk with a full chunk | |
3950 end = start + ParGCArrayScanChunk; | |
3951 arrayOop(old)->set_length(end); | |
3952 // Push remainder. | |
845
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
3953 oop* old_p = set_partial_array_mask(old); |
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
3954 assert(arrayOop(old)->length() < obj->length(), "Empty push?"); |
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
3955 _par_scan_state->push_on_queue(old_p); |
342 | 3956 } else { |
3957 // Restore length so that the heap remains parsable in | |
3958 // case of evacuation failure. | |
3959 arrayOop(old)->set_length(end); | |
3960 } | |
845
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
3961 _scanner.set_region(_g1->heap_region_containing_raw(obj)); |
342 | 3962 // process our set of indices (include header in first chunk) |
845
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
3963 obj->oop_iterate_range(&_scanner, start, end); |
342 | 3964 } |
3965 | |
3966 class G1ParEvacuateFollowersClosure : public VoidClosure { | |
3967 protected: | |
3968 G1CollectedHeap* _g1h; | |
3969 G1ParScanThreadState* _par_scan_state; | |
3970 RefToScanQueueSet* _queues; | |
3971 ParallelTaskTerminator* _terminator; | |
3972 | |
3973 G1ParScanThreadState* par_scan_state() { return _par_scan_state; } | |
3974 RefToScanQueueSet* queues() { return _queues; } | |
3975 ParallelTaskTerminator* terminator() { return _terminator; } | |
3976 | |
3977 public: | |
3978 G1ParEvacuateFollowersClosure(G1CollectedHeap* g1h, | |
3979 G1ParScanThreadState* par_scan_state, | |
3980 RefToScanQueueSet* queues, | |
3981 ParallelTaskTerminator* terminator) | |
3982 : _g1h(g1h), _par_scan_state(par_scan_state), | |
3983 _queues(queues), _terminator(terminator) {} | |
3984 | |
3985 void do_void() { | |
3986 G1ParScanThreadState* pss = par_scan_state(); | |
3987 while (true) { | |
3988 pss->trim_queue(); | |
3989 IF_G1_DETAILED_STATS(pss->note_steal_attempt()); | |
845
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
3990 |
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
3991 StarTask stolen_task; |
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
3992 if (queues()->steal(pss->queue_num(), pss->hash_seed(), stolen_task)) { |
342 | 3993 IF_G1_DETAILED_STATS(pss->note_steal()); |
526 | 3994 |
3995 // slightly paranoid tests; I'm trying to catch potential | |
3996 // problems before we go into push_on_queue to know where the | |
3997 // problem is coming from | |
845
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
3998 assert((oop*)stolen_task != NULL, "Error"); |
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
3999 if (stolen_task.is_narrow()) { |
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
4000 assert(UseCompressedOops, "Error"); |
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
4001 narrowOop* p = (narrowOop*) stolen_task; |
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
4002 assert(has_partial_array_mask(p) || |
1261
0414c1049f15
6923991: G1: improve scalability of RSet scanning
iveresov
parents:
1245
diff
changeset
|
4003 _g1h->is_in_g1_reserved(oopDesc::load_decode_heap_oop(p)), "Error"); |
845
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
4004 pss->push_on_queue(p); |
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
4005 } else { |
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
4006 oop* p = (oop*) stolen_task; |
1261
0414c1049f15
6923991: G1: improve scalability of RSet scanning
iveresov
parents:
1245
diff
changeset
|
4007 assert(has_partial_array_mask(p) || _g1h->is_in_g1_reserved(*p), "Error"); |
845
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
4008 pss->push_on_queue(p); |
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
4009 } |
342 | 4010 continue; |
4011 } | |
4012 pss->start_term_time(); | |
4013 if (terminator()->offer_termination()) break; | |
4014 pss->end_term_time(); | |
4015 } | |
4016 pss->end_term_time(); | |
4017 pss->retire_alloc_buffers(); | |
4018 } | |
4019 }; | |
4020 | |
4021 class G1ParTask : public AbstractGangTask { | |
4022 protected: | |
4023 G1CollectedHeap* _g1h; | |
4024 RefToScanQueueSet *_queues; | |
4025 ParallelTaskTerminator _terminator; | |
845
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
4026 int _n_workers; |
342 | 4027 |
4028 Mutex _stats_lock; | |
4029 Mutex* stats_lock() { return &_stats_lock; } | |
4030 | |
4031 size_t getNCards() { | |
4032 return (_g1h->capacity() + G1BlockOffsetSharedArray::N_bytes - 1) | |
4033 / G1BlockOffsetSharedArray::N_bytes; | |
4034 } | |
4035 | |
4036 public: | |
4037 G1ParTask(G1CollectedHeap* g1h, int workers, RefToScanQueueSet *task_queues) | |
4038 : AbstractGangTask("G1 collection"), | |
4039 _g1h(g1h), | |
4040 _queues(task_queues), | |
4041 _terminator(workers, _queues), | |
845
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
4042 _stats_lock(Mutex::leaf, "parallel G1 stats lock", true), |
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
4043 _n_workers(workers) |
342 | 4044 {} |
4045 | |
4046 RefToScanQueueSet* queues() { return _queues; } | |
4047 | |
4048 RefToScanQueue *work_queue(int i) { | |
4049 return queues()->queue(i); | |
4050 } | |
4051 | |
4052 void work(int i) { | |
845
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
838
diff
changeset
|
4053 if (i >= _n_workers) return; // no work needed this round |
1611 | 4054 |
4055 double start_time_ms = os::elapsedTime() * 1000.0; | |
4056 _g1h->g1_policy()->record_gc_worker_start_time(i, start_time_ms); | |
4057 | |
342 | 4058 ResourceMark rm; |
4059 HandleMark hm; | |
4060 | |
526 | 4061 G1ParScanThreadState pss(_g1h, i); |
4062 G1ParScanHeapEvacClosure scan_evac_cl(_g1h, &pss); | |
4063 G1ParScanHeapEvacFailureClosure evac_failure_cl(_g1h, &pss); | |
4064 G1ParScanPartialArrayClosure partial_scan_cl(_g1h, &pss); | |
342 | 4065 |
4066 pss.set_evac_closure(&scan_evac_cl); | |
4067 pss.set_evac_failure_closure(&evac_failure_cl); | |
4068 pss.set_partial_scan_closure(&partial_scan_cl); | |
4069 | |
4070 G1ParScanExtRootClosure only_scan_root_cl(_g1h, &pss); | |
4071 G1ParScanPermClosure only_scan_perm_cl(_g1h, &pss); | |
4072 G1ParScanHeapRSClosure only_scan_heap_rs_cl(_g1h, &pss); | |
1261
0414c1049f15
6923991: G1: improve scalability of RSet scanning
iveresov
parents:
1245
diff
changeset
|
4073 G1ParPushHeapRSClosure push_heap_rs_cl(_g1h, &pss); |
616
4f360ec815ba
6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents:
595
diff
changeset
|
4074 |
342 | 4075 G1ParScanAndMarkExtRootClosure scan_mark_root_cl(_g1h, &pss); |
4076 G1ParScanAndMarkPermClosure scan_mark_perm_cl(_g1h, &pss); | |
4077 G1ParScanAndMarkHeapRSClosure scan_mark_heap_rs_cl(_g1h, &pss); | |
4078 | |
4079 OopsInHeapRegionClosure *scan_root_cl; | |
4080 OopsInHeapRegionClosure *scan_perm_cl; | |
4081 | |
1359
23b1b27ac76c
6909756: G1: guarantee(G1CollectedHeap::heap()->mark_in_progress(),"Precondition.")
tonyp
parents:
1313
diff
changeset
|
4082 if (_g1h->g1_policy()->during_initial_mark_pause()) { |
342 | 4083 scan_root_cl = &scan_mark_root_cl; |
4084 scan_perm_cl = &scan_mark_perm_cl; | |
4085 } else { | |
4086 scan_root_cl = &only_scan_root_cl; | |
4087 scan_perm_cl = &only_scan_perm_cl; | |
4088 } | |
4089 | |
4090 pss.start_strong_roots(); | |
4091 _g1h->g1_process_strong_roots(/* not collecting perm */ false, | |
4092 SharedHeap::SO_AllClasses, | |
4093 scan_root_cl, | |
1261
0414c1049f15
6923991: G1: improve scalability of RSet scanning
iveresov
parents:
1245
diff
changeset
|
4094 &push_heap_rs_cl, |
342 | 4095 scan_perm_cl, |
4096 i); | |
4097 pss.end_strong_roots(); | |
4098 { | |
4099 double start = os::elapsedTime(); | |
4100 G1ParEvacuateFollowersClosure evac(_g1h, &pss, _queues, &_terminator); | |
4101 evac.do_void(); | |
4102 double elapsed_ms = (os::elapsedTime()-start)*1000.0; | |
4103 double term_ms = pss.term_time()*1000.0; | |
4104 _g1h->g1_policy()->record_obj_copy_time(i, elapsed_ms-term_ms); | |
1611 | 4105 _g1h->g1_policy()->record_termination(i, term_ms, pss.term_attempts()); |
342 | 4106 } |
1282 | 4107 _g1h->g1_policy()->record_thread_age_table(pss.age_table()); |
342 | 4108 _g1h->update_surviving_young_words(pss.surviving_young_words()+1); |
4109 | |
4110 // Clean up any par-expanded rem sets. | |
4111 HeapRegionRemSet::par_cleanup(); | |
4112 | |
4113 MutexLocker x(stats_lock()); | |
4114 if (ParallelGCVerbose) { | |
4115 gclog_or_tty->print("Thread %d complete:\n", i); | |
4116 #if G1_DETAILED_STATS | |
4117 gclog_or_tty->print(" Pushes: %7d Pops: %7d Overflows: %7d Steals %7d (in %d attempts)\n", | |
4118 pss.pushes(), | |
4119 pss.pops(), | |
4120 pss.overflow_pushes(), | |
4121 pss.steals(), | |
4122 pss.steal_attempts()); | |
4123 #endif | |
4124 double elapsed = pss.elapsed(); | |
4125 double strong_roots = pss.strong_roots_time(); | |
4126 double term = pss.term_time(); | |
4127 gclog_or_tty->print(" Elapsed: %7.2f ms.\n" | |
4128 " Strong roots: %7.2f ms (%6.2f%%)\n" | |
1611 | 4129 " Termination: %7.2f ms (%6.2f%%) " |
4130 "(in "SIZE_FORMAT" entries)\n", | |
342 | 4131 elapsed * 1000.0, |
4132 strong_roots * 1000.0, (strong_roots*100.0/elapsed), | |
4133 term * 1000.0, (term*100.0/elapsed), | |
4134 pss.term_attempts()); | |
4135 size_t total_waste = pss.alloc_buffer_waste() + pss.undo_waste(); | |
4136 gclog_or_tty->print(" Waste: %8dK\n" | |
4137 " Alloc Buffer: %8dK\n" | |
4138 " Undo: %8dK\n", | |
4139 (total_waste * HeapWordSize) / K, | |
4140 (pss.alloc_buffer_waste() * HeapWordSize) / K, | |
4141 (pss.undo_waste() * HeapWordSize) / K); | |
4142 } | |
4143 | |
4144 assert(pss.refs_to_scan() == 0, "Task queue should be empty"); | |
4145 assert(pss.overflowed_refs_to_scan() == 0, "Overflow queue should be empty"); | |
1611 | 4146 double end_time_ms = os::elapsedTime() * 1000.0; |
4147 _g1h->g1_policy()->record_gc_worker_end_time(i, end_time_ms); | |
342 | 4148 } |
4149 }; | |
4150 | |
4151 // *** Common G1 Evacuation Stuff | |
4152 | |
4153 void | |
4154 G1CollectedHeap:: | |
4155 g1_process_strong_roots(bool collecting_perm_gen, | |
4156 SharedHeap::ScanningOption so, | |
4157 OopClosure* scan_non_heap_roots, | |
4158 OopsInHeapRegionClosure* scan_rs, | |
4159 OopsInGenClosure* scan_perm, | |
4160 int worker_i) { | |
4161 // First scan the strong roots, including the perm gen. | |
4162 double ext_roots_start = os::elapsedTime(); | |
4163 double closure_app_time_sec = 0.0; | |
4164 | |
4165 BufferingOopClosure buf_scan_non_heap_roots(scan_non_heap_roots); | |
4166 BufferingOopsInGenClosure buf_scan_perm(scan_perm); | |
4167 buf_scan_perm.set_generation(perm_gen()); | |
4168 | |
989
148e5441d916
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
890
diff
changeset
|
4169 // Walk the code cache w/o buffering, because StarTask cannot handle |
148e5441d916
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
890
diff
changeset
|
4170 // unaligned oop locations. |
148e5441d916
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
890
diff
changeset
|
4171 CodeBlobToOopClosure eager_scan_code_roots(scan_non_heap_roots, /*do_marking=*/ true); |
148e5441d916
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
890
diff
changeset
|
4172 |
148e5441d916
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
890
diff
changeset
|
4173 process_strong_roots(false, // no scoping; this is parallel code |
148e5441d916
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
890
diff
changeset
|
4174 collecting_perm_gen, so, |
342 | 4175 &buf_scan_non_heap_roots, |
989
148e5441d916
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
890
diff
changeset
|
4176 &eager_scan_code_roots, |
342 | 4177 &buf_scan_perm); |
1394
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
4178 |
342 | 4179 // Finish up any enqueued closure apps. |
4180 buf_scan_non_heap_roots.done(); | |
4181 buf_scan_perm.done(); | |
4182 double ext_roots_end = os::elapsedTime(); | |
4183 g1_policy()->reset_obj_copy_time(worker_i); | |
4184 double obj_copy_time_sec = | |
4185 buf_scan_non_heap_roots.closure_app_seconds() + | |
4186 buf_scan_perm.closure_app_seconds(); | |
4187 g1_policy()->record_obj_copy_time(worker_i, obj_copy_time_sec * 1000.0); | |
4188 double ext_root_time_ms = | |
4189 ((ext_roots_end - ext_roots_start) - obj_copy_time_sec) * 1000.0; | |
4190 g1_policy()->record_ext_root_scan_time(worker_i, ext_root_time_ms); | |
4191 | |
4192 // Scan strong roots in mark stack. | |
4193 if (!_process_strong_tasks->is_task_claimed(G1H_PS_mark_stack_oops_do)) { | |
4194 concurrent_mark()->oops_do(scan_non_heap_roots); | |
4195 } | |
4196 double mark_stack_scan_ms = (os::elapsedTime() - ext_roots_end) * 1000.0; | |
4197 g1_policy()->record_mark_stack_scan_time(worker_i, mark_stack_scan_ms); | |
4198 | |
4199 // XXX What should this be doing in the parallel case? | |
4200 g1_policy()->record_collection_pause_end_CH_strong_roots(); | |
4201 // Now scan the complement of the collection set. | |
4202 if (scan_rs != NULL) { | |
4203 g1_rem_set()->oops_into_collection_set_do(scan_rs, worker_i); | |
4204 } | |
4205 // Finish with the ref_processor roots. | |
4206 if (!_process_strong_tasks->is_task_claimed(G1H_PS_refProcessor_oops_do)) { | |
4207 ref_processor()->oops_do(scan_non_heap_roots); | |
4208 } | |
4209 g1_policy()->record_collection_pause_end_G1_strong_roots(); | |
4210 _process_strong_tasks->all_tasks_completed(); | |
4211 } | |
4212 | |
4213 void | |
4214 G1CollectedHeap::g1_process_weak_roots(OopClosure* root_closure, | |
4215 OopClosure* non_root_closure) { | |
989
148e5441d916
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
890
diff
changeset
|
4216 CodeBlobToOopClosure roots_in_blobs(root_closure, /*do_marking=*/ false); |
148e5441d916
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
890
diff
changeset
|
4217 SharedHeap::process_weak_roots(root_closure, &roots_in_blobs, non_root_closure); |
342 | 4218 } |
4219 | |
4220 | |
4221 class SaveMarksClosure: public HeapRegionClosure { | |
4222 public: | |
4223 bool doHeapRegion(HeapRegion* r) { | |
4224 r->save_marks(); | |
4225 return false; | |
4226 } | |
4227 }; | |
4228 | |
4229 void G1CollectedHeap::save_marks() { | |
4230 if (ParallelGCThreads == 0) { | |
4231 SaveMarksClosure sm; | |
4232 heap_region_iterate(&sm); | |
4233 } | |
4234 // We do this even in the parallel case | |
4235 perm_gen()->save_marks(); | |
4236 } | |
4237 | |
4238 void G1CollectedHeap::evacuate_collection_set() { | |
4239 set_evacuation_failed(false); | |
4240 | |
4241 g1_rem_set()->prepare_for_oops_into_collection_set_do(); | |
4242 concurrent_g1_refine()->set_use_cache(false); | |
889 | 4243 concurrent_g1_refine()->clear_hot_cache_claimed_index(); |
4244 | |
342 | 4245 int n_workers = (ParallelGCThreads > 0 ? workers()->total_workers() : 1); |
4246 set_par_threads(n_workers); | |
4247 G1ParTask g1_par_task(this, n_workers, _task_queues); | |
4248 | |
4249 init_for_evac_failure(NULL); | |
4250 | |
4251 rem_set()->prepare_for_younger_refs_iterate(true); | |
616
4f360ec815ba
6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents:
595
diff
changeset
|
4252 |
4f360ec815ba
6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents:
595
diff
changeset
|
4253 assert(dirty_card_queue_set().completed_buffers_num() == 0, "Should be empty"); |
342 | 4254 double start_par = os::elapsedTime(); |
4255 if (ParallelGCThreads > 0) { | |
4256 // The individual threads will set their evac-failure closures. | |
989
148e5441d916
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
890
diff
changeset
|
4257 StrongRootsScope srs(this); |
342 | 4258 workers()->run_task(&g1_par_task); |
4259 } else { | |
989
148e5441d916
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
890
diff
changeset
|
4260 StrongRootsScope srs(this); |
342 | 4261 g1_par_task.work(0); |
4262 } | |
4263 | |
4264 double par_time = (os::elapsedTime() - start_par) * 1000.0; | |
4265 g1_policy()->record_par_time(par_time); | |
4266 set_par_threads(0); | |
4267 // Is this the right thing to do here? We don't save marks | |
4268 // on individual heap regions when we allocate from | |
4269 // them in parallel, so this seems like the correct place for this. | |
545 | 4270 retire_all_alloc_regions(); |
342 | 4271 { |
4272 G1IsAliveClosure is_alive(this); | |
4273 G1KeepAliveClosure keep_alive(this); | |
4274 JNIHandles::weak_oops_do(&is_alive, &keep_alive); | |
4275 } | |
940
8624da129f0b
6841313: G1: dirty cards of survivor regions in parallel
apetrusenko
parents:
936
diff
changeset
|
4276 release_gc_alloc_regions(false /* totally */); |
342 | 4277 g1_rem_set()->cleanup_after_oops_into_collection_set_do(); |
616
4f360ec815ba
6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents:
595
diff
changeset
|
4278 |
889 | 4279 concurrent_g1_refine()->clear_hot_cache(); |
342 | 4280 concurrent_g1_refine()->set_use_cache(true); |
4281 | |
4282 finalize_for_evac_failure(); | |
4283 | |
4284 // Must do this before removing self-forwarding pointers, which clears | |
4285 // the per-region evac-failure flags. | |
4286 concurrent_mark()->complete_marking_in_collection_set(); | |
4287 | |
4288 if (evacuation_failed()) { | |
4289 remove_self_forwarding_pointers(); | |
4290 if (PrintGCDetails) { | |
4291 gclog_or_tty->print(" (evacuation failed)"); | |
4292 } else if (PrintGC) { | |
4293 gclog_or_tty->print("--"); | |
4294 } | |
4295 } | |
4296 | |
616
4f360ec815ba
6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents:
595
diff
changeset
|
4297 if (G1DeferredRSUpdate) { |
4f360ec815ba
6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents:
595
diff
changeset
|
4298 RedirtyLoggedCardTableEntryFastClosure redirty; |
4f360ec815ba
6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents:
595
diff
changeset
|
4299 dirty_card_queue_set().set_closure(&redirty); |
4f360ec815ba
6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents:
595
diff
changeset
|
4300 dirty_card_queue_set().apply_closure_to_all_completed_buffers(); |
1111 | 4301 |
4302 DirtyCardQueueSet& dcq = JavaThread::dirty_card_queue_set(); | |
4303 dcq.merge_bufferlists(&dirty_card_queue_set()); | |
616
4f360ec815ba
6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents:
595
diff
changeset
|
4304 assert(dirty_card_queue_set().completed_buffers_num() == 0, "All should be consumed"); |
4f360ec815ba
6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents:
595
diff
changeset
|
4305 } |
342 | 4306 COMPILER2_PRESENT(DerivedPointerTable::update_pointers()); |
4307 } | |
4308 | |
4309 void G1CollectedHeap::free_region(HeapRegion* hr) { | |
4310 size_t pre_used = 0; | |
4311 size_t cleared_h_regions = 0; | |
4312 size_t freed_regions = 0; | |
4313 UncleanRegionList local_list; | |
4314 | |
4315 HeapWord* start = hr->bottom(); | |
4316 HeapWord* end = hr->prev_top_at_mark_start(); | |
4317 size_t used_bytes = hr->used(); | |
4318 size_t live_bytes = hr->max_live_bytes(); | |
4319 if (used_bytes > 0) { | |
4320 guarantee( live_bytes <= used_bytes, "invariant" ); | |
4321 } else { | |
4322 guarantee( live_bytes == 0, "invariant" ); | |
4323 } | |
4324 | |
4325 size_t garbage_bytes = used_bytes - live_bytes; | |
4326 if (garbage_bytes > 0) | |
4327 g1_policy()->decrease_known_garbage_bytes(garbage_bytes); | |
4328 | |
4329 free_region_work(hr, pre_used, cleared_h_regions, freed_regions, | |
4330 &local_list); | |
4331 finish_free_region_work(pre_used, cleared_h_regions, freed_regions, | |
4332 &local_list); | |
4333 } | |
4334 | |
4335 void | |
4336 G1CollectedHeap::free_region_work(HeapRegion* hr, | |
4337 size_t& pre_used, | |
4338 size_t& cleared_h_regions, | |
4339 size_t& freed_regions, | |
4340 UncleanRegionList* list, | |
4341 bool par) { | |
4342 pre_used += hr->used(); | |
4343 if (hr->isHumongous()) { | |
4344 assert(hr->startsHumongous(), | |
4345 "Only the start of a humongous region should be freed."); | |
4346 int ind = _hrs->find(hr); | |
4347 assert(ind != -1, "Should have an index."); | |
4348 // Clear the start region. | |
4349 hr->hr_clear(par, true /*clear_space*/); | |
4350 list->insert_before_head(hr); | |
4351 cleared_h_regions++; | |
4352 freed_regions++; | |
4353 // Clear any continued regions. | |
4354 ind++; | |
4355 while ((size_t)ind < n_regions()) { | |
4356 HeapRegion* hrc = _hrs->at(ind); | |
4357 if (!hrc->continuesHumongous()) break; | |
4358 // Otherwise, does continue the H region. | |
4359 assert(hrc->humongous_start_region() == hr, "Huh?"); | |
4360 hrc->hr_clear(par, true /*clear_space*/); | |
4361 cleared_h_regions++; | |
4362 freed_regions++; | |
4363 list->insert_before_head(hrc); | |
4364 ind++; | |
4365 } | |
4366 } else { | |
4367 hr->hr_clear(par, true /*clear_space*/); | |
4368 list->insert_before_head(hr); | |
4369 freed_regions++; | |
4370 // If we're using clear2, this should not be enabled. | |
4371 // assert(!hr->in_cohort(), "Can't be both free and in a cohort."); | |
4372 } | |
4373 } | |
4374 | |
4375 void G1CollectedHeap::finish_free_region_work(size_t pre_used, | |
4376 size_t cleared_h_regions, | |
4377 size_t freed_regions, | |
4378 UncleanRegionList* list) { | |
4379 if (list != NULL && list->sz() > 0) { | |
4380 prepend_region_list_on_unclean_list(list); | |
4381 } | |
4382 // Acquire a lock, if we're parallel, to update possibly-shared | |
4383 // variables. | |
4384 Mutex* lock = (n_par_threads() > 0) ? ParGCRareEvent_lock : NULL; | |
4385 { | |
4386 MutexLockerEx x(lock, Mutex::_no_safepoint_check_flag); | |
4387 _summary_bytes_used -= pre_used; | |
4388 _num_humongous_regions -= (int) cleared_h_regions; | |
4389 _free_regions += freed_regions; | |
4390 } | |
4391 } | |
4392 | |
4393 | |
4394 void G1CollectedHeap::dirtyCardsForYoungRegions(CardTableModRefBS* ct_bs, HeapRegion* list) { | |
4395 while (list != NULL) { | |
4396 guarantee( list->is_young(), "invariant" ); | |
4397 | |
4398 HeapWord* bottom = list->bottom(); | |
4399 HeapWord* end = list->end(); | |
4400 MemRegion mr(bottom, end); | |
4401 ct_bs->dirty(mr); | |
4402 | |
4403 list = list->get_next_young_region(); | |
4404 } | |
4405 } | |
4406 | |
796
29e7d79232b9
6819065: G1: eliminate high serial card table clearing time
apetrusenko
parents:
794
diff
changeset
|
4407 |
29e7d79232b9
6819065: G1: eliminate high serial card table clearing time
apetrusenko
parents:
794
diff
changeset
|
4408 class G1ParCleanupCTTask : public AbstractGangTask { |
29e7d79232b9
6819065: G1: eliminate high serial card table clearing time
apetrusenko
parents:
794
diff
changeset
|
4409 CardTableModRefBS* _ct_bs; |
29e7d79232b9
6819065: G1: eliminate high serial card table clearing time
apetrusenko
parents:
794
diff
changeset
|
4410 G1CollectedHeap* _g1h; |
940
8624da129f0b
6841313: G1: dirty cards of survivor regions in parallel
apetrusenko
parents:
936
diff
changeset
|
4411 HeapRegion* volatile _su_head; |
796
29e7d79232b9
6819065: G1: eliminate high serial card table clearing time
apetrusenko
parents:
794
diff
changeset
|
4412 public: |
29e7d79232b9
6819065: G1: eliminate high serial card table clearing time
apetrusenko
parents:
794
diff
changeset
|
4413 G1ParCleanupCTTask(CardTableModRefBS* ct_bs, |
940
8624da129f0b
6841313: G1: dirty cards of survivor regions in parallel
apetrusenko
parents:
936
diff
changeset
|
4414 G1CollectedHeap* g1h, |
8624da129f0b
6841313: G1: dirty cards of survivor regions in parallel
apetrusenko
parents:
936
diff
changeset
|
4415 HeapRegion* survivor_list) : |
796
29e7d79232b9
6819065: G1: eliminate high serial card table clearing time
apetrusenko
parents:
794
diff
changeset
|
4416 AbstractGangTask("G1 Par Cleanup CT Task"), |
29e7d79232b9
6819065: G1: eliminate high serial card table clearing time
apetrusenko
parents:
794
diff
changeset
|
4417 _ct_bs(ct_bs), |
940
8624da129f0b
6841313: G1: dirty cards of survivor regions in parallel
apetrusenko
parents:
936
diff
changeset
|
4418 _g1h(g1h), |
8624da129f0b
6841313: G1: dirty cards of survivor regions in parallel
apetrusenko
parents:
936
diff
changeset
|
4419 _su_head(survivor_list) |
796
29e7d79232b9
6819065: G1: eliminate high serial card table clearing time
apetrusenko
parents:
794
diff
changeset
|
4420 { } |
29e7d79232b9
6819065: G1: eliminate high serial card table clearing time
apetrusenko
parents:
794
diff
changeset
|
4421 |
29e7d79232b9
6819065: G1: eliminate high serial card table clearing time
apetrusenko
parents:
794
diff
changeset
|
4422 void work(int i) { |
29e7d79232b9
6819065: G1: eliminate high serial card table clearing time
apetrusenko
parents:
794
diff
changeset
|
4423 HeapRegion* r; |
29e7d79232b9
6819065: G1: eliminate high serial card table clearing time
apetrusenko
parents:
794
diff
changeset
|
4424 while (r = _g1h->pop_dirty_cards_region()) { |
29e7d79232b9
6819065: G1: eliminate high serial card table clearing time
apetrusenko
parents:
794
diff
changeset
|
4425 clear_cards(r); |
29e7d79232b9
6819065: G1: eliminate high serial card table clearing time
apetrusenko
parents:
794
diff
changeset
|
4426 } |
1394
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
4427 // Redirty the cards of the survivor regions. |
940
8624da129f0b
6841313: G1: dirty cards of survivor regions in parallel
apetrusenko
parents:
936
diff
changeset
|
4428 dirty_list(&this->_su_head); |
8624da129f0b
6841313: G1: dirty cards of survivor regions in parallel
apetrusenko
parents:
936
diff
changeset
|
4429 } |
8624da129f0b
6841313: G1: dirty cards of survivor regions in parallel
apetrusenko
parents:
936
diff
changeset
|
4430 |
796
29e7d79232b9
6819065: G1: eliminate high serial card table clearing time
apetrusenko
parents:
794
diff
changeset
|
4431 void clear_cards(HeapRegion* r) { |
1394
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
4432 // Cards for Survivor regions will be dirtied later. |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
4433 if (!r->is_survivor()) { |
796
29e7d79232b9
6819065: G1: eliminate high serial card table clearing time
apetrusenko
parents:
794
diff
changeset
|
4434 _ct_bs->clear(MemRegion(r->bottom(), r->end())); |
29e7d79232b9
6819065: G1: eliminate high serial card table clearing time
apetrusenko
parents:
794
diff
changeset
|
4435 } |
29e7d79232b9
6819065: G1: eliminate high serial card table clearing time
apetrusenko
parents:
794
diff
changeset
|
4436 } |
940
8624da129f0b
6841313: G1: dirty cards of survivor regions in parallel
apetrusenko
parents:
936
diff
changeset
|
4437 |
8624da129f0b
6841313: G1: dirty cards of survivor regions in parallel
apetrusenko
parents:
936
diff
changeset
|
4438 void dirty_list(HeapRegion* volatile * head_ptr) { |
8624da129f0b
6841313: G1: dirty cards of survivor regions in parallel
apetrusenko
parents:
936
diff
changeset
|
4439 HeapRegion* head; |
8624da129f0b
6841313: G1: dirty cards of survivor regions in parallel
apetrusenko
parents:
936
diff
changeset
|
4440 do { |
8624da129f0b
6841313: G1: dirty cards of survivor regions in parallel
apetrusenko
parents:
936
diff
changeset
|
4441 // Pop region off the list. |
8624da129f0b
6841313: G1: dirty cards of survivor regions in parallel
apetrusenko
parents:
936
diff
changeset
|
4442 head = *head_ptr; |
8624da129f0b
6841313: G1: dirty cards of survivor regions in parallel
apetrusenko
parents:
936
diff
changeset
|
4443 if (head != NULL) { |
8624da129f0b
6841313: G1: dirty cards of survivor regions in parallel
apetrusenko
parents:
936
diff
changeset
|
4444 HeapRegion* r = (HeapRegion*) |
8624da129f0b
6841313: G1: dirty cards of survivor regions in parallel
apetrusenko
parents:
936
diff
changeset
|
4445 Atomic::cmpxchg_ptr(head->get_next_young_region(), head_ptr, head); |
8624da129f0b
6841313: G1: dirty cards of survivor regions in parallel
apetrusenko
parents:
936
diff
changeset
|
4446 if (r == head) { |
8624da129f0b
6841313: G1: dirty cards of survivor regions in parallel
apetrusenko
parents:
936
diff
changeset
|
4447 assert(!r->isHumongous(), "Humongous regions shouldn't be on survivor list"); |
8624da129f0b
6841313: G1: dirty cards of survivor regions in parallel
apetrusenko
parents:
936
diff
changeset
|
4448 _ct_bs->dirty(MemRegion(r->bottom(), r->end())); |
8624da129f0b
6841313: G1: dirty cards of survivor regions in parallel
apetrusenko
parents:
936
diff
changeset
|
4449 } |
8624da129f0b
6841313: G1: dirty cards of survivor regions in parallel
apetrusenko
parents:
936
diff
changeset
|
4450 } |
8624da129f0b
6841313: G1: dirty cards of survivor regions in parallel
apetrusenko
parents:
936
diff
changeset
|
4451 } while (*head_ptr != NULL); |
8624da129f0b
6841313: G1: dirty cards of survivor regions in parallel
apetrusenko
parents:
936
diff
changeset
|
4452 } |
796
29e7d79232b9
6819065: G1: eliminate high serial card table clearing time
apetrusenko
parents:
794
diff
changeset
|
4453 }; |
29e7d79232b9
6819065: G1: eliminate high serial card table clearing time
apetrusenko
parents:
794
diff
changeset
|
4454 |
29e7d79232b9
6819065: G1: eliminate high serial card table clearing time
apetrusenko
parents:
794
diff
changeset
|
4455 |
940
8624da129f0b
6841313: G1: dirty cards of survivor regions in parallel
apetrusenko
parents:
936
diff
changeset
|
4456 #ifndef PRODUCT |
8624da129f0b
6841313: G1: dirty cards of survivor regions in parallel
apetrusenko
parents:
936
diff
changeset
|
4457 class G1VerifyCardTableCleanup: public HeapRegionClosure { |
8624da129f0b
6841313: G1: dirty cards of survivor regions in parallel
apetrusenko
parents:
936
diff
changeset
|
4458 CardTableModRefBS* _ct_bs; |
8624da129f0b
6841313: G1: dirty cards of survivor regions in parallel
apetrusenko
parents:
936
diff
changeset
|
4459 public: |
8624da129f0b
6841313: G1: dirty cards of survivor regions in parallel
apetrusenko
parents:
936
diff
changeset
|
4460 G1VerifyCardTableCleanup(CardTableModRefBS* ct_bs) |
8624da129f0b
6841313: G1: dirty cards of survivor regions in parallel
apetrusenko
parents:
936
diff
changeset
|
4461 : _ct_bs(ct_bs) |
8624da129f0b
6841313: G1: dirty cards of survivor regions in parallel
apetrusenko
parents:
936
diff
changeset
|
4462 { } |
8624da129f0b
6841313: G1: dirty cards of survivor regions in parallel
apetrusenko
parents:
936
diff
changeset
|
4463 virtual bool doHeapRegion(HeapRegion* r) |
8624da129f0b
6841313: G1: dirty cards of survivor regions in parallel
apetrusenko
parents:
936
diff
changeset
|
4464 { |
8624da129f0b
6841313: G1: dirty cards of survivor regions in parallel
apetrusenko
parents:
936
diff
changeset
|
4465 MemRegion mr(r->bottom(), r->end()); |
1394
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
4466 if (r->is_survivor()) { |
940
8624da129f0b
6841313: G1: dirty cards of survivor regions in parallel
apetrusenko
parents:
936
diff
changeset
|
4467 _ct_bs->verify_dirty_region(mr); |
8624da129f0b
6841313: G1: dirty cards of survivor regions in parallel
apetrusenko
parents:
936
diff
changeset
|
4468 } else { |
8624da129f0b
6841313: G1: dirty cards of survivor regions in parallel
apetrusenko
parents:
936
diff
changeset
|
4469 _ct_bs->verify_clean_region(mr); |
8624da129f0b
6841313: G1: dirty cards of survivor regions in parallel
apetrusenko
parents:
936
diff
changeset
|
4470 } |
8624da129f0b
6841313: G1: dirty cards of survivor regions in parallel
apetrusenko
parents:
936
diff
changeset
|
4471 return false; |
8624da129f0b
6841313: G1: dirty cards of survivor regions in parallel
apetrusenko
parents:
936
diff
changeset
|
4472 } |
8624da129f0b
6841313: G1: dirty cards of survivor regions in parallel
apetrusenko
parents:
936
diff
changeset
|
4473 }; |
8624da129f0b
6841313: G1: dirty cards of survivor regions in parallel
apetrusenko
parents:
936
diff
changeset
|
4474 #endif |
8624da129f0b
6841313: G1: dirty cards of survivor regions in parallel
apetrusenko
parents:
936
diff
changeset
|
4475 |
342 | 4476 void G1CollectedHeap::cleanUpCardTable() { |
4477 CardTableModRefBS* ct_bs = (CardTableModRefBS*) (barrier_set()); | |
4478 double start = os::elapsedTime(); | |
4479 | |
796
29e7d79232b9
6819065: G1: eliminate high serial card table clearing time
apetrusenko
parents:
794
diff
changeset
|
4480 // Iterate over the dirty cards region list. |
940
8624da129f0b
6841313: G1: dirty cards of survivor regions in parallel
apetrusenko
parents:
936
diff
changeset
|
4481 G1ParCleanupCTTask cleanup_task(ct_bs, this, |
8624da129f0b
6841313: G1: dirty cards of survivor regions in parallel
apetrusenko
parents:
936
diff
changeset
|
4482 _young_list->first_survivor_region()); |
1394
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
4483 |
796
29e7d79232b9
6819065: G1: eliminate high serial card table clearing time
apetrusenko
parents:
794
diff
changeset
|
4484 if (ParallelGCThreads > 0) { |
29e7d79232b9
6819065: G1: eliminate high serial card table clearing time
apetrusenko
parents:
794
diff
changeset
|
4485 set_par_threads(workers()->total_workers()); |
29e7d79232b9
6819065: G1: eliminate high serial card table clearing time
apetrusenko
parents:
794
diff
changeset
|
4486 workers()->run_task(&cleanup_task); |
29e7d79232b9
6819065: G1: eliminate high serial card table clearing time
apetrusenko
parents:
794
diff
changeset
|
4487 set_par_threads(0); |
29e7d79232b9
6819065: G1: eliminate high serial card table clearing time
apetrusenko
parents:
794
diff
changeset
|
4488 } else { |
29e7d79232b9
6819065: G1: eliminate high serial card table clearing time
apetrusenko
parents:
794
diff
changeset
|
4489 while (_dirty_cards_region_list) { |
29e7d79232b9
6819065: G1: eliminate high serial card table clearing time
apetrusenko
parents:
794
diff
changeset
|
4490 HeapRegion* r = _dirty_cards_region_list; |
29e7d79232b9
6819065: G1: eliminate high serial card table clearing time
apetrusenko
parents:
794
diff
changeset
|
4491 cleanup_task.clear_cards(r); |
29e7d79232b9
6819065: G1: eliminate high serial card table clearing time
apetrusenko
parents:
794
diff
changeset
|
4492 _dirty_cards_region_list = r->get_next_dirty_cards_region(); |
29e7d79232b9
6819065: G1: eliminate high serial card table clearing time
apetrusenko
parents:
794
diff
changeset
|
4493 if (_dirty_cards_region_list == r) { |
29e7d79232b9
6819065: G1: eliminate high serial card table clearing time
apetrusenko
parents:
794
diff
changeset
|
4494 // The last region. |
29e7d79232b9
6819065: G1: eliminate high serial card table clearing time
apetrusenko
parents:
794
diff
changeset
|
4495 _dirty_cards_region_list = NULL; |
29e7d79232b9
6819065: G1: eliminate high serial card table clearing time
apetrusenko
parents:
794
diff
changeset
|
4496 } |
29e7d79232b9
6819065: G1: eliminate high serial card table clearing time
apetrusenko
parents:
794
diff
changeset
|
4497 r->set_next_dirty_cards_region(NULL); |
29e7d79232b9
6819065: G1: eliminate high serial card table clearing time
apetrusenko
parents:
794
diff
changeset
|
4498 } |
1394
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
4499 // now, redirty the cards of the survivor regions |
940
8624da129f0b
6841313: G1: dirty cards of survivor regions in parallel
apetrusenko
parents:
936
diff
changeset
|
4500 // (it seemed faster to do it this way, instead of iterating over |
8624da129f0b
6841313: G1: dirty cards of survivor regions in parallel
apetrusenko
parents:
936
diff
changeset
|
4501 // all regions and then clearing / dirtying as appropriate) |
8624da129f0b
6841313: G1: dirty cards of survivor regions in parallel
apetrusenko
parents:
936
diff
changeset
|
4502 dirtyCardsForYoungRegions(ct_bs, _young_list->first_survivor_region()); |
8624da129f0b
6841313: G1: dirty cards of survivor regions in parallel
apetrusenko
parents:
936
diff
changeset
|
4503 } |
1394
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
4504 |
342 | 4505 double elapsed = os::elapsedTime() - start; |
4506 g1_policy()->record_clear_ct_time( elapsed * 1000.0); | |
940
8624da129f0b
6841313: G1: dirty cards of survivor regions in parallel
apetrusenko
parents:
936
diff
changeset
|
4507 #ifndef PRODUCT |
8624da129f0b
6841313: G1: dirty cards of survivor regions in parallel
apetrusenko
parents:
936
diff
changeset
|
4508 if (G1VerifyCTCleanup || VerifyAfterGC) { |
8624da129f0b
6841313: G1: dirty cards of survivor regions in parallel
apetrusenko
parents:
936
diff
changeset
|
4509 G1VerifyCardTableCleanup cleanup_verifier(ct_bs); |
8624da129f0b
6841313: G1: dirty cards of survivor regions in parallel
apetrusenko
parents:
936
diff
changeset
|
4510 heap_region_iterate(&cleanup_verifier); |
8624da129f0b
6841313: G1: dirty cards of survivor regions in parallel
apetrusenko
parents:
936
diff
changeset
|
4511 } |
8624da129f0b
6841313: G1: dirty cards of survivor regions in parallel
apetrusenko
parents:
936
diff
changeset
|
4512 #endif |
342 | 4513 } |
4514 | |
4515 void G1CollectedHeap::do_collection_pause_if_appropriate(size_t word_size) { | |
4516 if (g1_policy()->should_do_collection_pause(word_size)) { | |
4517 do_collection_pause(); | |
4518 } | |
4519 } | |
4520 | |
4521 void G1CollectedHeap::free_collection_set(HeapRegion* cs_head) { | |
4522 double young_time_ms = 0.0; | |
4523 double non_young_time_ms = 0.0; | |
4524 | |
1394
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
4525 // Since the collection set is a superset of the the young list, |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
4526 // all we need to do to clear the young list is clear its |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
4527 // head and length, and unlink any young regions in the code below |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
4528 _young_list->clear(); |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
4529 |
342 | 4530 G1CollectorPolicy* policy = g1_policy(); |
4531 | |
4532 double start_sec = os::elapsedTime(); | |
4533 bool non_young = true; | |
4534 | |
4535 HeapRegion* cur = cs_head; | |
4536 int age_bound = -1; | |
4537 size_t rs_lengths = 0; | |
4538 | |
4539 while (cur != NULL) { | |
4540 if (non_young) { | |
4541 if (cur->is_young()) { | |
4542 double end_sec = os::elapsedTime(); | |
4543 double elapsed_ms = (end_sec - start_sec) * 1000.0; | |
4544 non_young_time_ms += elapsed_ms; | |
4545 | |
4546 start_sec = os::elapsedTime(); | |
4547 non_young = false; | |
4548 } | |
4549 } else { | |
4550 if (!cur->is_on_free_list()) { | |
4551 double end_sec = os::elapsedTime(); | |
4552 double elapsed_ms = (end_sec - start_sec) * 1000.0; | |
4553 young_time_ms += elapsed_ms; | |
4554 | |
4555 start_sec = os::elapsedTime(); | |
4556 non_young = true; | |
4557 } | |
4558 } | |
4559 | |
4560 rs_lengths += cur->rem_set()->occupied(); | |
4561 | |
4562 HeapRegion* next = cur->next_in_collection_set(); | |
4563 assert(cur->in_collection_set(), "bad CS"); | |
4564 cur->set_next_in_collection_set(NULL); | |
4565 cur->set_in_collection_set(false); | |
4566 | |
4567 if (cur->is_young()) { | |
4568 int index = cur->young_index_in_cset(); | |
4569 guarantee( index != -1, "invariant" ); | |
4570 guarantee( (size_t)index < policy->young_cset_length(), "invariant" ); | |
4571 size_t words_survived = _surviving_young_words[index]; | |
4572 cur->record_surv_words_in_group(words_survived); | |
1394
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
4573 |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
4574 // At this point the we have 'popped' cur from the collection set |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
4575 // (linked via next_in_collection_set()) but it is still in the |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
4576 // young list (linked via next_young_region()). Clear the |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
4577 // _next_young_region field. |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
4578 cur->set_next_young_region(NULL); |
342 | 4579 } else { |
4580 int index = cur->young_index_in_cset(); | |
4581 guarantee( index == -1, "invariant" ); | |
4582 } | |
4583 | |
4584 assert( (cur->is_young() && cur->young_index_in_cset() > -1) || | |
4585 (!cur->is_young() && cur->young_index_in_cset() == -1), | |
4586 "invariant" ); | |
4587 | |
4588 if (!cur->evacuation_failed()) { | |
4589 // And the region is empty. | |
4590 assert(!cur->is_empty(), | |
4591 "Should not have empty regions in a CS."); | |
4592 free_region(cur); | |
4593 } else { | |
4594 cur->uninstall_surv_rate_group(); | |
4595 if (cur->is_young()) | |
4596 cur->set_young_index_in_cset(-1); | |
4597 cur->set_not_young(); | |
4598 cur->set_evacuation_failed(false); | |
4599 } | |
4600 cur = next; | |
4601 } | |
4602 | |
4603 policy->record_max_rs_lengths(rs_lengths); | |
4604 policy->cset_regions_freed(); | |
4605 | |
4606 double end_sec = os::elapsedTime(); | |
4607 double elapsed_ms = (end_sec - start_sec) * 1000.0; | |
4608 if (non_young) | |
4609 non_young_time_ms += elapsed_ms; | |
4610 else | |
4611 young_time_ms += elapsed_ms; | |
4612 | |
4613 policy->record_young_free_cset_time_ms(young_time_ms); | |
4614 policy->record_non_young_free_cset_time_ms(non_young_time_ms); | |
4615 } | |
4616 | |
1394
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
4617 // This routine is similar to the above but does not record |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
4618 // any policy statistics or update free lists; we are abandoning |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
4619 // the current incremental collection set in preparation of a |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
4620 // full collection. After the full GC we will start to build up |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
4621 // the incremental collection set again. |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
4622 // This is only called when we're doing a full collection |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
4623 // and is immediately followed by the tearing down of the young list. |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
4624 |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
4625 void G1CollectedHeap::abandon_collection_set(HeapRegion* cs_head) { |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
4626 HeapRegion* cur = cs_head; |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
4627 |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
4628 while (cur != NULL) { |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
4629 HeapRegion* next = cur->next_in_collection_set(); |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
4630 assert(cur->in_collection_set(), "bad CS"); |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
4631 cur->set_next_in_collection_set(NULL); |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
4632 cur->set_in_collection_set(false); |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
4633 cur->set_young_index_in_cset(-1); |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
4634 cur = next; |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
4635 } |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
4636 } |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
4637 |
342 | 4638 HeapRegion* |
4639 G1CollectedHeap::alloc_region_from_unclean_list_locked(bool zero_filled) { | |
4640 assert(ZF_mon->owned_by_self(), "Precondition"); | |
4641 HeapRegion* res = pop_unclean_region_list_locked(); | |
4642 if (res != NULL) { | |
4643 assert(!res->continuesHumongous() && | |
4644 res->zero_fill_state() != HeapRegion::Allocated, | |
4645 "Only free regions on unclean list."); | |
4646 if (zero_filled) { | |
4647 res->ensure_zero_filled_locked(); | |
4648 res->set_zero_fill_allocated(); | |
4649 } | |
4650 } | |
4651 return res; | |
4652 } | |
4653 | |
4654 HeapRegion* G1CollectedHeap::alloc_region_from_unclean_list(bool zero_filled) { | |
4655 MutexLockerEx zx(ZF_mon, Mutex::_no_safepoint_check_flag); | |
4656 return alloc_region_from_unclean_list_locked(zero_filled); | |
4657 } | |
4658 | |
4659 void G1CollectedHeap::put_region_on_unclean_list(HeapRegion* r) { | |
4660 MutexLockerEx x(ZF_mon, Mutex::_no_safepoint_check_flag); | |
4661 put_region_on_unclean_list_locked(r); | |
4662 if (should_zf()) ZF_mon->notify_all(); // Wake up ZF thread. | |
4663 } | |
4664 | |
4665 void G1CollectedHeap::set_unclean_regions_coming(bool b) { | |
4666 MutexLockerEx x(Cleanup_mon); | |
4667 set_unclean_regions_coming_locked(b); | |
4668 } | |
4669 | |
4670 void G1CollectedHeap::set_unclean_regions_coming_locked(bool b) { | |
4671 assert(Cleanup_mon->owned_by_self(), "Precondition"); | |
4672 _unclean_regions_coming = b; | |
4673 // Wake up mutator threads that might be waiting for completeCleanup to | |
4674 // finish. | |
4675 if (!b) Cleanup_mon->notify_all(); | |
4676 } | |
4677 | |
4678 void G1CollectedHeap::wait_for_cleanup_complete() { | |
4679 MutexLockerEx x(Cleanup_mon); | |
4680 wait_for_cleanup_complete_locked(); | |
4681 } | |
4682 | |
4683 void G1CollectedHeap::wait_for_cleanup_complete_locked() { | |
4684 assert(Cleanup_mon->owned_by_self(), "precondition"); | |
4685 while (_unclean_regions_coming) { | |
4686 Cleanup_mon->wait(); | |
4687 } | |
4688 } | |
4689 | |
4690 void | |
4691 G1CollectedHeap::put_region_on_unclean_list_locked(HeapRegion* r) { | |
4692 assert(ZF_mon->owned_by_self(), "precondition."); | |
1545
cc387008223e
6921317: (partial) G1: assert(top() == bottom() || zfs == Allocated,"Region must be empty, or we must be setting it to
apetrusenko
parents:
1489
diff
changeset
|
4693 #ifdef ASSERT |
cc387008223e
6921317: (partial) G1: assert(top() == bottom() || zfs == Allocated,"Region must be empty, or we must be setting it to
apetrusenko
parents:
1489
diff
changeset
|
4694 if (r->is_gc_alloc_region()) { |
cc387008223e
6921317: (partial) G1: assert(top() == bottom() || zfs == Allocated,"Region must be empty, or we must be setting it to
apetrusenko
parents:
1489
diff
changeset
|
4695 ResourceMark rm; |
cc387008223e
6921317: (partial) G1: assert(top() == bottom() || zfs == Allocated,"Region must be empty, or we must be setting it to
apetrusenko
parents:
1489
diff
changeset
|
4696 stringStream region_str; |
cc387008223e
6921317: (partial) G1: assert(top() == bottom() || zfs == Allocated,"Region must be empty, or we must be setting it to
apetrusenko
parents:
1489
diff
changeset
|
4697 print_on(®ion_str); |
cc387008223e
6921317: (partial) G1: assert(top() == bottom() || zfs == Allocated,"Region must be empty, or we must be setting it to
apetrusenko
parents:
1489
diff
changeset
|
4698 assert(!r->is_gc_alloc_region(), err_msg("Unexpected GC allocation region: %s", |
cc387008223e
6921317: (partial) G1: assert(top() == bottom() || zfs == Allocated,"Region must be empty, or we must be setting it to
apetrusenko
parents:
1489
diff
changeset
|
4699 region_str.as_string())); |
cc387008223e
6921317: (partial) G1: assert(top() == bottom() || zfs == Allocated,"Region must be empty, or we must be setting it to
apetrusenko
parents:
1489
diff
changeset
|
4700 } |
cc387008223e
6921317: (partial) G1: assert(top() == bottom() || zfs == Allocated,"Region must be empty, or we must be setting it to
apetrusenko
parents:
1489
diff
changeset
|
4701 #endif |
342 | 4702 _unclean_region_list.insert_before_head(r); |
4703 } | |
4704 | |
4705 void | |
4706 G1CollectedHeap::prepend_region_list_on_unclean_list(UncleanRegionList* list) { | |
4707 MutexLockerEx x(ZF_mon, Mutex::_no_safepoint_check_flag); | |
4708 prepend_region_list_on_unclean_list_locked(list); | |
4709 if (should_zf()) ZF_mon->notify_all(); // Wake up ZF thread. | |
4710 } | |
4711 | |
4712 void | |
4713 G1CollectedHeap:: | |
4714 prepend_region_list_on_unclean_list_locked(UncleanRegionList* list) { | |
4715 assert(ZF_mon->owned_by_self(), "precondition."); | |
4716 _unclean_region_list.prepend_list(list); | |
4717 } | |
4718 | |
4719 HeapRegion* G1CollectedHeap::pop_unclean_region_list_locked() { | |
4720 assert(ZF_mon->owned_by_self(), "precondition."); | |
4721 HeapRegion* res = _unclean_region_list.pop(); | |
4722 if (res != NULL) { | |
4723 // Inform ZF thread that there's a new unclean head. | |
4724 if (_unclean_region_list.hd() != NULL && should_zf()) | |
4725 ZF_mon->notify_all(); | |
4726 } | |
4727 return res; | |
4728 } | |
4729 | |
4730 HeapRegion* G1CollectedHeap::peek_unclean_region_list_locked() { | |
4731 assert(ZF_mon->owned_by_self(), "precondition."); | |
4732 return _unclean_region_list.hd(); | |
4733 } | |
4734 | |
4735 | |
4736 bool G1CollectedHeap::move_cleaned_region_to_free_list_locked() { | |
4737 assert(ZF_mon->owned_by_self(), "Precondition"); | |
4738 HeapRegion* r = peek_unclean_region_list_locked(); | |
4739 if (r != NULL && r->zero_fill_state() == HeapRegion::ZeroFilled) { | |
4740 // Result of below must be equal to "r", since we hold the lock. | |
4741 (void)pop_unclean_region_list_locked(); | |
4742 put_free_region_on_list_locked(r); | |
4743 return true; | |
4744 } else { | |
4745 return false; | |
4746 } | |
4747 } | |
4748 | |
4749 bool G1CollectedHeap::move_cleaned_region_to_free_list() { | |
4750 MutexLockerEx x(ZF_mon, Mutex::_no_safepoint_check_flag); | |
4751 return move_cleaned_region_to_free_list_locked(); | |
4752 } | |
4753 | |
4754 | |
4755 void G1CollectedHeap::put_free_region_on_list_locked(HeapRegion* r) { | |
4756 assert(ZF_mon->owned_by_self(), "precondition."); | |
4757 assert(_free_region_list_size == free_region_list_length(), "Inv"); | |
4758 assert(r->zero_fill_state() == HeapRegion::ZeroFilled, | |
4759 "Regions on free list must be zero filled"); | |
4760 assert(!r->isHumongous(), "Must not be humongous."); | |
4761 assert(r->is_empty(), "Better be empty"); | |
4762 assert(!r->is_on_free_list(), | |
4763 "Better not already be on free list"); | |
4764 assert(!r->is_on_unclean_list(), | |
4765 "Better not already be on unclean list"); | |
4766 r->set_on_free_list(true); | |
4767 r->set_next_on_free_list(_free_region_list); | |
4768 _free_region_list = r; | |
4769 _free_region_list_size++; | |
4770 assert(_free_region_list_size == free_region_list_length(), "Inv"); | |
4771 } | |
4772 | |
4773 void G1CollectedHeap::put_free_region_on_list(HeapRegion* r) { | |
4774 MutexLockerEx x(ZF_mon, Mutex::_no_safepoint_check_flag); | |
4775 put_free_region_on_list_locked(r); | |
4776 } | |
4777 | |
4778 HeapRegion* G1CollectedHeap::pop_free_region_list_locked() { | |
4779 assert(ZF_mon->owned_by_self(), "precondition."); | |
4780 assert(_free_region_list_size == free_region_list_length(), "Inv"); | |
4781 HeapRegion* res = _free_region_list; | |
4782 if (res != NULL) { | |
4783 _free_region_list = res->next_from_free_list(); | |
4784 _free_region_list_size--; | |
4785 res->set_on_free_list(false); | |
4786 res->set_next_on_free_list(NULL); | |
4787 assert(_free_region_list_size == free_region_list_length(), "Inv"); | |
4788 } | |
4789 return res; | |
4790 } | |
4791 | |
4792 | |
4793 HeapRegion* G1CollectedHeap::alloc_free_region_from_lists(bool zero_filled) { | |
4794 // By self, or on behalf of self. | |
4795 assert(Heap_lock->is_locked(), "Precondition"); | |
4796 HeapRegion* res = NULL; | |
4797 bool first = true; | |
4798 while (res == NULL) { | |
4799 if (zero_filled || !first) { | |
4800 MutexLockerEx x(ZF_mon, Mutex::_no_safepoint_check_flag); | |
4801 res = pop_free_region_list_locked(); | |
4802 if (res != NULL) { | |
4803 assert(!res->zero_fill_is_allocated(), | |
4804 "No allocated regions on free list."); | |
4805 res->set_zero_fill_allocated(); | |
4806 } else if (!first) { | |
4807 break; // We tried both, time to return NULL. | |
4808 } | |
4809 } | |
4810 | |
4811 if (res == NULL) { | |
4812 res = alloc_region_from_unclean_list(zero_filled); | |
4813 } | |
4814 assert(res == NULL || | |
4815 !zero_filled || | |
4816 res->zero_fill_is_allocated(), | |
4817 "We must have allocated the region we're returning"); | |
4818 first = false; | |
4819 } | |
4820 return res; | |
4821 } | |
4822 | |
4823 void G1CollectedHeap::remove_allocated_regions_from_lists() { | |
4824 MutexLockerEx x(ZF_mon, Mutex::_no_safepoint_check_flag); | |
4825 { | |
4826 HeapRegion* prev = NULL; | |
4827 HeapRegion* cur = _unclean_region_list.hd(); | |
4828 while (cur != NULL) { | |
4829 HeapRegion* next = cur->next_from_unclean_list(); | |
4830 if (cur->zero_fill_is_allocated()) { | |
4831 // Remove from the list. | |
4832 if (prev == NULL) { | |
4833 (void)_unclean_region_list.pop(); | |
4834 } else { | |
4835 _unclean_region_list.delete_after(prev); | |
4836 } | |
4837 cur->set_on_unclean_list(false); | |
4838 cur->set_next_on_unclean_list(NULL); | |
4839 } else { | |
4840 prev = cur; | |
4841 } | |
4842 cur = next; | |
4843 } | |
4844 assert(_unclean_region_list.sz() == unclean_region_list_length(), | |
4845 "Inv"); | |
4846 } | |
4847 | |
4848 { | |
4849 HeapRegion* prev = NULL; | |
4850 HeapRegion* cur = _free_region_list; | |
4851 while (cur != NULL) { | |
4852 HeapRegion* next = cur->next_from_free_list(); | |
4853 if (cur->zero_fill_is_allocated()) { | |
4854 // Remove from the list. | |
4855 if (prev == NULL) { | |
4856 _free_region_list = cur->next_from_free_list(); | |
4857 } else { | |
4858 prev->set_next_on_free_list(cur->next_from_free_list()); | |
4859 } | |
4860 cur->set_on_free_list(false); | |
4861 cur->set_next_on_free_list(NULL); | |
4862 _free_region_list_size--; | |
4863 } else { | |
4864 prev = cur; | |
4865 } | |
4866 cur = next; | |
4867 } | |
4868 assert(_free_region_list_size == free_region_list_length(), "Inv"); | |
4869 } | |
4870 } | |
4871 | |
4872 bool G1CollectedHeap::verify_region_lists() { | |
4873 MutexLockerEx x(ZF_mon, Mutex::_no_safepoint_check_flag); | |
4874 return verify_region_lists_locked(); | |
4875 } | |
4876 | |
4877 bool G1CollectedHeap::verify_region_lists_locked() { | |
4878 HeapRegion* unclean = _unclean_region_list.hd(); | |
4879 while (unclean != NULL) { | |
4880 guarantee(unclean->is_on_unclean_list(), "Well, it is!"); | |
4881 guarantee(!unclean->is_on_free_list(), "Well, it shouldn't be!"); | |
4882 guarantee(unclean->zero_fill_state() != HeapRegion::Allocated, | |
4883 "Everything else is possible."); | |
4884 unclean = unclean->next_from_unclean_list(); | |
4885 } | |
4886 guarantee(_unclean_region_list.sz() == unclean_region_list_length(), "Inv"); | |
4887 | |
4888 HeapRegion* free_r = _free_region_list; | |
4889 while (free_r != NULL) { | |
4890 assert(free_r->is_on_free_list(), "Well, it is!"); | |
4891 assert(!free_r->is_on_unclean_list(), "Well, it shouldn't be!"); | |
4892 switch (free_r->zero_fill_state()) { | |
4893 case HeapRegion::NotZeroFilled: | |
4894 case HeapRegion::ZeroFilling: | |
4895 guarantee(false, "Should not be on free list."); | |
4896 break; | |
4897 default: | |
4898 // Everything else is possible. | |
4899 break; | |
4900 } | |
4901 free_r = free_r->next_from_free_list(); | |
4902 } | |
4903 guarantee(_free_region_list_size == free_region_list_length(), "Inv"); | |
4904 // If we didn't do an assertion... | |
4905 return true; | |
4906 } | |
4907 | |
4908 size_t G1CollectedHeap::free_region_list_length() { | |
4909 assert(ZF_mon->owned_by_self(), "precondition."); | |
4910 size_t len = 0; | |
4911 HeapRegion* cur = _free_region_list; | |
4912 while (cur != NULL) { | |
4913 len++; | |
4914 cur = cur->next_from_free_list(); | |
4915 } | |
4916 return len; | |
4917 } | |
4918 | |
4919 size_t G1CollectedHeap::unclean_region_list_length() { | |
4920 assert(ZF_mon->owned_by_self(), "precondition."); | |
4921 return _unclean_region_list.length(); | |
4922 } | |
4923 | |
4924 size_t G1CollectedHeap::n_regions() { | |
4925 return _hrs->length(); | |
4926 } | |
4927 | |
4928 size_t G1CollectedHeap::max_regions() { | |
4929 return | |
4930 (size_t)align_size_up(g1_reserved_obj_bytes(), HeapRegion::GrainBytes) / | |
4931 HeapRegion::GrainBytes; | |
4932 } | |
4933 | |
4934 size_t G1CollectedHeap::free_regions() { | |
4935 /* Possibly-expensive assert. | |
4936 assert(_free_regions == count_free_regions(), | |
4937 "_free_regions is off."); | |
4938 */ | |
4939 return _free_regions; | |
4940 } | |
4941 | |
4942 bool G1CollectedHeap::should_zf() { | |
4943 return _free_region_list_size < (size_t) G1ConcZFMaxRegions; | |
4944 } | |
4945 | |
4946 class RegionCounter: public HeapRegionClosure { | |
4947 size_t _n; | |
4948 public: | |
4949 RegionCounter() : _n(0) {} | |
4950 bool doHeapRegion(HeapRegion* r) { | |
677 | 4951 if (r->is_empty()) { |
342 | 4952 assert(!r->isHumongous(), "H regions should not be empty."); |
4953 _n++; | |
4954 } | |
4955 return false; | |
4956 } | |
4957 int res() { return (int) _n; } | |
4958 }; | |
4959 | |
4960 size_t G1CollectedHeap::count_free_regions() { | |
4961 RegionCounter rc; | |
4962 heap_region_iterate(&rc); | |
4963 size_t n = rc.res(); | |
4964 if (_cur_alloc_region != NULL && _cur_alloc_region->is_empty()) | |
4965 n--; | |
4966 return n; | |
4967 } | |
4968 | |
4969 size_t G1CollectedHeap::count_free_regions_list() { | |
4970 size_t n = 0; | |
4971 size_t o = 0; | |
4972 ZF_mon->lock_without_safepoint_check(); | |
4973 HeapRegion* cur = _free_region_list; | |
4974 while (cur != NULL) { | |
4975 cur = cur->next_from_free_list(); | |
4976 n++; | |
4977 } | |
4978 size_t m = unclean_region_list_length(); | |
4979 ZF_mon->unlock(); | |
4980 return n + m; | |
4981 } | |
4982 | |
4983 bool G1CollectedHeap::should_set_young_locked() { | |
4984 assert(heap_lock_held_for_gc(), | |
4985 "the heap lock should already be held by or for this thread"); | |
4986 return (g1_policy()->in_young_gc_mode() && | |
4987 g1_policy()->should_add_next_region_to_young_list()); | |
4988 } | |
4989 | |
4990 void G1CollectedHeap::set_region_short_lived_locked(HeapRegion* hr) { | |
4991 assert(heap_lock_held_for_gc(), | |
4992 "the heap lock should already be held by or for this thread"); | |
4993 _young_list->push_region(hr); | |
4994 g1_policy()->set_region_short_lived(hr); | |
4995 } | |
4996 | |
4997 class NoYoungRegionsClosure: public HeapRegionClosure { | |
4998 private: | |
4999 bool _success; | |
5000 public: | |
5001 NoYoungRegionsClosure() : _success(true) { } | |
5002 bool doHeapRegion(HeapRegion* r) { | |
5003 if (r->is_young()) { | |
5004 gclog_or_tty->print_cr("Region ["PTR_FORMAT", "PTR_FORMAT") tagged as young", | |
5005 r->bottom(), r->end()); | |
5006 _success = false; | |
5007 } | |
5008 return false; | |
5009 } | |
5010 bool success() { return _success; } | |
5011 }; | |
5012 | |
1394
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
5013 bool G1CollectedHeap::check_young_list_empty(bool check_heap, bool check_sample) { |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
5014 bool ret = _young_list->check_list_empty(check_sample); |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
5015 |
1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
1391
diff
changeset
|
5016 if (check_heap) { |
342 | 5017 NoYoungRegionsClosure closure; |
5018 heap_region_iterate(&closure); | |
5019 ret = ret && closure.success(); | |
5020 } | |
5021 | |
5022 return ret; | |
5023 } | |
5024 | |
5025 void G1CollectedHeap::empty_young_list() { | |
5026 assert(heap_lock_held_for_gc(), | |
5027 "the heap lock should already be held by or for this thread"); | |
5028 assert(g1_policy()->in_young_gc_mode(), "should be in young GC mode"); | |
5029 | |
5030 _young_list->empty_list(); | |
5031 } | |
5032 | |
5033 bool G1CollectedHeap::all_alloc_regions_no_allocs_since_save_marks() { | |
5034 bool no_allocs = true; | |
5035 for (int ap = 0; ap < GCAllocPurposeCount && no_allocs; ++ap) { | |
5036 HeapRegion* r = _gc_alloc_regions[ap]; | |
5037 no_allocs = r == NULL || r->saved_mark_at_top(); | |
5038 } | |
5039 return no_allocs; | |
5040 } | |
5041 | |
545 | 5042 void G1CollectedHeap::retire_all_alloc_regions() { |
342 | 5043 for (int ap = 0; ap < GCAllocPurposeCount; ++ap) { |
5044 HeapRegion* r = _gc_alloc_regions[ap]; | |
5045 if (r != NULL) { | |
5046 // Check for aliases. | |
5047 bool has_processed_alias = false; | |
5048 for (int i = 0; i < ap; ++i) { | |
5049 if (_gc_alloc_regions[i] == r) { | |
5050 has_processed_alias = true; | |
5051 break; | |
5052 } | |
5053 } | |
5054 if (!has_processed_alias) { | |
545 | 5055 retire_alloc_region(r, false /* par */); |
342 | 5056 } |
5057 } | |
5058 } | |
5059 } | |
5060 | |
5061 | |
5062 // Done at the start of full GC. | |
5063 void G1CollectedHeap::tear_down_region_lists() { | |
5064 MutexLockerEx x(ZF_mon, Mutex::_no_safepoint_check_flag); | |
5065 while (pop_unclean_region_list_locked() != NULL) ; | |
5066 assert(_unclean_region_list.hd() == NULL && _unclean_region_list.sz() == 0, | |
1489
cff162798819
6888953: some calls to function-like macros are missing semicolons
jcoomes
parents:
1394
diff
changeset
|
5067 "Postconditions of loop."); |
342 | 5068 while (pop_free_region_list_locked() != NULL) ; |
5069 assert(_free_region_list == NULL, "Postcondition of loop."); | |
5070 if (_free_region_list_size != 0) { | |
5071 gclog_or_tty->print_cr("Size is %d.", _free_region_list_size); | |
838
0316eac49d5a
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
tonyp
parents:
811
diff
changeset
|
5072 print_on(gclog_or_tty, true /* extended */); |
342 | 5073 } |
5074 assert(_free_region_list_size == 0, "Postconditions of loop."); | |
5075 } | |
5076 | |
5077 | |
5078 class RegionResetter: public HeapRegionClosure { | |
5079 G1CollectedHeap* _g1; | |
5080 int _n; | |
5081 public: | |
5082 RegionResetter() : _g1(G1CollectedHeap::heap()), _n(0) {} | |
5083 bool doHeapRegion(HeapRegion* r) { | |
5084 if (r->continuesHumongous()) return false; | |
5085 if (r->top() > r->bottom()) { | |
5086 if (r->top() < r->end()) { | |
5087 Copy::fill_to_words(r->top(), | |
5088 pointer_delta(r->end(), r->top())); | |
5089 } | |
5090 r->set_zero_fill_allocated(); | |
5091 } else { | |
5092 assert(r->is_empty(), "tautology"); | |
677 | 5093 _n++; |
5094 switch (r->zero_fill_state()) { | |
342 | 5095 case HeapRegion::NotZeroFilled: |
5096 case HeapRegion::ZeroFilling: | |
5097 _g1->put_region_on_unclean_list_locked(r); | |
5098 break; | |
5099 case HeapRegion::Allocated: | |
5100 r->set_zero_fill_complete(); | |
5101 // no break; go on to put on free list. | |
5102 case HeapRegion::ZeroFilled: | |
5103 _g1->put_free_region_on_list_locked(r); | |
5104 break; | |
5105 } | |
5106 } | |
5107 return false; | |
5108 } | |
5109 | |
5110 int getFreeRegionCount() {return _n;} | |
5111 }; | |
5112 | |
5113 // Done at the end of full GC. | |
5114 void G1CollectedHeap::rebuild_region_lists() { | |
5115 MutexLockerEx x(ZF_mon, Mutex::_no_safepoint_check_flag); | |
5116 // This needs to go at the end of the full GC. | |
5117 RegionResetter rs; | |
5118 heap_region_iterate(&rs); | |
5119 _free_regions = rs.getFreeRegionCount(); | |
5120 // Tell the ZF thread it may have work to do. | |
5121 if (should_zf()) ZF_mon->notify_all(); | |
5122 } | |
5123 | |
5124 class UsedRegionsNeedZeroFillSetter: public HeapRegionClosure { | |
5125 G1CollectedHeap* _g1; | |
5126 int _n; | |
5127 public: | |
5128 UsedRegionsNeedZeroFillSetter() : _g1(G1CollectedHeap::heap()), _n(0) {} | |
5129 bool doHeapRegion(HeapRegion* r) { | |
5130 if (r->continuesHumongous()) return false; | |
5131 if (r->top() > r->bottom()) { | |
5132 // There are assertions in "set_zero_fill_needed()" below that | |
5133 // require top() == bottom(), so this is technically illegal. | |
5134 // We'll skirt the law here, by making that true temporarily. | |
5135 DEBUG_ONLY(HeapWord* save_top = r->top(); | |
5136 r->set_top(r->bottom())); | |
5137 r->set_zero_fill_needed(); | |
5138 DEBUG_ONLY(r->set_top(save_top)); | |
5139 } | |
5140 return false; | |
5141 } | |
5142 }; | |
5143 | |
5144 // Done at the start of full GC. | |
5145 void G1CollectedHeap::set_used_regions_to_need_zero_fill() { | |
5146 MutexLockerEx x(ZF_mon, Mutex::_no_safepoint_check_flag); | |
5147 // This needs to go at the end of the full GC. | |
5148 UsedRegionsNeedZeroFillSetter rs; | |
5149 heap_region_iterate(&rs); | |
5150 } | |
5151 | |
5152 void G1CollectedHeap::set_refine_cte_cl_concurrency(bool concurrent) { | |
5153 _refine_cte_cl->set_concurrent(concurrent); | |
5154 } | |
5155 | |
5156 #ifndef PRODUCT | |
5157 | |
5158 class PrintHeapRegionClosure: public HeapRegionClosure { | |
5159 public: | |
5160 bool doHeapRegion(HeapRegion *r) { | |
5161 gclog_or_tty->print("Region: "PTR_FORMAT":", r); | |
5162 if (r != NULL) { | |
5163 if (r->is_on_free_list()) | |
5164 gclog_or_tty->print("Free "); | |
5165 if (r->is_young()) | |
5166 gclog_or_tty->print("Young "); | |
5167 if (r->isHumongous()) | |
5168 gclog_or_tty->print("Is Humongous "); | |
5169 r->print(); | |
5170 } | |
5171 return false; | |
5172 } | |
5173 }; | |
5174 | |
5175 class SortHeapRegionClosure : public HeapRegionClosure { | |
5176 size_t young_regions,free_regions, unclean_regions; | |
5177 size_t hum_regions, count; | |
5178 size_t unaccounted, cur_unclean, cur_alloc; | |
5179 size_t total_free; | |
5180 HeapRegion* cur; | |
5181 public: | |
5182 SortHeapRegionClosure(HeapRegion *_cur) : cur(_cur), young_regions(0), | |
5183 free_regions(0), unclean_regions(0), | |
5184 hum_regions(0), | |
5185 count(0), unaccounted(0), | |
5186 cur_alloc(0), total_free(0) | |
5187 {} | |
5188 bool doHeapRegion(HeapRegion *r) { | |
5189 count++; | |
5190 if (r->is_on_free_list()) free_regions++; | |
5191 else if (r->is_on_unclean_list()) unclean_regions++; | |
5192 else if (r->isHumongous()) hum_regions++; | |
5193 else if (r->is_young()) young_regions++; | |
5194 else if (r == cur) cur_alloc++; | |
5195 else unaccounted++; | |
5196 return false; | |
5197 } | |
5198 void print() { | |
5199 total_free = free_regions + unclean_regions; | |
5200 gclog_or_tty->print("%d regions\n", count); | |
5201 gclog_or_tty->print("%d free: free_list = %d unclean = %d\n", | |
5202 total_free, free_regions, unclean_regions); | |
5203 gclog_or_tty->print("%d humongous %d young\n", | |
5204 hum_regions, young_regions); | |
5205 gclog_or_tty->print("%d cur_alloc\n", cur_alloc); | |
5206 gclog_or_tty->print("UHOH unaccounted = %d\n", unaccounted); | |
5207 } | |
5208 }; | |
5209 | |
5210 void G1CollectedHeap::print_region_counts() { | |
5211 SortHeapRegionClosure sc(_cur_alloc_region); | |
5212 PrintHeapRegionClosure cl; | |
5213 heap_region_iterate(&cl); | |
5214 heap_region_iterate(&sc); | |
5215 sc.print(); | |
5216 print_region_accounting_info(); | |
5217 }; | |
5218 | |
5219 bool G1CollectedHeap::regions_accounted_for() { | |
5220 // TODO: regions accounting for young/survivor/tenured | |
5221 return true; | |
5222 } | |
5223 | |
5224 bool G1CollectedHeap::print_region_accounting_info() { | |
5225 gclog_or_tty->print_cr("Free regions: %d (count: %d count list %d) (clean: %d unclean: %d).", | |
5226 free_regions(), | |
5227 count_free_regions(), count_free_regions_list(), | |
5228 _free_region_list_size, _unclean_region_list.sz()); | |
5229 gclog_or_tty->print_cr("cur_alloc: %d.", | |
5230 (_cur_alloc_region == NULL ? 0 : 1)); | |
5231 gclog_or_tty->print_cr("H regions: %d.", _num_humongous_regions); | |
5232 | |
5233 // TODO: check regions accounting for young/survivor/tenured | |
5234 return true; | |
5235 } | |
5236 | |
5237 bool G1CollectedHeap::is_in_closed_subset(const void* p) const { | |
5238 HeapRegion* hr = heap_region_containing(p); | |
5239 if (hr == NULL) { | |
5240 return is_in_permanent(p); | |
5241 } else { | |
5242 return hr->is_in(p); | |
5243 } | |
5244 } | |
941 | 5245 #endif // !PRODUCT |
342 | 5246 |
5247 void G1CollectedHeap::g1_unimplemented() { | |
5248 // Unimplemented(); | |
5249 } |