annotate src/share/vm/gc_implementation/parallelScavenge/adjoiningGenerations.cpp @ 6725:da91efe96a93

6964458: Reimplement class meta-data storage to use native memory Summary: Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland Contributed-by: jmasa <jon.masamitsu@oracle.com>, stefank <stefan.karlsson@oracle.com>, mgerdin <mikael.gerdin@oracle.com>, never <tom.rodriguez@oracle.com>
author coleenp
date Sat, 01 Sep 2012 13:25:18 -0400
parents f95d63e2154a
children 8f07aa079343
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1972
diff changeset
2 * Copyright (c) 2003, 2012, 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: 0
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
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: 0
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/adjoiningGenerations.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
27 #include "gc_implementation/parallelScavenge/adjoiningVirtualSpaces.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
28 #include "gc_implementation/parallelScavenge/parallelScavengeHeap.hpp"
0
a61af66fc99e Initial load
duke
parents:
diff changeset
29
a61af66fc99e Initial load
duke
parents:
diff changeset
30 // If boundary moving is being used, create the young gen and old
a61af66fc99e Initial load
duke
parents:
diff changeset
31 // gen with ASPSYoungGen and ASPSOldGen, respectively. Revert to
a61af66fc99e Initial load
duke
parents:
diff changeset
32 // the old behavior otherwise (with PSYoungGen and PSOldGen).
a61af66fc99e Initial load
duke
parents:
diff changeset
33
a61af66fc99e Initial load
duke
parents:
diff changeset
34 AdjoiningGenerations::AdjoiningGenerations(ReservedSpace old_young_rs,
a61af66fc99e Initial load
duke
parents:
diff changeset
35 size_t init_low_byte_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
36 size_t min_low_byte_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
37 size_t max_low_byte_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
38 size_t init_high_byte_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
39 size_t min_high_byte_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
40 size_t max_high_byte_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
41 size_t alignment) :
a61af66fc99e Initial load
duke
parents:
diff changeset
42 _virtual_spaces(old_young_rs, min_low_byte_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
43 min_high_byte_size, alignment) {
a61af66fc99e Initial load
duke
parents:
diff changeset
44 assert(min_low_byte_size <= init_low_byte_size &&
a61af66fc99e Initial load
duke
parents:
diff changeset
45 init_low_byte_size <= max_low_byte_size, "Parameter check");
a61af66fc99e Initial load
duke
parents:
diff changeset
46 assert(min_high_byte_size <= init_high_byte_size &&
a61af66fc99e Initial load
duke
parents:
diff changeset
47 init_high_byte_size <= max_high_byte_size, "Parameter check");
a61af66fc99e Initial load
duke
parents:
diff changeset
48 // Create the generations differently based on the option to
a61af66fc99e Initial load
duke
parents:
diff changeset
49 // move the boundary.
a61af66fc99e Initial load
duke
parents:
diff changeset
50 if (UseAdaptiveGCBoundary) {
a61af66fc99e Initial load
duke
parents:
diff changeset
51 // Initialize the adjoining virtual spaces. Then pass the
a61af66fc99e Initial load
duke
parents:
diff changeset
52 // a virtual to each generation for initialization of the
a61af66fc99e Initial load
duke
parents:
diff changeset
53 // generation.
a61af66fc99e Initial load
duke
parents:
diff changeset
54
a61af66fc99e Initial load
duke
parents:
diff changeset
55 // Does the actual creation of the virtual spaces
a61af66fc99e Initial load
duke
parents:
diff changeset
56 _virtual_spaces.initialize(max_low_byte_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
57 init_low_byte_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
58 init_high_byte_size);
a61af66fc99e Initial load
duke
parents:
diff changeset
59
a61af66fc99e Initial load
duke
parents:
diff changeset
60 // Place the young gen at the high end. Passes in the virtual space.
a61af66fc99e Initial load
duke
parents:
diff changeset
61 _young_gen = new ASPSYoungGen(_virtual_spaces.high(),
a61af66fc99e Initial load
duke
parents:
diff changeset
62 _virtual_spaces.high()->committed_size(),
a61af66fc99e Initial load
duke
parents:
diff changeset
63 min_high_byte_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
64 _virtual_spaces.high_byte_size_limit());
a61af66fc99e Initial load
duke
parents:
diff changeset
65
a61af66fc99e Initial load
duke
parents:
diff changeset
66 // Place the old gen at the low end. Passes in the virtual space.
a61af66fc99e Initial load
duke
parents:
diff changeset
67 _old_gen = new ASPSOldGen(_virtual_spaces.low(),
a61af66fc99e Initial load
duke
parents:
diff changeset
68 _virtual_spaces.low()->committed_size(),
a61af66fc99e Initial load
duke
parents:
diff changeset
69 min_low_byte_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
70 _virtual_spaces.low_byte_size_limit(),
a61af66fc99e Initial load
duke
parents:
diff changeset
71 "old", 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
72
a61af66fc99e Initial load
duke
parents:
diff changeset
73 young_gen()->initialize_work();
a61af66fc99e Initial load
duke
parents:
diff changeset
74 assert(young_gen()->reserved().byte_size() <= young_gen()->gen_size_limit(),
a61af66fc99e Initial load
duke
parents:
diff changeset
75 "Consistency check");
a61af66fc99e Initial load
duke
parents:
diff changeset
76 assert(old_young_rs.size() >= young_gen()->gen_size_limit(),
a61af66fc99e Initial load
duke
parents:
diff changeset
77 "Consistency check");
a61af66fc99e Initial load
duke
parents:
diff changeset
78
a61af66fc99e Initial load
duke
parents:
diff changeset
79 old_gen()->initialize_work("old", 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
80 assert(old_gen()->reserved().byte_size() <= old_gen()->gen_size_limit(),
a61af66fc99e Initial load
duke
parents:
diff changeset
81 "Consistency check");
a61af66fc99e Initial load
duke
parents:
diff changeset
82 assert(old_young_rs.size() >= old_gen()->gen_size_limit(),
a61af66fc99e Initial load
duke
parents:
diff changeset
83 "Consistency check");
a61af66fc99e Initial load
duke
parents:
diff changeset
84 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
85
a61af66fc99e Initial load
duke
parents:
diff changeset
86 // Layout the reserved space for the generations.
a61af66fc99e Initial load
duke
parents:
diff changeset
87 ReservedSpace old_rs =
a61af66fc99e Initial load
duke
parents:
diff changeset
88 virtual_spaces()->reserved_space().first_part(max_low_byte_size);
a61af66fc99e Initial load
duke
parents:
diff changeset
89 ReservedSpace heap_rs =
a61af66fc99e Initial load
duke
parents:
diff changeset
90 virtual_spaces()->reserved_space().last_part(max_low_byte_size);
a61af66fc99e Initial load
duke
parents:
diff changeset
91 ReservedSpace young_rs = heap_rs.first_part(max_high_byte_size);
a61af66fc99e Initial load
duke
parents:
diff changeset
92 assert(young_rs.size() == heap_rs.size(), "Didn't reserve all of the heap");
a61af66fc99e Initial load
duke
parents:
diff changeset
93
a61af66fc99e Initial load
duke
parents:
diff changeset
94 // Create the generations. Virtual spaces are not passed in.
a61af66fc99e Initial load
duke
parents:
diff changeset
95 _young_gen = new PSYoungGen(init_high_byte_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
96 min_high_byte_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
97 max_high_byte_size);
a61af66fc99e Initial load
duke
parents:
diff changeset
98 _old_gen = new PSOldGen(init_low_byte_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
99 min_low_byte_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
100 max_low_byte_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
101 "old", 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
102
a61af66fc99e Initial load
duke
parents:
diff changeset
103 // The virtual spaces are created by the initialization of the gens.
a61af66fc99e Initial load
duke
parents:
diff changeset
104 _young_gen->initialize(young_rs, alignment);
a61af66fc99e Initial load
duke
parents:
diff changeset
105 assert(young_gen()->gen_size_limit() == young_rs.size(),
a61af66fc99e Initial load
duke
parents:
diff changeset
106 "Consistency check");
a61af66fc99e Initial load
duke
parents:
diff changeset
107 _old_gen->initialize(old_rs, alignment, "old", 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
108 assert(old_gen()->gen_size_limit() == old_rs.size(), "Consistency check");
a61af66fc99e Initial load
duke
parents:
diff changeset
109 }
a61af66fc99e Initial load
duke
parents:
diff changeset
110 }
a61af66fc99e Initial load
duke
parents:
diff changeset
111
a61af66fc99e Initial load
duke
parents:
diff changeset
112 size_t AdjoiningGenerations::reserved_byte_size() {
a61af66fc99e Initial load
duke
parents:
diff changeset
113 return virtual_spaces()->reserved_space().size();
a61af66fc99e Initial load
duke
parents:
diff changeset
114 }
a61af66fc99e Initial load
duke
parents:
diff changeset
115
a61af66fc99e Initial load
duke
parents:
diff changeset
116
a61af66fc99e Initial load
duke
parents:
diff changeset
117 // Make checks on the current sizes of the generations and
a61af66fc99e Initial load
duke
parents:
diff changeset
118 // the contraints on the sizes of the generations. Push
a61af66fc99e Initial load
duke
parents:
diff changeset
119 // up the boundary within the contraints. A partial
a61af66fc99e Initial load
duke
parents:
diff changeset
120 // push can occur.
a61af66fc99e Initial load
duke
parents:
diff changeset
121 void AdjoiningGenerations::request_old_gen_expansion(size_t expand_in_bytes) {
a61af66fc99e Initial load
duke
parents:
diff changeset
122 assert(UseAdaptiveSizePolicy && UseAdaptiveGCBoundary, "runtime check");
a61af66fc99e Initial load
duke
parents:
diff changeset
123
a61af66fc99e Initial load
duke
parents:
diff changeset
124 assert_lock_strong(ExpandHeap_lock);
a61af66fc99e Initial load
duke
parents:
diff changeset
125 assert_locked_or_safepoint(Heap_lock);
a61af66fc99e Initial load
duke
parents:
diff changeset
126
a61af66fc99e Initial load
duke
parents:
diff changeset
127 // These sizes limit the amount the boundaries can move. Effectively,
a61af66fc99e Initial load
duke
parents:
diff changeset
128 // the generation says how much it is willing to yield to the other
a61af66fc99e Initial load
duke
parents:
diff changeset
129 // generation.
a61af66fc99e Initial load
duke
parents:
diff changeset
130 const size_t young_gen_available = young_gen()->available_for_contraction();
a61af66fc99e Initial load
duke
parents:
diff changeset
131 const size_t old_gen_available = old_gen()->available_for_expansion();
a61af66fc99e Initial load
duke
parents:
diff changeset
132 const size_t alignment = virtual_spaces()->alignment();
a61af66fc99e Initial load
duke
parents:
diff changeset
133 size_t change_in_bytes = MIN3(young_gen_available,
a61af66fc99e Initial load
duke
parents:
diff changeset
134 old_gen_available,
a61af66fc99e Initial load
duke
parents:
diff changeset
135 align_size_up_(expand_in_bytes, alignment));
a61af66fc99e Initial load
duke
parents:
diff changeset
136
a61af66fc99e Initial load
duke
parents:
diff changeset
137 if (change_in_bytes == 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
138 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
139 }
a61af66fc99e Initial load
duke
parents:
diff changeset
140
a61af66fc99e Initial load
duke
parents:
diff changeset
141 if (TraceAdaptiveGCBoundary) {
a61af66fc99e Initial load
duke
parents:
diff changeset
142 gclog_or_tty->print_cr("Before expansion of old gen with boundary move");
a61af66fc99e Initial load
duke
parents:
diff changeset
143 gclog_or_tty->print_cr(" Requested change: 0x%x Attempted change: 0x%x",
a61af66fc99e Initial load
duke
parents:
diff changeset
144 expand_in_bytes, change_in_bytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
145 if (!PrintHeapAtGC) {
a61af66fc99e Initial load
duke
parents:
diff changeset
146 Universe::print_on(gclog_or_tty);
a61af66fc99e Initial load
duke
parents:
diff changeset
147 }
a61af66fc99e Initial load
duke
parents:
diff changeset
148 gclog_or_tty->print_cr(" PSOldGen max size: " SIZE_FORMAT "K",
a61af66fc99e Initial load
duke
parents:
diff changeset
149 old_gen()->max_gen_size()/K);
a61af66fc99e Initial load
duke
parents:
diff changeset
150 }
a61af66fc99e Initial load
duke
parents:
diff changeset
151
a61af66fc99e Initial load
duke
parents:
diff changeset
152 // Move the boundary between the generations up (smaller young gen).
a61af66fc99e Initial load
duke
parents:
diff changeset
153 if (virtual_spaces()->adjust_boundary_up(change_in_bytes)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
154 young_gen()->reset_after_change();
a61af66fc99e Initial load
duke
parents:
diff changeset
155 old_gen()->reset_after_change();
a61af66fc99e Initial load
duke
parents:
diff changeset
156 }
a61af66fc99e Initial load
duke
parents:
diff changeset
157
a61af66fc99e Initial load
duke
parents:
diff changeset
158 // The total reserved for the generations should match the sum
a61af66fc99e Initial load
duke
parents:
diff changeset
159 // of the two even if the boundary is moving.
a61af66fc99e Initial load
duke
parents:
diff changeset
160 assert(reserved_byte_size() ==
a61af66fc99e Initial load
duke
parents:
diff changeset
161 old_gen()->max_gen_size() + young_gen()->max_size(),
a61af66fc99e Initial load
duke
parents:
diff changeset
162 "Space is missing");
a61af66fc99e Initial load
duke
parents:
diff changeset
163 young_gen()->space_invariants();
a61af66fc99e Initial load
duke
parents:
diff changeset
164 old_gen()->space_invariants();
a61af66fc99e Initial load
duke
parents:
diff changeset
165
a61af66fc99e Initial load
duke
parents:
diff changeset
166 if (TraceAdaptiveGCBoundary) {
a61af66fc99e Initial load
duke
parents:
diff changeset
167 gclog_or_tty->print_cr("After expansion of old gen with boundary move");
a61af66fc99e Initial load
duke
parents:
diff changeset
168 if (!PrintHeapAtGC) {
a61af66fc99e Initial load
duke
parents:
diff changeset
169 Universe::print_on(gclog_or_tty);
a61af66fc99e Initial load
duke
parents:
diff changeset
170 }
a61af66fc99e Initial load
duke
parents:
diff changeset
171 gclog_or_tty->print_cr(" PSOldGen max size: " SIZE_FORMAT "K",
a61af66fc99e Initial load
duke
parents:
diff changeset
172 old_gen()->max_gen_size()/K);
a61af66fc99e Initial load
duke
parents:
diff changeset
173 }
a61af66fc99e Initial load
duke
parents:
diff changeset
174 }
a61af66fc99e Initial load
duke
parents:
diff changeset
175
a61af66fc99e Initial load
duke
parents:
diff changeset
176 // See comments on request_old_gen_expansion()
a61af66fc99e Initial load
duke
parents:
diff changeset
177 bool AdjoiningGenerations::request_young_gen_expansion(size_t expand_in_bytes) {
a61af66fc99e Initial load
duke
parents:
diff changeset
178 assert(UseAdaptiveSizePolicy && UseAdaptiveGCBoundary, "runtime check");
a61af66fc99e Initial load
duke
parents:
diff changeset
179
a61af66fc99e Initial load
duke
parents:
diff changeset
180 // If eden is not empty, the boundary can be moved but no advantage
a61af66fc99e Initial load
duke
parents:
diff changeset
181 // can be made of the move since eden cannot be moved.
a61af66fc99e Initial load
duke
parents:
diff changeset
182 if (!young_gen()->eden_space()->is_empty()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
183 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
184 }
a61af66fc99e Initial load
duke
parents:
diff changeset
185
a61af66fc99e Initial load
duke
parents:
diff changeset
186
a61af66fc99e Initial load
duke
parents:
diff changeset
187 bool result = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
188 const size_t young_gen_available = young_gen()->available_for_expansion();
a61af66fc99e Initial load
duke
parents:
diff changeset
189 const size_t old_gen_available = old_gen()->available_for_contraction();
a61af66fc99e Initial load
duke
parents:
diff changeset
190 const size_t alignment = virtual_spaces()->alignment();
a61af66fc99e Initial load
duke
parents:
diff changeset
191 size_t change_in_bytes = MIN3(young_gen_available,
a61af66fc99e Initial load
duke
parents:
diff changeset
192 old_gen_available,
a61af66fc99e Initial load
duke
parents:
diff changeset
193 align_size_up_(expand_in_bytes, alignment));
a61af66fc99e Initial load
duke
parents:
diff changeset
194
a61af66fc99e Initial load
duke
parents:
diff changeset
195 if (change_in_bytes == 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
196 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
197 }
a61af66fc99e Initial load
duke
parents:
diff changeset
198
a61af66fc99e Initial load
duke
parents:
diff changeset
199 if (TraceAdaptiveGCBoundary) {
a61af66fc99e Initial load
duke
parents:
diff changeset
200 gclog_or_tty->print_cr("Before expansion of young gen with boundary move");
a61af66fc99e Initial load
duke
parents:
diff changeset
201 gclog_or_tty->print_cr(" Requested change: 0x%x Attempted change: 0x%x",
a61af66fc99e Initial load
duke
parents:
diff changeset
202 expand_in_bytes, change_in_bytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
203 if (!PrintHeapAtGC) {
a61af66fc99e Initial load
duke
parents:
diff changeset
204 Universe::print_on(gclog_or_tty);
a61af66fc99e Initial load
duke
parents:
diff changeset
205 }
a61af66fc99e Initial load
duke
parents:
diff changeset
206 gclog_or_tty->print_cr(" PSYoungGen max size: " SIZE_FORMAT "K",
a61af66fc99e Initial load
duke
parents:
diff changeset
207 young_gen()->max_size()/K);
a61af66fc99e Initial load
duke
parents:
diff changeset
208 }
a61af66fc99e Initial load
duke
parents:
diff changeset
209
a61af66fc99e Initial load
duke
parents:
diff changeset
210 // Move the boundary between the generations down (smaller old gen).
a61af66fc99e Initial load
duke
parents:
diff changeset
211 MutexLocker x(ExpandHeap_lock);
a61af66fc99e Initial load
duke
parents:
diff changeset
212 if (virtual_spaces()->adjust_boundary_down(change_in_bytes)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
213 young_gen()->reset_after_change();
a61af66fc99e Initial load
duke
parents:
diff changeset
214 old_gen()->reset_after_change();
a61af66fc99e Initial load
duke
parents:
diff changeset
215 result = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
216 }
a61af66fc99e Initial load
duke
parents:
diff changeset
217
a61af66fc99e Initial load
duke
parents:
diff changeset
218 // The total reserved for the generations should match the sum
a61af66fc99e Initial load
duke
parents:
diff changeset
219 // of the two even if the boundary is moving.
a61af66fc99e Initial load
duke
parents:
diff changeset
220 assert(reserved_byte_size() ==
a61af66fc99e Initial load
duke
parents:
diff changeset
221 old_gen()->max_gen_size() + young_gen()->max_size(),
a61af66fc99e Initial load
duke
parents:
diff changeset
222 "Space is missing");
a61af66fc99e Initial load
duke
parents:
diff changeset
223 young_gen()->space_invariants();
a61af66fc99e Initial load
duke
parents:
diff changeset
224 old_gen()->space_invariants();
a61af66fc99e Initial load
duke
parents:
diff changeset
225
a61af66fc99e Initial load
duke
parents:
diff changeset
226 if (TraceAdaptiveGCBoundary) {
a61af66fc99e Initial load
duke
parents:
diff changeset
227 gclog_or_tty->print_cr("After expansion of young gen with boundary move");
a61af66fc99e Initial load
duke
parents:
diff changeset
228 if (!PrintHeapAtGC) {
a61af66fc99e Initial load
duke
parents:
diff changeset
229 Universe::print_on(gclog_or_tty);
a61af66fc99e Initial load
duke
parents:
diff changeset
230 }
a61af66fc99e Initial load
duke
parents:
diff changeset
231 gclog_or_tty->print_cr(" PSYoungGen max size: " SIZE_FORMAT "K",
a61af66fc99e Initial load
duke
parents:
diff changeset
232 young_gen()->max_size()/K);
a61af66fc99e Initial load
duke
parents:
diff changeset
233 }
a61af66fc99e Initial load
duke
parents:
diff changeset
234
a61af66fc99e Initial load
duke
parents:
diff changeset
235 return result;
a61af66fc99e Initial load
duke
parents:
diff changeset
236 }
a61af66fc99e Initial load
duke
parents:
diff changeset
237
a61af66fc99e Initial load
duke
parents:
diff changeset
238 // Additional space is needed in the old generation. Try to move the boundary
a61af66fc99e Initial load
duke
parents:
diff changeset
239 // up to meet the need. Moves boundary up only
a61af66fc99e Initial load
duke
parents:
diff changeset
240 void AdjoiningGenerations::adjust_boundary_for_old_gen_needs(
a61af66fc99e Initial load
duke
parents:
diff changeset
241 size_t desired_free_space) {
a61af66fc99e Initial load
duke
parents:
diff changeset
242 assert(UseAdaptiveSizePolicy && UseAdaptiveGCBoundary, "runtime check");
a61af66fc99e Initial load
duke
parents:
diff changeset
243
a61af66fc99e Initial load
duke
parents:
diff changeset
244 // Stress testing.
a61af66fc99e Initial load
duke
parents:
diff changeset
245 if (PSAdaptiveSizePolicyResizeVirtualSpaceAlot == 1) {
a61af66fc99e Initial load
duke
parents:
diff changeset
246 MutexLocker x(ExpandHeap_lock);
a61af66fc99e Initial load
duke
parents:
diff changeset
247 request_old_gen_expansion(virtual_spaces()->alignment() * 3 / 2);
a61af66fc99e Initial load
duke
parents:
diff changeset
248 }
a61af66fc99e Initial load
duke
parents:
diff changeset
249
a61af66fc99e Initial load
duke
parents:
diff changeset
250 // Expand only if the entire generation is already committed.
a61af66fc99e Initial load
duke
parents:
diff changeset
251 if (old_gen()->virtual_space()->uncommitted_size() == 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
252 if (old_gen()->free_in_bytes() < desired_free_space) {
a61af66fc99e Initial load
duke
parents:
diff changeset
253 MutexLocker x(ExpandHeap_lock);
a61af66fc99e Initial load
duke
parents:
diff changeset
254 request_old_gen_expansion(desired_free_space);
a61af66fc99e Initial load
duke
parents:
diff changeset
255 }
a61af66fc99e Initial load
duke
parents:
diff changeset
256 }
a61af66fc99e Initial load
duke
parents:
diff changeset
257 }
a61af66fc99e Initial load
duke
parents:
diff changeset
258
a61af66fc99e Initial load
duke
parents:
diff changeset
259 // See comment on adjust_boundary_for_old_gen_needss().
a61af66fc99e Initial load
duke
parents:
diff changeset
260 // Adjust boundary down only.
a61af66fc99e Initial load
duke
parents:
diff changeset
261 void AdjoiningGenerations::adjust_boundary_for_young_gen_needs(size_t eden_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
262 size_t survivor_size) {
a61af66fc99e Initial load
duke
parents:
diff changeset
263
a61af66fc99e Initial load
duke
parents:
diff changeset
264 assert(UseAdaptiveSizePolicy && UseAdaptiveGCBoundary, "runtime check");
a61af66fc99e Initial load
duke
parents:
diff changeset
265
a61af66fc99e Initial load
duke
parents:
diff changeset
266 // Stress testing.
a61af66fc99e Initial load
duke
parents:
diff changeset
267 if (PSAdaptiveSizePolicyResizeVirtualSpaceAlot == 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
268 request_young_gen_expansion(virtual_spaces()->alignment() * 3 / 2);
a61af66fc99e Initial load
duke
parents:
diff changeset
269 eden_size = young_gen()->eden_space()->capacity_in_bytes();
a61af66fc99e Initial load
duke
parents:
diff changeset
270 }
a61af66fc99e Initial load
duke
parents:
diff changeset
271
a61af66fc99e Initial load
duke
parents:
diff changeset
272 // Expand only if the entire generation is already committed.
a61af66fc99e Initial load
duke
parents:
diff changeset
273 if (young_gen()->virtual_space()->uncommitted_size() == 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
274 size_t desired_size = eden_size + 2 * survivor_size;
a61af66fc99e Initial load
duke
parents:
diff changeset
275 const size_t committed = young_gen()->virtual_space()->committed_size();
a61af66fc99e Initial load
duke
parents:
diff changeset
276 if (desired_size > committed) {
a61af66fc99e Initial load
duke
parents:
diff changeset
277 request_young_gen_expansion(desired_size - committed);
a61af66fc99e Initial load
duke
parents:
diff changeset
278 }
a61af66fc99e Initial load
duke
parents:
diff changeset
279 }
a61af66fc99e Initial load
duke
parents:
diff changeset
280 }