annotate src/share/vm/gc_implementation/parallelScavenge/asPSYoungGen.cpp @ 3285:49a67202bc67

7011855: G1: non-product flag to artificially grow the heap Summary: It introduces non-product cmd line parameter G1DummyRegionsPerGC which indicates how many "dummy" regions to allocate at the end of each GC. This allows the G1 heap to grow artificially and makes concurrent marking cycles more frequent irrespective of what the application that is running is doing. The dummy regions will be found totally empty during cleanup so this parameter can also be used to stress the concurrent cleanup operation. Reviewed-by: brutisso, johnc
author tonyp
date Tue, 19 Apr 2011 15:46:59 -0400
parents f95d63e2154a
children 46d7652b223c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
2 * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
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
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
25 #include "precompiled.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
26 #include "gc_implementation/parallelScavenge/asPSYoungGen.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
27 #include "gc_implementation/parallelScavenge/parallelScavengeHeap.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
28 #include "gc_implementation/parallelScavenge/psMarkSweepDecorator.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
29 #include "gc_implementation/parallelScavenge/psScavenge.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
30 #include "gc_implementation/parallelScavenge/psYoungGen.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
31 #include "gc_implementation/shared/gcUtil.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
32 #include "gc_implementation/shared/spaceDecorator.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
33 #include "oops/oop.inline.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
34 #include "runtime/java.hpp"
0
a61af66fc99e Initial load
duke
parents:
diff changeset
35
a61af66fc99e Initial load
duke
parents:
diff changeset
36 ASPSYoungGen::ASPSYoungGen(size_t init_byte_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
37 size_t minimum_byte_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
38 size_t byte_size_limit) :
a61af66fc99e Initial load
duke
parents:
diff changeset
39 PSYoungGen(init_byte_size, minimum_byte_size, byte_size_limit),
a61af66fc99e Initial load
duke
parents:
diff changeset
40 _gen_size_limit(byte_size_limit) {
a61af66fc99e Initial load
duke
parents:
diff changeset
41 }
a61af66fc99e Initial load
duke
parents:
diff changeset
42
a61af66fc99e Initial load
duke
parents:
diff changeset
43
a61af66fc99e Initial load
duke
parents:
diff changeset
44 ASPSYoungGen::ASPSYoungGen(PSVirtualSpace* vs,
a61af66fc99e Initial load
duke
parents:
diff changeset
45 size_t init_byte_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
46 size_t minimum_byte_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
47 size_t byte_size_limit) :
a61af66fc99e Initial load
duke
parents:
diff changeset
48 //PSYoungGen(init_byte_size, minimum_byte_size, byte_size_limit),
a61af66fc99e Initial load
duke
parents:
diff changeset
49 PSYoungGen(vs->committed_size(), minimum_byte_size, byte_size_limit),
a61af66fc99e Initial load
duke
parents:
diff changeset
50 _gen_size_limit(byte_size_limit) {
a61af66fc99e Initial load
duke
parents:
diff changeset
51
a61af66fc99e Initial load
duke
parents:
diff changeset
52 assert(vs->committed_size() == init_byte_size, "Cannot replace with");
a61af66fc99e Initial load
duke
parents:
diff changeset
53
a61af66fc99e Initial load
duke
parents:
diff changeset
54 _virtual_space = vs;
a61af66fc99e Initial load
duke
parents:
diff changeset
55 }
a61af66fc99e Initial load
duke
parents:
diff changeset
56
a61af66fc99e Initial load
duke
parents:
diff changeset
57 void ASPSYoungGen::initialize_virtual_space(ReservedSpace rs,
a61af66fc99e Initial load
duke
parents:
diff changeset
58 size_t alignment) {
a61af66fc99e Initial load
duke
parents:
diff changeset
59 assert(_init_gen_size != 0, "Should have a finite size");
a61af66fc99e Initial load
duke
parents:
diff changeset
60 _virtual_space = new PSVirtualSpaceHighToLow(rs, alignment);
a61af66fc99e Initial load
duke
parents:
diff changeset
61 if (!_virtual_space->expand_by(_init_gen_size)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
62 vm_exit_during_initialization("Could not reserve enough space for "
a61af66fc99e Initial load
duke
parents:
diff changeset
63 "object heap");
a61af66fc99e Initial load
duke
parents:
diff changeset
64 }
a61af66fc99e Initial load
duke
parents:
diff changeset
65 }
a61af66fc99e Initial load
duke
parents:
diff changeset
66
a61af66fc99e Initial load
duke
parents:
diff changeset
67 void ASPSYoungGen::initialize(ReservedSpace rs, size_t alignment) {
a61af66fc99e Initial load
duke
parents:
diff changeset
68 initialize_virtual_space(rs, alignment);
a61af66fc99e Initial load
duke
parents:
diff changeset
69 initialize_work();
a61af66fc99e Initial load
duke
parents:
diff changeset
70 }
a61af66fc99e Initial load
duke
parents:
diff changeset
71
a61af66fc99e Initial load
duke
parents:
diff changeset
72 size_t ASPSYoungGen::available_for_expansion() {
a61af66fc99e Initial load
duke
parents:
diff changeset
73
a61af66fc99e Initial load
duke
parents:
diff changeset
74 size_t current_committed_size = virtual_space()->committed_size();
a61af66fc99e Initial load
duke
parents:
diff changeset
75 assert((gen_size_limit() >= current_committed_size),
a61af66fc99e Initial load
duke
parents:
diff changeset
76 "generation size limit is wrong");
a61af66fc99e Initial load
duke
parents:
diff changeset
77 ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap();
a61af66fc99e Initial load
duke
parents:
diff changeset
78 size_t result = gen_size_limit() - current_committed_size;
a61af66fc99e Initial load
duke
parents:
diff changeset
79 size_t result_aligned = align_size_down(result, heap->young_gen_alignment());
a61af66fc99e Initial load
duke
parents:
diff changeset
80 return result_aligned;
a61af66fc99e Initial load
duke
parents:
diff changeset
81 }
a61af66fc99e Initial load
duke
parents:
diff changeset
82
a61af66fc99e Initial load
duke
parents:
diff changeset
83 // Return the number of bytes the young gen is willing give up.
a61af66fc99e Initial load
duke
parents:
diff changeset
84 //
a61af66fc99e Initial load
duke
parents:
diff changeset
85 // Future implementations could check the survivors and if to_space is in the
a61af66fc99e Initial load
duke
parents:
diff changeset
86 // right place (below from_space), take a chunk from to_space.
a61af66fc99e Initial load
duke
parents:
diff changeset
87 size_t ASPSYoungGen::available_for_contraction() {
a61af66fc99e Initial load
duke
parents:
diff changeset
88
a61af66fc99e Initial load
duke
parents:
diff changeset
89 size_t uncommitted_bytes = virtual_space()->uncommitted_size();
a61af66fc99e Initial load
duke
parents:
diff changeset
90 if (uncommitted_bytes != 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
91 return uncommitted_bytes;
a61af66fc99e Initial load
duke
parents:
diff changeset
92 }
a61af66fc99e Initial load
duke
parents:
diff changeset
93
a61af66fc99e Initial load
duke
parents:
diff changeset
94 if (eden_space()->is_empty()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
95 // Respect the minimum size for eden and for the young gen as a whole.
a61af66fc99e Initial load
duke
parents:
diff changeset
96 ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap();
13
183f41cf8bfe 6557851: CMS: ergonomics defaults are not set with FLAG_SET_ERGO
jmasa
parents: 0
diff changeset
97 const size_t eden_alignment = heap->intra_heap_alignment();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
98 const size_t gen_alignment = heap->young_gen_alignment();
a61af66fc99e Initial load
duke
parents:
diff changeset
99
a61af66fc99e Initial load
duke
parents:
diff changeset
100 assert(eden_space()->capacity_in_bytes() >= eden_alignment,
a61af66fc99e Initial load
duke
parents:
diff changeset
101 "Alignment is wrong");
a61af66fc99e Initial load
duke
parents:
diff changeset
102 size_t eden_avail = eden_space()->capacity_in_bytes() - eden_alignment;
a61af66fc99e Initial load
duke
parents:
diff changeset
103 eden_avail = align_size_down(eden_avail, gen_alignment);
a61af66fc99e Initial load
duke
parents:
diff changeset
104
a61af66fc99e Initial load
duke
parents:
diff changeset
105 assert(virtual_space()->committed_size() >= min_gen_size(),
a61af66fc99e Initial load
duke
parents:
diff changeset
106 "minimum gen size is wrong");
a61af66fc99e Initial load
duke
parents:
diff changeset
107 size_t gen_avail = virtual_space()->committed_size() - min_gen_size();
a61af66fc99e Initial load
duke
parents:
diff changeset
108 assert(virtual_space()->is_aligned(gen_avail), "not aligned");
a61af66fc99e Initial load
duke
parents:
diff changeset
109
a61af66fc99e Initial load
duke
parents:
diff changeset
110 const size_t max_contraction = MIN2(eden_avail, gen_avail);
a61af66fc99e Initial load
duke
parents:
diff changeset
111 // See comment for ASPSOldGen::available_for_contraction()
a61af66fc99e Initial load
duke
parents:
diff changeset
112 // for reasons the "increment" fraction is used.
a61af66fc99e Initial load
duke
parents:
diff changeset
113 PSAdaptiveSizePolicy* policy = heap->size_policy();
a61af66fc99e Initial load
duke
parents:
diff changeset
114 size_t result = policy->eden_increment_aligned_down(max_contraction);
a61af66fc99e Initial load
duke
parents:
diff changeset
115 size_t result_aligned = align_size_down(result, gen_alignment);
a61af66fc99e Initial load
duke
parents:
diff changeset
116 if (PrintAdaptiveSizePolicy && Verbose) {
a61af66fc99e Initial load
duke
parents:
diff changeset
117 gclog_or_tty->print_cr("ASPSYoungGen::available_for_contraction: %d K",
a61af66fc99e Initial load
duke
parents:
diff changeset
118 result_aligned/K);
a61af66fc99e Initial load
duke
parents:
diff changeset
119 gclog_or_tty->print_cr(" max_contraction %d K", max_contraction/K);
a61af66fc99e Initial load
duke
parents:
diff changeset
120 gclog_or_tty->print_cr(" eden_avail %d K", eden_avail/K);
a61af66fc99e Initial load
duke
parents:
diff changeset
121 gclog_or_tty->print_cr(" gen_avail %d K", gen_avail/K);
a61af66fc99e Initial load
duke
parents:
diff changeset
122 }
a61af66fc99e Initial load
duke
parents:
diff changeset
123 return result_aligned;
a61af66fc99e Initial load
duke
parents:
diff changeset
124
a61af66fc99e Initial load
duke
parents:
diff changeset
125 }
a61af66fc99e Initial load
duke
parents:
diff changeset
126
a61af66fc99e Initial load
duke
parents:
diff changeset
127 return 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
128 }
a61af66fc99e Initial load
duke
parents:
diff changeset
129
a61af66fc99e Initial load
duke
parents:
diff changeset
130 // The current implementation only considers to the end of eden.
a61af66fc99e Initial load
duke
parents:
diff changeset
131 // If to_space is below from_space, to_space is not considered.
a61af66fc99e Initial load
duke
parents:
diff changeset
132 // to_space can be.
a61af66fc99e Initial load
duke
parents:
diff changeset
133 size_t ASPSYoungGen::available_to_live() {
a61af66fc99e Initial load
duke
parents:
diff changeset
134 ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap();
13
183f41cf8bfe 6557851: CMS: ergonomics defaults are not set with FLAG_SET_ERGO
jmasa
parents: 0
diff changeset
135 const size_t alignment = heap->intra_heap_alignment();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
136
a61af66fc99e Initial load
duke
parents:
diff changeset
137 // Include any space that is committed but is not in eden.
a61af66fc99e Initial load
duke
parents:
diff changeset
138 size_t available = pointer_delta(eden_space()->bottom(),
a61af66fc99e Initial load
duke
parents:
diff changeset
139 virtual_space()->low(),
a61af66fc99e Initial load
duke
parents:
diff changeset
140 sizeof(char));
a61af66fc99e Initial load
duke
parents:
diff changeset
141
a61af66fc99e Initial load
duke
parents:
diff changeset
142 const size_t eden_capacity = eden_space()->capacity_in_bytes();
a61af66fc99e Initial load
duke
parents:
diff changeset
143 if (eden_space()->is_empty() && eden_capacity > alignment) {
a61af66fc99e Initial load
duke
parents:
diff changeset
144 available += eden_capacity - alignment;
a61af66fc99e Initial load
duke
parents:
diff changeset
145 }
a61af66fc99e Initial load
duke
parents:
diff changeset
146 return available;
a61af66fc99e Initial load
duke
parents:
diff changeset
147 }
a61af66fc99e Initial load
duke
parents:
diff changeset
148
a61af66fc99e Initial load
duke
parents:
diff changeset
149 // Similar to PSYoungGen::resize_generation() but
a61af66fc99e Initial load
duke
parents:
diff changeset
150 // allows sum of eden_size and 2 * survivor_size to exceed _max_gen_size
a61af66fc99e Initial load
duke
parents:
diff changeset
151 // expands at the low end of the virtual space
a61af66fc99e Initial load
duke
parents:
diff changeset
152 // moves the boundary between the generations in order to expand
a61af66fc99e Initial load
duke
parents:
diff changeset
153 // some additional diagnostics
a61af66fc99e Initial load
duke
parents:
diff changeset
154 // If no additional changes are required, this can be deleted
a61af66fc99e Initial load
duke
parents:
diff changeset
155 // and the changes factored back into PSYoungGen::resize_generation().
a61af66fc99e Initial load
duke
parents:
diff changeset
156 bool ASPSYoungGen::resize_generation(size_t eden_size, size_t survivor_size) {
a61af66fc99e Initial load
duke
parents:
diff changeset
157 const size_t alignment = virtual_space()->alignment();
a61af66fc99e Initial load
duke
parents:
diff changeset
158 size_t orig_size = virtual_space()->committed_size();
a61af66fc99e Initial load
duke
parents:
diff changeset
159 bool size_changed = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
160
a61af66fc99e Initial load
duke
parents:
diff changeset
161 // There used to be a guarantee here that
a61af66fc99e Initial load
duke
parents:
diff changeset
162 // (eden_size + 2*survivor_size) <= _max_gen_size
a61af66fc99e Initial load
duke
parents:
diff changeset
163 // This requirement is enforced by the calculation of desired_size
a61af66fc99e Initial load
duke
parents:
diff changeset
164 // below. It may not be true on entry since the size of the
a61af66fc99e Initial load
duke
parents:
diff changeset
165 // eden_size is no bounded by the generation size.
a61af66fc99e Initial load
duke
parents:
diff changeset
166
a61af66fc99e Initial load
duke
parents:
diff changeset
167 assert(max_size() == reserved().byte_size(), "max gen size problem?");
a61af66fc99e Initial load
duke
parents:
diff changeset
168 assert(min_gen_size() <= orig_size && orig_size <= max_size(),
a61af66fc99e Initial load
duke
parents:
diff changeset
169 "just checking");
a61af66fc99e Initial load
duke
parents:
diff changeset
170
a61af66fc99e Initial load
duke
parents:
diff changeset
171 // Adjust new generation size
a61af66fc99e Initial load
duke
parents:
diff changeset
172 const size_t eden_plus_survivors =
a61af66fc99e Initial load
duke
parents:
diff changeset
173 align_size_up(eden_size + 2 * survivor_size, alignment);
a61af66fc99e Initial load
duke
parents:
diff changeset
174 size_t desired_size = MAX2(MIN2(eden_plus_survivors, gen_size_limit()),
a61af66fc99e Initial load
duke
parents:
diff changeset
175 min_gen_size());
a61af66fc99e Initial load
duke
parents:
diff changeset
176 assert(desired_size <= gen_size_limit(), "just checking");
a61af66fc99e Initial load
duke
parents:
diff changeset
177
a61af66fc99e Initial load
duke
parents:
diff changeset
178 if (desired_size > orig_size) {
a61af66fc99e Initial load
duke
parents:
diff changeset
179 // Grow the generation
a61af66fc99e Initial load
duke
parents:
diff changeset
180 size_t change = desired_size - orig_size;
263
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 13
diff changeset
181 HeapWord* prev_low = (HeapWord*) virtual_space()->low();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
182 if (!virtual_space()->expand_by(change)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
183 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
184 }
263
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 13
diff changeset
185 if (ZapUnusedHeapArea) {
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 13
diff changeset
186 // 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
187 // 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
188 // spaces have been computed.
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 13
diff changeset
189 HeapWord* new_low = (HeapWord*) virtual_space()->low();
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 13
diff changeset
190 assert(new_low < prev_low, "Did not grow");
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 13
diff changeset
191
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 13
diff changeset
192 MemRegion mangle_region(new_low, prev_low);
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 13
diff changeset
193 SpaceMangler::mangle_region(mangle_region);
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 13
diff changeset
194 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
195 size_changed = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
196 } else if (desired_size < orig_size) {
a61af66fc99e Initial load
duke
parents:
diff changeset
197 size_t desired_change = orig_size - desired_size;
a61af66fc99e Initial load
duke
parents:
diff changeset
198
a61af66fc99e Initial load
duke
parents:
diff changeset
199 // How much is available for shrinking.
a61af66fc99e Initial load
duke
parents:
diff changeset
200 size_t available_bytes = limit_gen_shrink(desired_change);
a61af66fc99e Initial load
duke
parents:
diff changeset
201 size_t change = MIN2(desired_change, available_bytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
202 virtual_space()->shrink_by(change);
a61af66fc99e Initial load
duke
parents:
diff changeset
203 size_changed = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
204 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
205 if (Verbose && PrintGC) {
a61af66fc99e Initial load
duke
parents:
diff changeset
206 if (orig_size == gen_size_limit()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
207 gclog_or_tty->print_cr("ASPSYoung generation size at maximum: "
a61af66fc99e Initial load
duke
parents:
diff changeset
208 SIZE_FORMAT "K", orig_size/K);
a61af66fc99e Initial load
duke
parents:
diff changeset
209 } else if (orig_size == min_gen_size()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
210 gclog_or_tty->print_cr("ASPSYoung generation size at minium: "
a61af66fc99e Initial load
duke
parents:
diff changeset
211 SIZE_FORMAT "K", orig_size/K);
a61af66fc99e Initial load
duke
parents:
diff changeset
212 }
a61af66fc99e Initial load
duke
parents:
diff changeset
213 }
a61af66fc99e Initial load
duke
parents:
diff changeset
214 }
a61af66fc99e Initial load
duke
parents:
diff changeset
215
a61af66fc99e Initial load
duke
parents:
diff changeset
216 if (size_changed) {
a61af66fc99e Initial load
duke
parents:
diff changeset
217 reset_after_change();
a61af66fc99e Initial load
duke
parents:
diff changeset
218 if (Verbose && PrintGC) {
a61af66fc99e Initial load
duke
parents:
diff changeset
219 size_t current_size = virtual_space()->committed_size();
a61af66fc99e Initial load
duke
parents:
diff changeset
220 gclog_or_tty->print_cr("ASPSYoung generation size changed: "
a61af66fc99e Initial load
duke
parents:
diff changeset
221 SIZE_FORMAT "K->" SIZE_FORMAT "K",
a61af66fc99e Initial load
duke
parents:
diff changeset
222 orig_size/K, current_size/K);
a61af66fc99e Initial load
duke
parents:
diff changeset
223 }
a61af66fc99e Initial load
duke
parents:
diff changeset
224 }
a61af66fc99e Initial load
duke
parents:
diff changeset
225
a61af66fc99e Initial load
duke
parents:
diff changeset
226 guarantee(eden_plus_survivors <= virtual_space()->committed_size() ||
a61af66fc99e Initial load
duke
parents:
diff changeset
227 virtual_space()->committed_size() == max_size(), "Sanity");
a61af66fc99e Initial load
duke
parents:
diff changeset
228
a61af66fc99e Initial load
duke
parents:
diff changeset
229 return true;
a61af66fc99e Initial load
duke
parents:
diff changeset
230 }
a61af66fc99e Initial load
duke
parents:
diff changeset
231
a61af66fc99e Initial load
duke
parents:
diff changeset
232 // Similar to PSYoungGen::resize_spaces() but
a61af66fc99e Initial load
duke
parents:
diff changeset
233 // eden always starts at the low end of the committed virtual space
a61af66fc99e Initial load
duke
parents:
diff changeset
234 // current implementation does not allow holes between the spaces
a61af66fc99e Initial load
duke
parents:
diff changeset
235 // _young_generation_boundary has to be reset because it changes.
a61af66fc99e Initial load
duke
parents:
diff changeset
236 // so additional verification
263
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 13
diff changeset
237
0
a61af66fc99e Initial load
duke
parents:
diff changeset
238 void ASPSYoungGen::resize_spaces(size_t requested_eden_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
239 size_t requested_survivor_size) {
263
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 13
diff changeset
240 assert(UseAdaptiveSizePolicy, "sanity check");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
241 assert(requested_eden_size > 0 && requested_survivor_size > 0,
a61af66fc99e Initial load
duke
parents:
diff changeset
242 "just checking");
a61af66fc99e Initial load
duke
parents:
diff changeset
243
a61af66fc99e Initial load
duke
parents:
diff changeset
244 space_invariants();
a61af66fc99e Initial load
duke
parents:
diff changeset
245
a61af66fc99e Initial load
duke
parents:
diff changeset
246 // We require eden and to space to be empty
a61af66fc99e Initial load
duke
parents:
diff changeset
247 if ((!eden_space()->is_empty()) || (!to_space()->is_empty())) {
a61af66fc99e Initial load
duke
parents:
diff changeset
248 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
249 }
a61af66fc99e Initial load
duke
parents:
diff changeset
250
a61af66fc99e Initial load
duke
parents:
diff changeset
251 if (PrintAdaptiveSizePolicy && Verbose) {
a61af66fc99e Initial load
duke
parents:
diff changeset
252 gclog_or_tty->print_cr("PSYoungGen::resize_spaces(requested_eden_size: "
a61af66fc99e Initial load
duke
parents:
diff changeset
253 SIZE_FORMAT
a61af66fc99e Initial load
duke
parents:
diff changeset
254 ", requested_survivor_size: " SIZE_FORMAT ")",
a61af66fc99e Initial load
duke
parents:
diff changeset
255 requested_eden_size, requested_survivor_size);
a61af66fc99e Initial load
duke
parents:
diff changeset
256 gclog_or_tty->print_cr(" eden: [" PTR_FORMAT ".." PTR_FORMAT ") "
a61af66fc99e Initial load
duke
parents:
diff changeset
257 SIZE_FORMAT,
a61af66fc99e Initial load
duke
parents:
diff changeset
258 eden_space()->bottom(),
a61af66fc99e Initial load
duke
parents:
diff changeset
259 eden_space()->end(),
a61af66fc99e Initial load
duke
parents:
diff changeset
260 pointer_delta(eden_space()->end(),
a61af66fc99e Initial load
duke
parents:
diff changeset
261 eden_space()->bottom(),
a61af66fc99e Initial load
duke
parents:
diff changeset
262 sizeof(char)));
a61af66fc99e Initial load
duke
parents:
diff changeset
263 gclog_or_tty->print_cr(" from: [" PTR_FORMAT ".." PTR_FORMAT ") "
a61af66fc99e Initial load
duke
parents:
diff changeset
264 SIZE_FORMAT,
a61af66fc99e Initial load
duke
parents:
diff changeset
265 from_space()->bottom(),
a61af66fc99e Initial load
duke
parents:
diff changeset
266 from_space()->end(),
a61af66fc99e Initial load
duke
parents:
diff changeset
267 pointer_delta(from_space()->end(),
a61af66fc99e Initial load
duke
parents:
diff changeset
268 from_space()->bottom(),
a61af66fc99e Initial load
duke
parents:
diff changeset
269 sizeof(char)));
a61af66fc99e Initial load
duke
parents:
diff changeset
270 gclog_or_tty->print_cr(" to: [" PTR_FORMAT ".." PTR_FORMAT ") "
a61af66fc99e Initial load
duke
parents:
diff changeset
271 SIZE_FORMAT,
a61af66fc99e Initial load
duke
parents:
diff changeset
272 to_space()->bottom(),
a61af66fc99e Initial load
duke
parents:
diff changeset
273 to_space()->end(),
a61af66fc99e Initial load
duke
parents:
diff changeset
274 pointer_delta( to_space()->end(),
a61af66fc99e Initial load
duke
parents:
diff changeset
275 to_space()->bottom(),
a61af66fc99e Initial load
duke
parents:
diff changeset
276 sizeof(char)));
a61af66fc99e Initial load
duke
parents:
diff changeset
277 }
a61af66fc99e Initial load
duke
parents:
diff changeset
278
a61af66fc99e Initial load
duke
parents:
diff changeset
279 // There's nothing to do if the new sizes are the same as the current
a61af66fc99e Initial load
duke
parents:
diff changeset
280 if (requested_survivor_size == to_space()->capacity_in_bytes() &&
a61af66fc99e Initial load
duke
parents:
diff changeset
281 requested_survivor_size == from_space()->capacity_in_bytes() &&
a61af66fc99e Initial load
duke
parents:
diff changeset
282 requested_eden_size == eden_space()->capacity_in_bytes()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
283 if (PrintAdaptiveSizePolicy && Verbose) {
a61af66fc99e Initial load
duke
parents:
diff changeset
284 gclog_or_tty->print_cr(" capacities are the right sizes, returning");
a61af66fc99e Initial load
duke
parents:
diff changeset
285 }
a61af66fc99e Initial load
duke
parents:
diff changeset
286 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
287 }
a61af66fc99e Initial load
duke
parents:
diff changeset
288
a61af66fc99e Initial load
duke
parents:
diff changeset
289 char* eden_start = (char*)virtual_space()->low();
a61af66fc99e Initial load
duke
parents:
diff changeset
290 char* eden_end = (char*)eden_space()->end();
a61af66fc99e Initial load
duke
parents:
diff changeset
291 char* from_start = (char*)from_space()->bottom();
a61af66fc99e Initial load
duke
parents:
diff changeset
292 char* from_end = (char*)from_space()->end();
a61af66fc99e Initial load
duke
parents:
diff changeset
293 char* to_start = (char*)to_space()->bottom();
a61af66fc99e Initial load
duke
parents:
diff changeset
294 char* to_end = (char*)to_space()->end();
a61af66fc99e Initial load
duke
parents:
diff changeset
295
a61af66fc99e Initial load
duke
parents:
diff changeset
296 assert(eden_start < from_start, "Cannot push into from_space");
a61af66fc99e Initial load
duke
parents:
diff changeset
297
a61af66fc99e Initial load
duke
parents:
diff changeset
298 ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap();
13
183f41cf8bfe 6557851: CMS: ergonomics defaults are not set with FLAG_SET_ERGO
jmasa
parents: 0
diff changeset
299 const 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
300 const bool maintain_minimum =
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 13
diff changeset
301 (requested_eden_size + 2 * requested_survivor_size) <= min_gen_size();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
302
263
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 13
diff changeset
303 bool eden_from_to_order = from_start < to_start;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
304 // 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
305 if (eden_from_to_order) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
306 // Eden, from, to
263
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 13
diff changeset
307
0
a61af66fc99e Initial load
duke
parents:
diff changeset
308 if (PrintAdaptiveSizePolicy && Verbose) {
a61af66fc99e Initial load
duke
parents:
diff changeset
309 gclog_or_tty->print_cr(" Eden, from, to:");
a61af66fc99e Initial load
duke
parents:
diff changeset
310 }
a61af66fc99e Initial load
duke
parents:
diff changeset
311
a61af66fc99e Initial load
duke
parents:
diff changeset
312 // Set eden
263
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 13
diff changeset
313 // "requested_eden_size" is a goal for the size of eden
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 13
diff changeset
314 // and may not be attainable. "eden_size" below is
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 13
diff changeset
315 // calculated based on the location of from-space and
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 13
diff changeset
316 // the goal for the size of eden. from-space is
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 13
diff changeset
317 // fixed in place because it contains live data.
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 13
diff changeset
318 // The calculation is done this way to avoid 32bit
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 13
diff changeset
319 // overflow (i.e., eden_start + requested_eden_size
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 13
diff changeset
320 // may too large for representation in 32bits).
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 13
diff changeset
321 size_t eden_size;
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 13
diff changeset
322 if (maintain_minimum) {
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 13
diff changeset
323 // Only make eden larger than the requested size if
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 13
diff changeset
324 // the minimum size of the generation has to be maintained.
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 13
diff changeset
325 // This could be done in general but policy at a higher
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 13
diff changeset
326 // level is determining a requested size for eden and that
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 13
diff changeset
327 // should be honored unless there is a fundamental reason.
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 13
diff changeset
328 eden_size = pointer_delta(from_start,
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 13
diff changeset
329 eden_start,
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 13
diff changeset
330 sizeof(char));
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 13
diff changeset
331 } else {
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 13
diff changeset
332 eden_size = MIN2(requested_eden_size,
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 13
diff changeset
333 pointer_delta(from_start, eden_start, sizeof(char)));
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 13
diff changeset
334 }
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 13
diff changeset
335
0
a61af66fc99e Initial load
duke
parents:
diff changeset
336 eden_end = eden_start + eden_size;
1489
cff162798819 6888953: some calls to function-like macros are missing semicolons
jcoomes
parents: 269
diff changeset
337 assert(eden_end >= eden_start, "addition overflowed");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
338
a61af66fc99e Initial load
duke
parents:
diff changeset
339 // To may resize into from space as long as it is clear of live data.
a61af66fc99e Initial load
duke
parents:
diff changeset
340 // From space must remain page aligned, though, so we need to do some
a61af66fc99e Initial load
duke
parents:
diff changeset
341 // extra calculations.
a61af66fc99e Initial load
duke
parents:
diff changeset
342
a61af66fc99e Initial load
duke
parents:
diff changeset
343 // First calculate an optimal to-space
a61af66fc99e Initial load
duke
parents:
diff changeset
344 to_end = (char*)virtual_space()->high();
a61af66fc99e Initial load
duke
parents:
diff changeset
345 to_start = (char*)pointer_delta(to_end,
a61af66fc99e Initial load
duke
parents:
diff changeset
346 (char*)requested_survivor_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
347 sizeof(char));
a61af66fc99e Initial load
duke
parents:
diff changeset
348
a61af66fc99e Initial load
duke
parents:
diff changeset
349 // Does the optimal to-space overlap from-space?
a61af66fc99e Initial load
duke
parents:
diff changeset
350 if (to_start < (char*)from_space()->end()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
351 assert(heap->kind() == CollectedHeap::ParallelScavengeHeap, "Sanity");
a61af66fc99e Initial load
duke
parents:
diff changeset
352
a61af66fc99e Initial load
duke
parents:
diff changeset
353 // Calculate the minimum offset possible for from_end
a61af66fc99e Initial load
duke
parents:
diff changeset
354 size_t from_size =
a61af66fc99e Initial load
duke
parents:
diff changeset
355 pointer_delta(from_space()->top(), from_start, sizeof(char));
a61af66fc99e Initial load
duke
parents:
diff changeset
356
a61af66fc99e Initial load
duke
parents:
diff changeset
357 // Should we be in this method if from_space is empty? Why not the set_space method? FIX ME!
a61af66fc99e Initial load
duke
parents:
diff changeset
358 if (from_size == 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
359 from_size = alignment;
a61af66fc99e Initial load
duke
parents:
diff changeset
360 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
361 from_size = align_size_up(from_size, alignment);
a61af66fc99e Initial load
duke
parents:
diff changeset
362 }
a61af66fc99e Initial load
duke
parents:
diff changeset
363
a61af66fc99e Initial load
duke
parents:
diff changeset
364 from_end = from_start + from_size;
a61af66fc99e Initial load
duke
parents:
diff changeset
365 assert(from_end > from_start, "addition overflow or from_size problem");
a61af66fc99e Initial load
duke
parents:
diff changeset
366
a61af66fc99e Initial load
duke
parents:
diff changeset
367 guarantee(from_end <= (char*)from_space()->end(),
a61af66fc99e Initial load
duke
parents:
diff changeset
368 "from_end moved to the right");
a61af66fc99e Initial load
duke
parents:
diff changeset
369
a61af66fc99e Initial load
duke
parents:
diff changeset
370 // Now update to_start with the new from_end
a61af66fc99e Initial load
duke
parents:
diff changeset
371 to_start = MAX2(from_end, to_start);
a61af66fc99e Initial load
duke
parents:
diff changeset
372 }
a61af66fc99e Initial load
duke
parents:
diff changeset
373
a61af66fc99e Initial load
duke
parents:
diff changeset
374 guarantee(to_start != to_end, "to space is zero sized");
a61af66fc99e Initial load
duke
parents:
diff changeset
375
a61af66fc99e Initial load
duke
parents:
diff changeset
376 if (PrintAdaptiveSizePolicy && Verbose) {
a61af66fc99e Initial load
duke
parents:
diff changeset
377 gclog_or_tty->print_cr(" [eden_start .. eden_end): "
a61af66fc99e Initial load
duke
parents:
diff changeset
378 "[" PTR_FORMAT " .. " PTR_FORMAT ") " SIZE_FORMAT,
a61af66fc99e Initial load
duke
parents:
diff changeset
379 eden_start,
a61af66fc99e Initial load
duke
parents:
diff changeset
380 eden_end,
a61af66fc99e Initial load
duke
parents:
diff changeset
381 pointer_delta(eden_end, eden_start, sizeof(char)));
a61af66fc99e Initial load
duke
parents:
diff changeset
382 gclog_or_tty->print_cr(" [from_start .. from_end): "
a61af66fc99e Initial load
duke
parents:
diff changeset
383 "[" PTR_FORMAT " .. " PTR_FORMAT ") " SIZE_FORMAT,
a61af66fc99e Initial load
duke
parents:
diff changeset
384 from_start,
a61af66fc99e Initial load
duke
parents:
diff changeset
385 from_end,
a61af66fc99e Initial load
duke
parents:
diff changeset
386 pointer_delta(from_end, from_start, sizeof(char)));
a61af66fc99e Initial load
duke
parents:
diff changeset
387 gclog_or_tty->print_cr(" [ to_start .. to_end): "
a61af66fc99e Initial load
duke
parents:
diff changeset
388 "[" PTR_FORMAT " .. " PTR_FORMAT ") " SIZE_FORMAT,
a61af66fc99e Initial load
duke
parents:
diff changeset
389 to_start,
a61af66fc99e Initial load
duke
parents:
diff changeset
390 to_end,
a61af66fc99e Initial load
duke
parents:
diff changeset
391 pointer_delta( to_end, to_start, sizeof(char)));
a61af66fc99e Initial load
duke
parents:
diff changeset
392 }
a61af66fc99e Initial load
duke
parents:
diff changeset
393 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
394 // Eden, to, from
a61af66fc99e Initial load
duke
parents:
diff changeset
395 if (PrintAdaptiveSizePolicy && Verbose) {
a61af66fc99e Initial load
duke
parents:
diff changeset
396 gclog_or_tty->print_cr(" Eden, to, from:");
a61af66fc99e Initial load
duke
parents:
diff changeset
397 }
a61af66fc99e Initial load
duke
parents:
diff changeset
398
a61af66fc99e Initial load
duke
parents:
diff changeset
399 // To space gets priority over eden resizing. Note that we position
a61af66fc99e Initial load
duke
parents:
diff changeset
400 // to space as if we were able to resize from space, even though from
a61af66fc99e Initial load
duke
parents:
diff changeset
401 // space is not modified.
a61af66fc99e Initial load
duke
parents:
diff changeset
402 // Giving eden priority was tried and gave poorer performance.
a61af66fc99e Initial load
duke
parents:
diff changeset
403 to_end = (char*)pointer_delta(virtual_space()->high(),
a61af66fc99e Initial load
duke
parents:
diff changeset
404 (char*)requested_survivor_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
405 sizeof(char));
a61af66fc99e Initial load
duke
parents:
diff changeset
406 to_end = MIN2(to_end, from_start);
a61af66fc99e Initial load
duke
parents:
diff changeset
407 to_start = (char*)pointer_delta(to_end, (char*)requested_survivor_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
408 sizeof(char));
a61af66fc99e Initial load
duke
parents:
diff changeset
409 // if the space sizes are to be increased by several times then
a61af66fc99e Initial load
duke
parents:
diff changeset
410 // 'to_start' will point beyond the young generation. In this case
a61af66fc99e Initial load
duke
parents:
diff changeset
411 // 'to_start' should be adjusted.
a61af66fc99e Initial load
duke
parents:
diff changeset
412 to_start = MAX2(to_start, eden_start + alignment);
a61af66fc99e Initial load
duke
parents:
diff changeset
413
a61af66fc99e Initial load
duke
parents:
diff changeset
414 // Compute how big eden can be, then adjust end.
263
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 13
diff changeset
415 // See comments above on calculating eden_end.
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 13
diff changeset
416 size_t eden_size;
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 13
diff changeset
417 if (maintain_minimum) {
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 13
diff changeset
418 eden_size = pointer_delta(to_start, eden_start, sizeof(char));
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 13
diff changeset
419 } else {
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 13
diff changeset
420 eden_size = MIN2(requested_eden_size,
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 13
diff changeset
421 pointer_delta(to_start, eden_start, sizeof(char)));
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 13
diff changeset
422 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
423 eden_end = eden_start + eden_size;
1489
cff162798819 6888953: some calls to function-like macros are missing semicolons
jcoomes
parents: 269
diff changeset
424 assert(eden_end >= eden_start, "addition overflowed");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
425
a61af66fc99e Initial load
duke
parents:
diff changeset
426 // Don't let eden shrink down to 0 or less.
a61af66fc99e Initial load
duke
parents:
diff changeset
427 eden_end = MAX2(eden_end, eden_start + alignment);
a61af66fc99e Initial load
duke
parents:
diff changeset
428 to_start = MAX2(to_start, eden_end);
a61af66fc99e Initial load
duke
parents:
diff changeset
429
a61af66fc99e Initial load
duke
parents:
diff changeset
430 if (PrintAdaptiveSizePolicy && Verbose) {
a61af66fc99e Initial load
duke
parents:
diff changeset
431 gclog_or_tty->print_cr(" [eden_start .. eden_end): "
a61af66fc99e Initial load
duke
parents:
diff changeset
432 "[" PTR_FORMAT " .. " PTR_FORMAT ") " SIZE_FORMAT,
a61af66fc99e Initial load
duke
parents:
diff changeset
433 eden_start,
a61af66fc99e Initial load
duke
parents:
diff changeset
434 eden_end,
a61af66fc99e Initial load
duke
parents:
diff changeset
435 pointer_delta(eden_end, eden_start, sizeof(char)));
a61af66fc99e Initial load
duke
parents:
diff changeset
436 gclog_or_tty->print_cr(" [ to_start .. to_end): "
a61af66fc99e Initial load
duke
parents:
diff changeset
437 "[" PTR_FORMAT " .. " PTR_FORMAT ") " SIZE_FORMAT,
a61af66fc99e Initial load
duke
parents:
diff changeset
438 to_start,
a61af66fc99e Initial load
duke
parents:
diff changeset
439 to_end,
a61af66fc99e Initial load
duke
parents:
diff changeset
440 pointer_delta( to_end, to_start, sizeof(char)));
a61af66fc99e Initial load
duke
parents:
diff changeset
441 gclog_or_tty->print_cr(" [from_start .. from_end): "
a61af66fc99e Initial load
duke
parents:
diff changeset
442 "[" PTR_FORMAT " .. " PTR_FORMAT ") " SIZE_FORMAT,
a61af66fc99e Initial load
duke
parents:
diff changeset
443 from_start,
a61af66fc99e Initial load
duke
parents:
diff changeset
444 from_end,
a61af66fc99e Initial load
duke
parents:
diff changeset
445 pointer_delta(from_end, from_start, sizeof(char)));
a61af66fc99e Initial load
duke
parents:
diff changeset
446 }
a61af66fc99e Initial load
duke
parents:
diff changeset
447 }
a61af66fc99e Initial load
duke
parents:
diff changeset
448
a61af66fc99e Initial load
duke
parents:
diff changeset
449
a61af66fc99e Initial load
duke
parents:
diff changeset
450 guarantee((HeapWord*)from_start <= from_space()->bottom(),
a61af66fc99e Initial load
duke
parents:
diff changeset
451 "from start moved to the right");
a61af66fc99e Initial load
duke
parents:
diff changeset
452 guarantee((HeapWord*)from_end >= from_space()->top(),
a61af66fc99e Initial load
duke
parents:
diff changeset
453 "from end moved into live data");
a61af66fc99e Initial load
duke
parents:
diff changeset
454 assert(is_object_aligned((intptr_t)eden_start), "checking alignment");
a61af66fc99e Initial load
duke
parents:
diff changeset
455 assert(is_object_aligned((intptr_t)from_start), "checking alignment");
a61af66fc99e Initial load
duke
parents:
diff changeset
456 assert(is_object_aligned((intptr_t)to_start), "checking alignment");
a61af66fc99e Initial load
duke
parents:
diff changeset
457
a61af66fc99e Initial load
duke
parents:
diff changeset
458 MemRegion edenMR((HeapWord*)eden_start, (HeapWord*)eden_end);
a61af66fc99e Initial load
duke
parents:
diff changeset
459 MemRegion toMR ((HeapWord*)to_start, (HeapWord*)to_end);
a61af66fc99e Initial load
duke
parents:
diff changeset
460 MemRegion fromMR((HeapWord*)from_start, (HeapWord*)from_end);
a61af66fc99e Initial load
duke
parents:
diff changeset
461
a61af66fc99e Initial load
duke
parents:
diff changeset
462 // Let's make sure the call to initialize doesn't reset "top"!
a61af66fc99e Initial load
duke
parents:
diff changeset
463 DEBUG_ONLY(HeapWord* old_from_top = from_space()->top();)
a61af66fc99e Initial load
duke
parents:
diff changeset
464
a61af66fc99e Initial load
duke
parents:
diff changeset
465 // For PrintAdaptiveSizePolicy block below
a61af66fc99e Initial load
duke
parents:
diff changeset
466 size_t old_from = from_space()->capacity_in_bytes();
a61af66fc99e Initial load
duke
parents:
diff changeset
467 size_t old_to = to_space()->capacity_in_bytes();
a61af66fc99e Initial load
duke
parents:
diff changeset
468
263
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 13
diff changeset
469 if (ZapUnusedHeapArea) {
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 13
diff changeset
470 // 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
471 // 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
472 // 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
473 // 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
474 // spaces and are mangled.
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 13
diff changeset
475 if (UseNUMA) {
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 13
diff changeset
476 if (eden_from_to_order) {
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 13
diff changeset
477 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
478 } else {
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 13
diff changeset
479 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
480 }
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 13
diff changeset
481 }
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 13
diff changeset
482
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 13
diff changeset
483 // 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
484 // the spaces are already mangled.
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 13
diff changeset
485 // 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
486 // 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
487 // in the calls to initialize().
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 13
diff changeset
488 // 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
489 // 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
490 // 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
491 // 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
492
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 13
diff changeset
493 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
494 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
495 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
496 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
497 }
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 13
diff changeset
498 // 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
499 // 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
500 eden_space()->initialize(edenMR,
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 13
diff changeset
501 SpaceDecorator::Clear,
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 13
diff changeset
502 SpaceDecorator::DontMangle);
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 13
diff changeset
503 to_space()->initialize(toMR,
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 13
diff changeset
504 SpaceDecorator::Clear,
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 13
diff changeset
505 SpaceDecorator::DontMangle);
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 13
diff changeset
506 from_space()->initialize(fromMR,
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 13
diff changeset
507 SpaceDecorator::DontClear,
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 13
diff changeset
508 SpaceDecorator::DontMangle);
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 13
diff changeset
509
0
a61af66fc99e Initial load
duke
parents:
diff changeset
510 PSScavenge::set_young_generation_boundary(eden_space()->bottom());
a61af66fc99e Initial load
duke
parents:
diff changeset
511
a61af66fc99e Initial load
duke
parents:
diff changeset
512 assert(from_space()->top() == old_from_top, "from top changed!");
a61af66fc99e Initial load
duke
parents:
diff changeset
513
a61af66fc99e Initial load
duke
parents:
diff changeset
514 if (PrintAdaptiveSizePolicy) {
a61af66fc99e Initial load
duke
parents:
diff changeset
515 ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap();
a61af66fc99e Initial load
duke
parents:
diff changeset
516 assert(heap->kind() == CollectedHeap::ParallelScavengeHeap, "Sanity");
a61af66fc99e Initial load
duke
parents:
diff changeset
517
a61af66fc99e Initial load
duke
parents:
diff changeset
518 gclog_or_tty->print("AdaptiveSizePolicy::survivor space sizes: "
a61af66fc99e Initial load
duke
parents:
diff changeset
519 "collection: %d "
a61af66fc99e Initial load
duke
parents:
diff changeset
520 "(" SIZE_FORMAT ", " SIZE_FORMAT ") -> "
a61af66fc99e Initial load
duke
parents:
diff changeset
521 "(" SIZE_FORMAT ", " SIZE_FORMAT ") ",
a61af66fc99e Initial load
duke
parents:
diff changeset
522 heap->total_collections(),
a61af66fc99e Initial load
duke
parents:
diff changeset
523 old_from, old_to,
a61af66fc99e Initial load
duke
parents:
diff changeset
524 from_space()->capacity_in_bytes(),
a61af66fc99e Initial load
duke
parents:
diff changeset
525 to_space()->capacity_in_bytes());
a61af66fc99e Initial load
duke
parents:
diff changeset
526 gclog_or_tty->cr();
a61af66fc99e Initial load
duke
parents:
diff changeset
527 }
a61af66fc99e Initial load
duke
parents:
diff changeset
528 space_invariants();
a61af66fc99e Initial load
duke
parents:
diff changeset
529 }
a61af66fc99e Initial load
duke
parents:
diff changeset
530 void ASPSYoungGen::reset_after_change() {
a61af66fc99e Initial load
duke
parents:
diff changeset
531 assert_locked_or_safepoint(Heap_lock);
a61af66fc99e Initial load
duke
parents:
diff changeset
532
a61af66fc99e Initial load
duke
parents:
diff changeset
533 _reserved = MemRegion((HeapWord*)virtual_space()->low_boundary(),
a61af66fc99e Initial load
duke
parents:
diff changeset
534 (HeapWord*)virtual_space()->high_boundary());
a61af66fc99e Initial load
duke
parents:
diff changeset
535 PSScavenge::reference_processor()->set_span(_reserved);
a61af66fc99e Initial load
duke
parents:
diff changeset
536
a61af66fc99e Initial load
duke
parents:
diff changeset
537 HeapWord* new_eden_bottom = (HeapWord*)virtual_space()->low();
a61af66fc99e Initial load
duke
parents:
diff changeset
538 HeapWord* eden_bottom = eden_space()->bottom();
a61af66fc99e Initial load
duke
parents:
diff changeset
539 if (new_eden_bottom != eden_bottom) {
a61af66fc99e Initial load
duke
parents:
diff changeset
540 MemRegion eden_mr(new_eden_bottom, eden_space()->end());
263
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 13
diff changeset
541 eden_space()->initialize(eden_mr,
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 13
diff changeset
542 SpaceDecorator::Clear,
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 13
diff changeset
543 SpaceDecorator::Mangle);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
544 PSScavenge::set_young_generation_boundary(eden_space()->bottom());
a61af66fc99e Initial load
duke
parents:
diff changeset
545 }
a61af66fc99e Initial load
duke
parents:
diff changeset
546 MemRegion cmr((HeapWord*)virtual_space()->low(),
a61af66fc99e Initial load
duke
parents:
diff changeset
547 (HeapWord*)virtual_space()->high());
a61af66fc99e Initial load
duke
parents:
diff changeset
548 Universe::heap()->barrier_set()->resize_covered_region(cmr);
a61af66fc99e Initial load
duke
parents:
diff changeset
549
a61af66fc99e Initial load
duke
parents:
diff changeset
550 space_invariants();
a61af66fc99e Initial load
duke
parents:
diff changeset
551 }