Mercurial > hg > graal-compiler
annotate src/share/vm/gc_implementation/parallelScavenge/psYoungGen.cpp @ 2149:7e37af9d69ef
7011379: G1: overly long concurrent marking cycles
Summary: This changeset introduces filtering of SATB buffers at the point when they are about to be enqueued. If this filtering clears enough entries on each buffer, the buffer can then be re-used and not enqueued. This cuts down the number of SATB buffers that need to be processed by the concurrent marking threads.
Reviewed-by: johnc, ysr
author | tonyp |
---|---|
date | Wed, 19 Jan 2011 09:35:17 -0500 |
parents | f95d63e2154a |
children | eda9eb483d29 |
rev | line source |
---|---|
0 | 1 /* |
1972 | 2 * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved. |
0 | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1489
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1489
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:
1489
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
1972 | 25 #include "precompiled.hpp" |
26 #include "gc_implementation/parallelScavenge/parallelScavengeHeap.hpp" | |
27 #include "gc_implementation/parallelScavenge/psMarkSweepDecorator.hpp" | |
28 #include "gc_implementation/parallelScavenge/psScavenge.hpp" | |
29 #include "gc_implementation/parallelScavenge/psYoungGen.hpp" | |
30 #include "gc_implementation/shared/gcUtil.hpp" | |
31 #include "gc_implementation/shared/mutableNUMASpace.hpp" | |
32 #include "gc_implementation/shared/spaceDecorator.hpp" | |
33 #include "oops/oop.inline.hpp" | |
34 #include "runtime/java.hpp" | |
0 | 35 |
36 PSYoungGen::PSYoungGen(size_t initial_size, | |
37 size_t min_size, | |
38 size_t max_size) : | |
39 _init_gen_size(initial_size), | |
40 _min_gen_size(min_size), | |
41 _max_gen_size(max_size) | |
42 {} | |
43 | |
44 void PSYoungGen::initialize_virtual_space(ReservedSpace rs, size_t alignment) { | |
45 assert(_init_gen_size != 0, "Should have a finite size"); | |
46 _virtual_space = new PSVirtualSpace(rs, alignment); | |
263
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
47 if (!virtual_space()->expand_by(_init_gen_size)) { |
0 | 48 vm_exit_during_initialization("Could not reserve enough space for " |
49 "object heap"); | |
50 } | |
51 } | |
52 | |
53 void PSYoungGen::initialize(ReservedSpace rs, size_t alignment) { | |
54 initialize_virtual_space(rs, alignment); | |
55 initialize_work(); | |
56 } | |
57 | |
58 void PSYoungGen::initialize_work() { | |
59 | |
263
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
60 _reserved = MemRegion((HeapWord*)virtual_space()->low_boundary(), |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
61 (HeapWord*)virtual_space()->high_boundary()); |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
62 |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
63 MemRegion cmr((HeapWord*)virtual_space()->low(), |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
64 (HeapWord*)virtual_space()->high()); |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
65 Universe::heap()->barrier_set()->resize_covered_region(cmr); |
0 | 66 |
263
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
67 if (ZapUnusedHeapArea) { |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
68 // Mangle newly committed space immediately because it |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
69 // can be done here more simply that after the new |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
70 // spaces have been computed. |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
71 SpaceMangler::mangle_region(cmr); |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
72 } |
0 | 73 |
74 if (UseNUMA) { | |
535
4e400c36026f
6783381: NUMA allocator: don't pretouch eden space with UseNUMA
iveresov
parents:
269
diff
changeset
|
75 _eden_space = new MutableNUMASpace(virtual_space()->alignment()); |
0 | 76 } else { |
535
4e400c36026f
6783381: NUMA allocator: don't pretouch eden space with UseNUMA
iveresov
parents:
269
diff
changeset
|
77 _eden_space = new MutableSpace(virtual_space()->alignment()); |
0 | 78 } |
535
4e400c36026f
6783381: NUMA allocator: don't pretouch eden space with UseNUMA
iveresov
parents:
269
diff
changeset
|
79 _from_space = new MutableSpace(virtual_space()->alignment()); |
4e400c36026f
6783381: NUMA allocator: don't pretouch eden space with UseNUMA
iveresov
parents:
269
diff
changeset
|
80 _to_space = new MutableSpace(virtual_space()->alignment()); |
0 | 81 |
82 if (_eden_space == NULL || _from_space == NULL || _to_space == NULL) { | |
83 vm_exit_during_initialization("Could not allocate a young gen space"); | |
84 } | |
85 | |
86 // Allocate the mark sweep views of spaces | |
87 _eden_mark_sweep = | |
88 new PSMarkSweepDecorator(_eden_space, NULL, MarkSweepDeadRatio); | |
89 _from_mark_sweep = | |
90 new PSMarkSweepDecorator(_from_space, NULL, MarkSweepDeadRatio); | |
91 _to_mark_sweep = | |
92 new PSMarkSweepDecorator(_to_space, NULL, MarkSweepDeadRatio); | |
93 | |
94 if (_eden_mark_sweep == NULL || | |
95 _from_mark_sweep == NULL || | |
96 _to_mark_sweep == NULL) { | |
97 vm_exit_during_initialization("Could not complete allocation" | |
98 " of the young generation"); | |
99 } | |
100 | |
101 // Generation Counters - generation 0, 3 subspaces | |
102 _gen_counters = new PSGenerationCounters("new", 0, 3, _virtual_space); | |
103 | |
104 // Compute maximum space sizes for performance counters | |
105 ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap(); | |
13
183f41cf8bfe
6557851: CMS: ergonomics defaults are not set with FLAG_SET_ERGO
jmasa
parents:
0
diff
changeset
|
106 size_t alignment = heap->intra_heap_alignment(); |
263
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
107 size_t size = virtual_space()->reserved_size(); |
0 | 108 |
109 size_t max_survivor_size; | |
110 size_t max_eden_size; | |
111 | |
112 if (UseAdaptiveSizePolicy) { | |
113 max_survivor_size = size / MinSurvivorRatio; | |
114 | |
115 // round the survivor space size down to the nearest alignment | |
116 // and make sure its size is greater than 0. | |
117 max_survivor_size = align_size_down(max_survivor_size, alignment); | |
118 max_survivor_size = MAX2(max_survivor_size, alignment); | |
119 | |
120 // set the maximum size of eden to be the size of the young gen | |
121 // less two times the minimum survivor size. The minimum survivor | |
122 // size for UseAdaptiveSizePolicy is one alignment. | |
123 max_eden_size = size - 2 * alignment; | |
124 } else { | |
125 max_survivor_size = size / InitialSurvivorRatio; | |
126 | |
127 // round the survivor space size down to the nearest alignment | |
128 // and make sure its size is greater than 0. | |
129 max_survivor_size = align_size_down(max_survivor_size, alignment); | |
130 max_survivor_size = MAX2(max_survivor_size, alignment); | |
131 | |
132 // set the maximum size of eden to be the size of the young gen | |
133 // less two times the survivor size when the generation is 100% | |
134 // committed. The minimum survivor size for -UseAdaptiveSizePolicy | |
135 // is dependent on the committed portion (current capacity) of the | |
136 // generation - the less space committed, the smaller the survivor | |
137 // space, possibly as small as an alignment. However, we are interested | |
138 // in the case where the young generation is 100% committed, as this | |
139 // is the point where eden reachs its maximum size. At this point, | |
140 // the size of a survivor space is max_survivor_size. | |
141 max_eden_size = size - 2 * max_survivor_size; | |
142 } | |
143 | |
144 _eden_counters = new SpaceCounters("eden", 0, max_eden_size, _eden_space, | |
145 _gen_counters); | |
146 _from_counters = new SpaceCounters("s0", 1, max_survivor_size, _from_space, | |
147 _gen_counters); | |
148 _to_counters = new SpaceCounters("s1", 2, max_survivor_size, _to_space, | |
149 _gen_counters); | |
150 | |
151 compute_initial_space_boundaries(); | |
152 } | |
153 | |
154 void PSYoungGen::compute_initial_space_boundaries() { | |
155 ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap(); | |
156 assert(heap->kind() == CollectedHeap::ParallelScavengeHeap, "Sanity"); | |
157 | |
158 // Compute sizes | |
13
183f41cf8bfe
6557851: CMS: ergonomics defaults are not set with FLAG_SET_ERGO
jmasa
parents:
0
diff
changeset
|
159 size_t alignment = heap->intra_heap_alignment(); |
263
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
160 size_t size = virtual_space()->committed_size(); |
0 | 161 |
162 size_t survivor_size = size / InitialSurvivorRatio; | |
163 survivor_size = align_size_down(survivor_size, alignment); | |
164 // ... but never less than an alignment | |
165 survivor_size = MAX2(survivor_size, alignment); | |
166 | |
167 // Young generation is eden + 2 survivor spaces | |
168 size_t eden_size = size - (2 * survivor_size); | |
169 | |
170 // Now go ahead and set 'em. | |
171 set_space_boundaries(eden_size, survivor_size); | |
172 space_invariants(); | |
173 | |
174 if (UsePerfData) { | |
175 _eden_counters->update_capacity(); | |
176 _from_counters->update_capacity(); | |
177 _to_counters->update_capacity(); | |
178 } | |
179 } | |
180 | |
181 void PSYoungGen::set_space_boundaries(size_t eden_size, size_t survivor_size) { | |
263
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
182 assert(eden_size < virtual_space()->committed_size(), "just checking"); |
0 | 183 assert(eden_size > 0 && survivor_size > 0, "just checking"); |
184 | |
185 // Initial layout is Eden, to, from. After swapping survivor spaces, | |
186 // that leaves us with Eden, from, to, which is step one in our two | |
187 // step resize-with-live-data procedure. | |
263
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
188 char *eden_start = virtual_space()->low(); |
0 | 189 char *to_start = eden_start + eden_size; |
190 char *from_start = to_start + survivor_size; | |
191 char *from_end = from_start + survivor_size; | |
192 | |
263
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
193 assert(from_end == virtual_space()->high(), "just checking"); |
0 | 194 assert(is_object_aligned((intptr_t)eden_start), "checking alignment"); |
195 assert(is_object_aligned((intptr_t)to_start), "checking alignment"); | |
196 assert(is_object_aligned((intptr_t)from_start), "checking alignment"); | |
197 | |
198 MemRegion eden_mr((HeapWord*)eden_start, (HeapWord*)to_start); | |
199 MemRegion to_mr ((HeapWord*)to_start, (HeapWord*)from_start); | |
200 MemRegion from_mr((HeapWord*)from_start, (HeapWord*)from_end); | |
201 | |
263
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
202 eden_space()->initialize(eden_mr, true, ZapUnusedHeapArea); |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
203 to_space()->initialize(to_mr , true, ZapUnusedHeapArea); |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
204 from_space()->initialize(from_mr, true, ZapUnusedHeapArea); |
0 | 205 } |
206 | |
207 #ifndef PRODUCT | |
208 void PSYoungGen::space_invariants() { | |
209 ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap(); | |
13
183f41cf8bfe
6557851: CMS: ergonomics defaults are not set with FLAG_SET_ERGO
jmasa
parents:
0
diff
changeset
|
210 const size_t alignment = heap->intra_heap_alignment(); |
0 | 211 |
212 // Currently, our eden size cannot shrink to zero | |
213 guarantee(eden_space()->capacity_in_bytes() >= alignment, "eden too small"); | |
214 guarantee(from_space()->capacity_in_bytes() >= alignment, "from too small"); | |
215 guarantee(to_space()->capacity_in_bytes() >= alignment, "to too small"); | |
216 | |
217 // Relationship of spaces to each other | |
218 char* eden_start = (char*)eden_space()->bottom(); | |
219 char* eden_end = (char*)eden_space()->end(); | |
220 char* from_start = (char*)from_space()->bottom(); | |
221 char* from_end = (char*)from_space()->end(); | |
222 char* to_start = (char*)to_space()->bottom(); | |
223 char* to_end = (char*)to_space()->end(); | |
224 | |
263
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
225 guarantee(eden_start >= virtual_space()->low(), "eden bottom"); |
0 | 226 guarantee(eden_start < eden_end, "eden space consistency"); |
227 guarantee(from_start < from_end, "from space consistency"); | |
228 guarantee(to_start < to_end, "to space consistency"); | |
229 | |
230 // Check whether from space is below to space | |
231 if (from_start < to_start) { | |
232 // Eden, from, to | |
233 guarantee(eden_end <= from_start, "eden/from boundary"); | |
234 guarantee(from_end <= to_start, "from/to boundary"); | |
263
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
235 guarantee(to_end <= virtual_space()->high(), "to end"); |
0 | 236 } else { |
237 // Eden, to, from | |
238 guarantee(eden_end <= to_start, "eden/to boundary"); | |
239 guarantee(to_end <= from_start, "to/from boundary"); | |
263
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
240 guarantee(from_end <= virtual_space()->high(), "from end"); |
0 | 241 } |
242 | |
243 // More checks that the virtual space is consistent with the spaces | |
263
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
244 assert(virtual_space()->committed_size() >= |
0 | 245 (eden_space()->capacity_in_bytes() + |
246 to_space()->capacity_in_bytes() + | |
247 from_space()->capacity_in_bytes()), "Committed size is inconsistent"); | |
263
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
248 assert(virtual_space()->committed_size() <= virtual_space()->reserved_size(), |
0 | 249 "Space invariant"); |
250 char* eden_top = (char*)eden_space()->top(); | |
251 char* from_top = (char*)from_space()->top(); | |
252 char* to_top = (char*)to_space()->top(); | |
263
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
253 assert(eden_top <= virtual_space()->high(), "eden top"); |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
254 assert(from_top <= virtual_space()->high(), "from top"); |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
255 assert(to_top <= virtual_space()->high(), "to top"); |
0 | 256 |
263
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
257 virtual_space()->verify(); |
0 | 258 } |
259 #endif | |
260 | |
261 void PSYoungGen::resize(size_t eden_size, size_t survivor_size) { | |
262 // Resize the generation if needed. If the generation resize | |
263 // reports false, do not attempt to resize the spaces. | |
264 if (resize_generation(eden_size, survivor_size)) { | |
265 // Then we lay out the spaces inside the generation | |
266 resize_spaces(eden_size, survivor_size); | |
267 | |
268 space_invariants(); | |
269 | |
270 if (PrintAdaptiveSizePolicy && Verbose) { | |
271 gclog_or_tty->print_cr("Young generation size: " | |
272 "desired eden: " SIZE_FORMAT " survivor: " SIZE_FORMAT | |
273 " used: " SIZE_FORMAT " capacity: " SIZE_FORMAT | |
274 " gen limits: " SIZE_FORMAT " / " SIZE_FORMAT, | |
275 eden_size, survivor_size, used_in_bytes(), capacity_in_bytes(), | |
276 _max_gen_size, min_gen_size()); | |
277 } | |
278 } | |
279 } | |
280 | |
281 | |
282 bool PSYoungGen::resize_generation(size_t eden_size, size_t survivor_size) { | |
263
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
283 const size_t alignment = virtual_space()->alignment(); |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
284 size_t orig_size = virtual_space()->committed_size(); |
0 | 285 bool size_changed = false; |
286 | |
287 // There used to be this guarantee there. | |
288 // guarantee ((eden_size + 2*survivor_size) <= _max_gen_size, "incorrect input arguments"); | |
289 // Code below forces this requirement. In addition the desired eden | |
290 // size and disired survivor sizes are desired goals and may | |
291 // exceed the total generation size. | |
292 | |
293 assert(min_gen_size() <= orig_size && orig_size <= max_size(), "just checking"); | |
294 | |
295 // Adjust new generation size | |
296 const size_t eden_plus_survivors = | |
297 align_size_up(eden_size + 2 * survivor_size, alignment); | |
298 size_t desired_size = MAX2(MIN2(eden_plus_survivors, max_size()), | |
299 min_gen_size()); | |
300 assert(desired_size <= max_size(), "just checking"); | |
301 | |
302 if (desired_size > orig_size) { | |
303 // Grow the generation | |
304 size_t change = desired_size - orig_size; | |
305 assert(change % alignment == 0, "just checking"); | |
263
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
306 HeapWord* prev_high = (HeapWord*) virtual_space()->high(); |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
307 if (!virtual_space()->expand_by(change)) { |
0 | 308 return false; // Error if we fail to resize! |
309 } | |
263
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
310 if (ZapUnusedHeapArea) { |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
311 // Mangle newly committed space immediately because it |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
312 // can be done here more simply that after the new |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
313 // spaces have been computed. |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
314 HeapWord* new_high = (HeapWord*) virtual_space()->high(); |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
315 MemRegion mangle_region(prev_high, new_high); |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
316 SpaceMangler::mangle_region(mangle_region); |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
317 } |
0 | 318 size_changed = true; |
319 } else if (desired_size < orig_size) { | |
320 size_t desired_change = orig_size - desired_size; | |
321 assert(desired_change % alignment == 0, "just checking"); | |
322 | |
323 desired_change = limit_gen_shrink(desired_change); | |
324 | |
325 if (desired_change > 0) { | |
326 virtual_space()->shrink_by(desired_change); | |
327 reset_survivors_after_shrink(); | |
328 | |
329 size_changed = true; | |
330 } | |
331 } else { | |
332 if (Verbose && PrintGC) { | |
333 if (orig_size == gen_size_limit()) { | |
334 gclog_or_tty->print_cr("PSYoung generation size at maximum: " | |
335 SIZE_FORMAT "K", orig_size/K); | |
336 } else if (orig_size == min_gen_size()) { | |
337 gclog_or_tty->print_cr("PSYoung generation size at minium: " | |
338 SIZE_FORMAT "K", orig_size/K); | |
339 } | |
340 } | |
341 } | |
342 | |
343 if (size_changed) { | |
344 post_resize(); | |
345 | |
346 if (Verbose && PrintGC) { | |
263
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
347 size_t current_size = virtual_space()->committed_size(); |
0 | 348 gclog_or_tty->print_cr("PSYoung generation size changed: " |
349 SIZE_FORMAT "K->" SIZE_FORMAT "K", | |
350 orig_size/K, current_size/K); | |
351 } | |
352 } | |
353 | |
263
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
354 guarantee(eden_plus_survivors <= virtual_space()->committed_size() || |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
355 virtual_space()->committed_size() == max_size(), "Sanity"); |
0 | 356 |
357 return true; | |
358 } | |
359 | |
263
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
360 #ifndef PRODUCT |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
361 // In the numa case eden is not mangled so a survivor space |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
362 // moving into a region previously occupied by a survivor |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
363 // may find an unmangled region. Also in the PS case eden |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
364 // to-space and from-space may not touch (i.e., there may be |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
365 // gaps between them due to movement while resizing the |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
366 // spaces). Those gaps must be mangled. |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
367 void PSYoungGen::mangle_survivors(MutableSpace* s1, |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
368 MemRegion s1MR, |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
369 MutableSpace* s2, |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
370 MemRegion s2MR) { |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
371 // Check eden and gap between eden and from-space, in deciding |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
372 // what to mangle in from-space. Check the gap between from-space |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
373 // and to-space when deciding what to mangle. |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
374 // |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
375 // +--------+ +----+ +---+ |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
376 // | eden | |s1 | |s2 | |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
377 // +--------+ +----+ +---+ |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
378 // +-------+ +-----+ |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
379 // |s1MR | |s2MR | |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
380 // +-------+ +-----+ |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
381 // All of survivor-space is properly mangled so find the |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
382 // upper bound on the mangling for any portion above current s1. |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
383 HeapWord* delta_end = MIN2(s1->bottom(), s1MR.end()); |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
384 MemRegion delta1_left; |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
385 if (s1MR.start() < delta_end) { |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
386 delta1_left = MemRegion(s1MR.start(), delta_end); |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
387 s1->mangle_region(delta1_left); |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
388 } |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
389 // Find any portion to the right of the current s1. |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
390 HeapWord* delta_start = MAX2(s1->end(), s1MR.start()); |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
391 MemRegion delta1_right; |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
392 if (delta_start < s1MR.end()) { |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
393 delta1_right = MemRegion(delta_start, s1MR.end()); |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
394 s1->mangle_region(delta1_right); |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
395 } |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
396 |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
397 // Similarly for the second survivor space except that |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
398 // any of the new region that overlaps with the current |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
399 // region of the first survivor space has already been |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
400 // mangled. |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
401 delta_end = MIN2(s2->bottom(), s2MR.end()); |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
402 delta_start = MAX2(s2MR.start(), s1->end()); |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
403 MemRegion delta2_left; |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
404 if (s2MR.start() < delta_end) { |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
405 delta2_left = MemRegion(s2MR.start(), delta_end); |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
406 s2->mangle_region(delta2_left); |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
407 } |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
408 delta_start = MAX2(s2->end(), s2MR.start()); |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
409 MemRegion delta2_right; |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
410 if (delta_start < s2MR.end()) { |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
411 s2->mangle_region(delta2_right); |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
412 } |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
413 |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
414 if (TraceZapUnusedHeapArea) { |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
415 // s1 |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
416 gclog_or_tty->print_cr("Current region: [" PTR_FORMAT ", " PTR_FORMAT ") " |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
417 "New region: [" PTR_FORMAT ", " PTR_FORMAT ")", |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
418 s1->bottom(), s1->end(), s1MR.start(), s1MR.end()); |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
419 gclog_or_tty->print_cr(" Mangle before: [" PTR_FORMAT ", " |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
420 PTR_FORMAT ") Mangle after: [" PTR_FORMAT ", " PTR_FORMAT ")", |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
421 delta1_left.start(), delta1_left.end(), delta1_right.start(), |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
422 delta1_right.end()); |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
423 |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
424 // s2 |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
425 gclog_or_tty->print_cr("Current region: [" PTR_FORMAT ", " PTR_FORMAT ") " |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
426 "New region: [" PTR_FORMAT ", " PTR_FORMAT ")", |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
427 s2->bottom(), s2->end(), s2MR.start(), s2MR.end()); |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
428 gclog_or_tty->print_cr(" Mangle before: [" PTR_FORMAT ", " |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
429 PTR_FORMAT ") Mangle after: [" PTR_FORMAT ", " PTR_FORMAT ")", |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
430 delta2_left.start(), delta2_left.end(), delta2_right.start(), |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
431 delta2_right.end()); |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
432 } |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
433 |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
434 } |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
435 #endif // NOT PRODUCT |
0 | 436 |
437 void PSYoungGen::resize_spaces(size_t requested_eden_size, | |
438 size_t requested_survivor_size) { | |
439 assert(UseAdaptiveSizePolicy, "sanity check"); | |
440 assert(requested_eden_size > 0 && requested_survivor_size > 0, | |
441 "just checking"); | |
442 | |
443 // We require eden and to space to be empty | |
444 if ((!eden_space()->is_empty()) || (!to_space()->is_empty())) { | |
445 return; | |
446 } | |
447 | |
448 if (PrintAdaptiveSizePolicy && Verbose) { | |
449 gclog_or_tty->print_cr("PSYoungGen::resize_spaces(requested_eden_size: " | |
450 SIZE_FORMAT | |
451 ", requested_survivor_size: " SIZE_FORMAT ")", | |
452 requested_eden_size, requested_survivor_size); | |
453 gclog_or_tty->print_cr(" eden: [" PTR_FORMAT ".." PTR_FORMAT ") " | |
454 SIZE_FORMAT, | |
455 eden_space()->bottom(), | |
456 eden_space()->end(), | |
457 pointer_delta(eden_space()->end(), | |
458 eden_space()->bottom(), | |
459 sizeof(char))); | |
460 gclog_or_tty->print_cr(" from: [" PTR_FORMAT ".." PTR_FORMAT ") " | |
461 SIZE_FORMAT, | |
462 from_space()->bottom(), | |
463 from_space()->end(), | |
464 pointer_delta(from_space()->end(), | |
465 from_space()->bottom(), | |
466 sizeof(char))); | |
467 gclog_or_tty->print_cr(" to: [" PTR_FORMAT ".." PTR_FORMAT ") " | |
468 SIZE_FORMAT, | |
469 to_space()->bottom(), | |
470 to_space()->end(), | |
471 pointer_delta( to_space()->end(), | |
472 to_space()->bottom(), | |
473 sizeof(char))); | |
474 } | |
475 | |
476 // There's nothing to do if the new sizes are the same as the current | |
477 if (requested_survivor_size == to_space()->capacity_in_bytes() && | |
478 requested_survivor_size == from_space()->capacity_in_bytes() && | |
479 requested_eden_size == eden_space()->capacity_in_bytes()) { | |
480 if (PrintAdaptiveSizePolicy && Verbose) { | |
481 gclog_or_tty->print_cr(" capacities are the right sizes, returning"); | |
482 } | |
483 return; | |
484 } | |
485 | |
486 char* eden_start = (char*)eden_space()->bottom(); | |
487 char* eden_end = (char*)eden_space()->end(); | |
488 char* from_start = (char*)from_space()->bottom(); | |
489 char* from_end = (char*)from_space()->end(); | |
490 char* to_start = (char*)to_space()->bottom(); | |
491 char* to_end = (char*)to_space()->end(); | |
492 | |
493 ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap(); | |
13
183f41cf8bfe
6557851: CMS: ergonomics defaults are not set with FLAG_SET_ERGO
jmasa
parents:
0
diff
changeset
|
494 const size_t alignment = heap->intra_heap_alignment(); |
0 | 495 const bool maintain_minimum = |
496 (requested_eden_size + 2 * requested_survivor_size) <= min_gen_size(); | |
497 | |
263
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
498 bool eden_from_to_order = from_start < to_start; |
0 | 499 // Check whether from space is below to space |
263
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
500 if (eden_from_to_order) { |
0 | 501 // Eden, from, to |
263
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
502 eden_from_to_order = true; |
0 | 503 if (PrintAdaptiveSizePolicy && Verbose) { |
504 gclog_or_tty->print_cr(" Eden, from, to:"); | |
505 } | |
506 | |
507 // Set eden | |
508 // "requested_eden_size" is a goal for the size of eden | |
509 // and may not be attainable. "eden_size" below is | |
510 // calculated based on the location of from-space and | |
511 // the goal for the size of eden. from-space is | |
512 // fixed in place because it contains live data. | |
513 // The calculation is done this way to avoid 32bit | |
514 // overflow (i.e., eden_start + requested_eden_size | |
515 // may too large for representation in 32bits). | |
516 size_t eden_size; | |
517 if (maintain_minimum) { | |
518 // Only make eden larger than the requested size if | |
519 // the minimum size of the generation has to be maintained. | |
520 // This could be done in general but policy at a higher | |
521 // level is determining a requested size for eden and that | |
522 // should be honored unless there is a fundamental reason. | |
523 eden_size = pointer_delta(from_start, | |
524 eden_start, | |
525 sizeof(char)); | |
526 } else { | |
527 eden_size = MIN2(requested_eden_size, | |
528 pointer_delta(from_start, eden_start, sizeof(char))); | |
529 } | |
530 | |
531 eden_end = eden_start + eden_size; | |
1489
cff162798819
6888953: some calls to function-like macros are missing semicolons
jcoomes
parents:
579
diff
changeset
|
532 assert(eden_end >= eden_start, "addition overflowed"); |
0 | 533 |
534 // To may resize into from space as long as it is clear of live data. | |
535 // From space must remain page aligned, though, so we need to do some | |
536 // extra calculations. | |
537 | |
538 // First calculate an optimal to-space | |
263
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
539 to_end = (char*)virtual_space()->high(); |
0 | 540 to_start = (char*)pointer_delta(to_end, (char*)requested_survivor_size, |
541 sizeof(char)); | |
542 | |
543 // Does the optimal to-space overlap from-space? | |
544 if (to_start < (char*)from_space()->end()) { | |
545 assert(heap->kind() == CollectedHeap::ParallelScavengeHeap, "Sanity"); | |
546 | |
547 // Calculate the minimum offset possible for from_end | |
548 size_t from_size = pointer_delta(from_space()->top(), from_start, sizeof(char)); | |
549 | |
550 // Should we be in this method if from_space is empty? Why not the set_space method? FIX ME! | |
551 if (from_size == 0) { | |
552 from_size = alignment; | |
553 } else { | |
554 from_size = align_size_up(from_size, alignment); | |
555 } | |
556 | |
557 from_end = from_start + from_size; | |
558 assert(from_end > from_start, "addition overflow or from_size problem"); | |
559 | |
560 guarantee(from_end <= (char*)from_space()->end(), "from_end moved to the right"); | |
561 | |
562 // Now update to_start with the new from_end | |
563 to_start = MAX2(from_end, to_start); | |
564 } | |
565 | |
566 guarantee(to_start != to_end, "to space is zero sized"); | |
567 | |
568 if (PrintAdaptiveSizePolicy && Verbose) { | |
569 gclog_or_tty->print_cr(" [eden_start .. eden_end): " | |
570 "[" PTR_FORMAT " .. " PTR_FORMAT ") " SIZE_FORMAT, | |
571 eden_start, | |
572 eden_end, | |
573 pointer_delta(eden_end, eden_start, sizeof(char))); | |
574 gclog_or_tty->print_cr(" [from_start .. from_end): " | |
575 "[" PTR_FORMAT " .. " PTR_FORMAT ") " SIZE_FORMAT, | |
576 from_start, | |
577 from_end, | |
578 pointer_delta(from_end, from_start, sizeof(char))); | |
579 gclog_or_tty->print_cr(" [ to_start .. to_end): " | |
580 "[" PTR_FORMAT " .. " PTR_FORMAT ") " SIZE_FORMAT, | |
581 to_start, | |
582 to_end, | |
583 pointer_delta( to_end, to_start, sizeof(char))); | |
584 } | |
585 } else { | |
586 // Eden, to, from | |
587 if (PrintAdaptiveSizePolicy && Verbose) { | |
588 gclog_or_tty->print_cr(" Eden, to, from:"); | |
589 } | |
590 | |
591 // To space gets priority over eden resizing. Note that we position | |
592 // to space as if we were able to resize from space, even though from | |
593 // space is not modified. | |
594 // Giving eden priority was tried and gave poorer performance. | |
263
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
595 to_end = (char*)pointer_delta(virtual_space()->high(), |
0 | 596 (char*)requested_survivor_size, |
597 sizeof(char)); | |
598 to_end = MIN2(to_end, from_start); | |
599 to_start = (char*)pointer_delta(to_end, (char*)requested_survivor_size, | |
600 sizeof(char)); | |
601 // if the space sizes are to be increased by several times then | |
602 // 'to_start' will point beyond the young generation. In this case | |
603 // 'to_start' should be adjusted. | |
604 to_start = MAX2(to_start, eden_start + alignment); | |
605 | |
606 // Compute how big eden can be, then adjust end. | |
607 // See comments above on calculating eden_end. | |
608 size_t eden_size; | |
609 if (maintain_minimum) { | |
610 eden_size = pointer_delta(to_start, eden_start, sizeof(char)); | |
611 } else { | |
612 eden_size = MIN2(requested_eden_size, | |
613 pointer_delta(to_start, eden_start, sizeof(char))); | |
614 } | |
615 eden_end = eden_start + eden_size; | |
1489
cff162798819
6888953: some calls to function-like macros are missing semicolons
jcoomes
parents:
579
diff
changeset
|
616 assert(eden_end >= eden_start, "addition overflowed"); |
0 | 617 |
618 // Could choose to not let eden shrink | |
619 // to_start = MAX2(to_start, eden_end); | |
620 | |
621 // Don't let eden shrink down to 0 or less. | |
622 eden_end = MAX2(eden_end, eden_start + alignment); | |
623 to_start = MAX2(to_start, eden_end); | |
624 | |
625 if (PrintAdaptiveSizePolicy && Verbose) { | |
626 gclog_or_tty->print_cr(" [eden_start .. eden_end): " | |
627 "[" PTR_FORMAT " .. " PTR_FORMAT ") " SIZE_FORMAT, | |
628 eden_start, | |
629 eden_end, | |
630 pointer_delta(eden_end, eden_start, sizeof(char))); | |
631 gclog_or_tty->print_cr(" [ to_start .. to_end): " | |
632 "[" PTR_FORMAT " .. " PTR_FORMAT ") " SIZE_FORMAT, | |
633 to_start, | |
634 to_end, | |
635 pointer_delta( to_end, to_start, sizeof(char))); | |
636 gclog_or_tty->print_cr(" [from_start .. from_end): " | |
637 "[" PTR_FORMAT " .. " PTR_FORMAT ") " SIZE_FORMAT, | |
638 from_start, | |
639 from_end, | |
640 pointer_delta(from_end, from_start, sizeof(char))); | |
641 } | |
642 } | |
643 | |
644 | |
645 guarantee((HeapWord*)from_start <= from_space()->bottom(), | |
646 "from start moved to the right"); | |
647 guarantee((HeapWord*)from_end >= from_space()->top(), | |
648 "from end moved into live data"); | |
649 assert(is_object_aligned((intptr_t)eden_start), "checking alignment"); | |
650 assert(is_object_aligned((intptr_t)from_start), "checking alignment"); | |
651 assert(is_object_aligned((intptr_t)to_start), "checking alignment"); | |
652 | |
653 MemRegion edenMR((HeapWord*)eden_start, (HeapWord*)eden_end); | |
654 MemRegion toMR ((HeapWord*)to_start, (HeapWord*)to_end); | |
655 MemRegion fromMR((HeapWord*)from_start, (HeapWord*)from_end); | |
656 | |
657 // Let's make sure the call to initialize doesn't reset "top"! | |
658 HeapWord* old_from_top = from_space()->top(); | |
659 | |
660 // For PrintAdaptiveSizePolicy block below | |
661 size_t old_from = from_space()->capacity_in_bytes(); | |
662 size_t old_to = to_space()->capacity_in_bytes(); | |
663 | |
263
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
664 if (ZapUnusedHeapArea) { |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
665 // NUMA is a special case because a numa space is not mangled |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
666 // in order to not prematurely bind its address to memory to |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
667 // the wrong memory (i.e., don't want the GC thread to first |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
668 // touch the memory). The survivor spaces are not numa |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
669 // spaces and are mangled. |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
670 if (UseNUMA) { |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
671 if (eden_from_to_order) { |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
672 mangle_survivors(from_space(), fromMR, to_space(), toMR); |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
673 } else { |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
674 mangle_survivors(to_space(), toMR, from_space(), fromMR); |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
675 } |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
676 } |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
677 |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
678 // If not mangling the spaces, do some checking to verify that |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
679 // the spaces are already mangled. |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
680 // The spaces should be correctly mangled at this point so |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
681 // do some checking here. Note that they are not being mangled |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
682 // in the calls to initialize(). |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
683 // Must check mangling before the spaces are reshaped. Otherwise, |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
684 // the bottom or end of one space may have moved into an area |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
685 // covered by another space and a failure of the check may |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
686 // not correctly indicate which space is not properly mangled. |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
687 HeapWord* limit = (HeapWord*) virtual_space()->high(); |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
688 eden_space()->check_mangled_unused_area(limit); |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
689 from_space()->check_mangled_unused_area(limit); |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
690 to_space()->check_mangled_unused_area(limit); |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
691 } |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
692 // When an existing space is being initialized, it is not |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
693 // mangled because the space has been previously mangled. |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
694 eden_space()->initialize(edenMR, |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
695 SpaceDecorator::Clear, |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
696 SpaceDecorator::DontMangle); |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
697 to_space()->initialize(toMR, |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
698 SpaceDecorator::Clear, |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
699 SpaceDecorator::DontMangle); |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
700 from_space()->initialize(fromMR, |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
701 SpaceDecorator::DontClear, |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
702 SpaceDecorator::DontMangle); |
0 | 703 |
704 assert(from_space()->top() == old_from_top, "from top changed!"); | |
705 | |
706 if (PrintAdaptiveSizePolicy) { | |
707 ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap(); | |
708 assert(heap->kind() == CollectedHeap::ParallelScavengeHeap, "Sanity"); | |
709 | |
710 gclog_or_tty->print("AdaptiveSizePolicy::survivor space sizes: " | |
711 "collection: %d " | |
712 "(" SIZE_FORMAT ", " SIZE_FORMAT ") -> " | |
713 "(" SIZE_FORMAT ", " SIZE_FORMAT ") ", | |
714 heap->total_collections(), | |
715 old_from, old_to, | |
716 from_space()->capacity_in_bytes(), | |
717 to_space()->capacity_in_bytes()); | |
718 gclog_or_tty->cr(); | |
719 } | |
720 } | |
721 | |
722 void PSYoungGen::swap_spaces() { | |
723 MutableSpace* s = from_space(); | |
724 _from_space = to_space(); | |
725 _to_space = s; | |
726 | |
727 // Now update the decorators. | |
728 PSMarkSweepDecorator* md = from_mark_sweep(); | |
729 _from_mark_sweep = to_mark_sweep(); | |
730 _to_mark_sweep = md; | |
731 | |
732 assert(from_mark_sweep()->space() == from_space(), "Sanity"); | |
733 assert(to_mark_sweep()->space() == to_space(), "Sanity"); | |
734 } | |
735 | |
736 size_t PSYoungGen::capacity_in_bytes() const { | |
737 return eden_space()->capacity_in_bytes() | |
738 + from_space()->capacity_in_bytes(); // to_space() is only used during scavenge | |
739 } | |
740 | |
741 | |
742 size_t PSYoungGen::used_in_bytes() const { | |
743 return eden_space()->used_in_bytes() | |
744 + from_space()->used_in_bytes(); // to_space() is only used during scavenge | |
745 } | |
746 | |
747 | |
748 size_t PSYoungGen::free_in_bytes() const { | |
749 return eden_space()->free_in_bytes() | |
750 + from_space()->free_in_bytes(); // to_space() is only used during scavenge | |
751 } | |
752 | |
753 size_t PSYoungGen::capacity_in_words() const { | |
754 return eden_space()->capacity_in_words() | |
755 + from_space()->capacity_in_words(); // to_space() is only used during scavenge | |
756 } | |
757 | |
758 | |
759 size_t PSYoungGen::used_in_words() const { | |
760 return eden_space()->used_in_words() | |
761 + from_space()->used_in_words(); // to_space() is only used during scavenge | |
762 } | |
763 | |
764 | |
765 size_t PSYoungGen::free_in_words() const { | |
766 return eden_space()->free_in_words() | |
767 + from_space()->free_in_words(); // to_space() is only used during scavenge | |
768 } | |
769 | |
770 void PSYoungGen::object_iterate(ObjectClosure* blk) { | |
771 eden_space()->object_iterate(blk); | |
772 from_space()->object_iterate(blk); | |
773 to_space()->object_iterate(blk); | |
774 } | |
775 | |
776 void PSYoungGen::precompact() { | |
777 eden_mark_sweep()->precompact(); | |
778 from_mark_sweep()->precompact(); | |
779 to_mark_sweep()->precompact(); | |
780 } | |
781 | |
782 void PSYoungGen::adjust_pointers() { | |
783 eden_mark_sweep()->adjust_pointers(); | |
784 from_mark_sweep()->adjust_pointers(); | |
785 to_mark_sweep()->adjust_pointers(); | |
786 } | |
787 | |
788 void PSYoungGen::compact() { | |
789 eden_mark_sweep()->compact(ZapUnusedHeapArea); | |
790 from_mark_sweep()->compact(ZapUnusedHeapArea); | |
791 // Mark sweep stores preserved markOops in to space, don't disturb! | |
792 to_mark_sweep()->compact(false); | |
793 } | |
794 | |
795 void PSYoungGen::move_and_update(ParCompactionManager* cm) { | |
796 PSParallelCompact::move_and_update(cm, PSParallelCompact::eden_space_id); | |
797 PSParallelCompact::move_and_update(cm, PSParallelCompact::from_space_id); | |
798 PSParallelCompact::move_and_update(cm, PSParallelCompact::to_space_id); | |
799 } | |
800 | |
801 void PSYoungGen::print() const { print_on(tty); } | |
802 void PSYoungGen::print_on(outputStream* st) const { | |
803 st->print(" %-15s", "PSYoungGen"); | |
804 if (PrintGCDetails && Verbose) { | |
805 st->print(" total " SIZE_FORMAT ", used " SIZE_FORMAT, | |
806 capacity_in_bytes(), used_in_bytes()); | |
807 } else { | |
808 st->print(" total " SIZE_FORMAT "K, used " SIZE_FORMAT "K", | |
809 capacity_in_bytes()/K, used_in_bytes()/K); | |
810 } | |
263
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
811 virtual_space()->print_space_boundaries_on(st); |
0 | 812 st->print(" eden"); eden_space()->print_on(st); |
813 st->print(" from"); from_space()->print_on(st); | |
814 st->print(" to "); to_space()->print_on(st); | |
815 } | |
816 | |
817 void PSYoungGen::print_used_change(size_t prev_used) const { | |
818 gclog_or_tty->print(" [%s:", name()); | |
819 gclog_or_tty->print(" " SIZE_FORMAT "K" | |
820 "->" SIZE_FORMAT "K" | |
821 "(" SIZE_FORMAT "K)", | |
822 prev_used / K, used_in_bytes() / K, | |
823 capacity_in_bytes() / K); | |
824 gclog_or_tty->print("]"); | |
825 } | |
826 | |
827 size_t PSYoungGen::available_for_expansion() { | |
828 ShouldNotReachHere(); | |
829 return 0; | |
830 } | |
831 | |
832 size_t PSYoungGen::available_for_contraction() { | |
833 ShouldNotReachHere(); | |
834 return 0; | |
835 } | |
836 | |
837 size_t PSYoungGen::available_to_min_gen() { | |
838 assert(virtual_space()->committed_size() >= min_gen_size(), "Invariant"); | |
839 return virtual_space()->committed_size() - min_gen_size(); | |
840 } | |
841 | |
842 // This method assumes that from-space has live data and that | |
843 // any shrinkage of the young gen is limited by location of | |
844 // from-space. | |
845 size_t PSYoungGen::available_to_live() { | |
846 size_t delta_in_survivor = 0; | |
847 ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap(); | |
13
183f41cf8bfe
6557851: CMS: ergonomics defaults are not set with FLAG_SET_ERGO
jmasa
parents:
0
diff
changeset
|
848 const size_t space_alignment = heap->intra_heap_alignment(); |
0 | 849 const size_t gen_alignment = heap->young_gen_alignment(); |
850 | |
851 MutableSpace* space_shrinking = NULL; | |
852 if (from_space()->end() > to_space()->end()) { | |
853 space_shrinking = from_space(); | |
854 } else { | |
855 space_shrinking = to_space(); | |
856 } | |
857 | |
858 // Include any space that is committed but not included in | |
859 // the survivor spaces. | |
860 assert(((HeapWord*)virtual_space()->high()) >= space_shrinking->end(), | |
861 "Survivor space beyond high end"); | |
862 size_t unused_committed = pointer_delta(virtual_space()->high(), | |
863 space_shrinking->end(), sizeof(char)); | |
864 | |
865 if (space_shrinking->is_empty()) { | |
866 // Don't let the space shrink to 0 | |
867 assert(space_shrinking->capacity_in_bytes() >= space_alignment, | |
868 "Space is too small"); | |
869 delta_in_survivor = space_shrinking->capacity_in_bytes() - space_alignment; | |
870 } else { | |
871 delta_in_survivor = pointer_delta(space_shrinking->end(), | |
872 space_shrinking->top(), | |
873 sizeof(char)); | |
874 } | |
875 | |
876 size_t delta_in_bytes = unused_committed + delta_in_survivor; | |
877 delta_in_bytes = align_size_down(delta_in_bytes, gen_alignment); | |
878 return delta_in_bytes; | |
879 } | |
880 | |
881 // Return the number of bytes available for resizing down the young | |
882 // generation. This is the minimum of | |
883 // input "bytes" | |
884 // bytes to the minimum young gen size | |
885 // bytes to the size currently being used + some small extra | |
886 size_t PSYoungGen::limit_gen_shrink(size_t bytes) { | |
887 // Allow shrinkage into the current eden but keep eden large enough | |
888 // to maintain the minimum young gen size | |
889 bytes = MIN3(bytes, available_to_min_gen(), available_to_live()); | |
890 return align_size_down(bytes, virtual_space()->alignment()); | |
891 } | |
892 | |
893 void PSYoungGen::reset_after_change() { | |
894 ShouldNotReachHere(); | |
895 } | |
896 | |
897 void PSYoungGen::reset_survivors_after_shrink() { | |
898 _reserved = MemRegion((HeapWord*)virtual_space()->low_boundary(), | |
899 (HeapWord*)virtual_space()->high_boundary()); | |
900 PSScavenge::reference_processor()->set_span(_reserved); | |
901 | |
902 MutableSpace* space_shrinking = NULL; | |
903 if (from_space()->end() > to_space()->end()) { | |
904 space_shrinking = from_space(); | |
905 } else { | |
906 space_shrinking = to_space(); | |
907 } | |
908 | |
909 HeapWord* new_end = (HeapWord*)virtual_space()->high(); | |
910 assert(new_end >= space_shrinking->bottom(), "Shrink was too large"); | |
911 // Was there a shrink of the survivor space? | |
912 if (new_end < space_shrinking->end()) { | |
913 MemRegion mr(space_shrinking->bottom(), new_end); | |
263
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
914 space_shrinking->initialize(mr, |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
915 SpaceDecorator::DontClear, |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
916 SpaceDecorator::Mangle); |
0 | 917 } |
918 } | |
919 | |
920 // This method currently does not expect to expand into eden (i.e., | |
921 // the virtual space boundaries is expected to be consistent | |
922 // with the eden boundaries.. | |
923 void PSYoungGen::post_resize() { | |
924 assert_locked_or_safepoint(Heap_lock); | |
925 assert((eden_space()->bottom() < to_space()->bottom()) && | |
926 (eden_space()->bottom() < from_space()->bottom()), | |
927 "Eden is assumed to be below the survivor spaces"); | |
928 | |
929 MemRegion cmr((HeapWord*)virtual_space()->low(), | |
930 (HeapWord*)virtual_space()->high()); | |
931 Universe::heap()->barrier_set()->resize_covered_region(cmr); | |
932 space_invariants(); | |
933 } | |
934 | |
935 | |
936 | |
937 void PSYoungGen::update_counters() { | |
938 if (UsePerfData) { | |
939 _eden_counters->update_all(); | |
940 _from_counters->update_all(); | |
941 _to_counters->update_all(); | |
942 _gen_counters->update_all(); | |
943 } | |
944 } | |
945 | |
946 void PSYoungGen::verify(bool allow_dirty) { | |
947 eden_space()->verify(allow_dirty); | |
948 from_space()->verify(allow_dirty); | |
949 to_space()->verify(allow_dirty); | |
950 } | |
263
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
951 |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
952 #ifndef PRODUCT |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
953 void PSYoungGen::record_spaces_top() { |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
954 assert(ZapUnusedHeapArea, "Not mangling unused space"); |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
955 eden_space()->set_top_for_allocations(); |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
956 from_space()->set_top_for_allocations(); |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
957 to_space()->set_top_for_allocations(); |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
958 } |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
13
diff
changeset
|
959 #endif |