annotate src/share/vm/gc_implementation/parallelScavenge/psOldGen.cpp @ 1972:f95d63e2154a

6989984: Use standard include model for Hospot Summary: Replaced MakeDeps and the includeDB files with more standardized solutions. Reviewed-by: coleenp, kvn, kamg
author stefank
date Tue, 23 Nov 2010 13:22:55 -0800
parents c18cbe5936b8
children eda9eb483d29
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) 2001, 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: 579
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 579
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: 579
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/parallelScavengeHeap.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
27 #include "gc_implementation/parallelScavenge/psAdaptiveSizePolicy.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/psOldGen.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
30 #include "gc_implementation/shared/spaceDecorator.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
31 #include "memory/cardTableModRefBS.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
32 #include "memory/gcLocker.inline.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 inline const char* PSOldGen::select_name() {
a61af66fc99e Initial load
duke
parents:
diff changeset
37 return UseParallelOldGC ? "ParOldGen" : "PSOldGen";
a61af66fc99e Initial load
duke
parents:
diff changeset
38 }
a61af66fc99e Initial load
duke
parents:
diff changeset
39
a61af66fc99e Initial load
duke
parents:
diff changeset
40 PSOldGen::PSOldGen(ReservedSpace rs, size_t alignment,
a61af66fc99e Initial load
duke
parents:
diff changeset
41 size_t initial_size, size_t min_size, size_t max_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
42 const char* perf_data_name, int level):
a61af66fc99e Initial load
duke
parents:
diff changeset
43 _name(select_name()), _init_gen_size(initial_size), _min_gen_size(min_size),
a61af66fc99e Initial load
duke
parents:
diff changeset
44 _max_gen_size(max_size)
a61af66fc99e Initial load
duke
parents:
diff changeset
45 {
a61af66fc99e Initial load
duke
parents:
diff changeset
46 initialize(rs, alignment, perf_data_name, level);
a61af66fc99e Initial load
duke
parents:
diff changeset
47 }
a61af66fc99e Initial load
duke
parents:
diff changeset
48
a61af66fc99e Initial load
duke
parents:
diff changeset
49 PSOldGen::PSOldGen(size_t initial_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
50 size_t min_size, size_t max_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
51 const char* perf_data_name, int level):
a61af66fc99e Initial load
duke
parents:
diff changeset
52 _name(select_name()), _init_gen_size(initial_size), _min_gen_size(min_size),
a61af66fc99e Initial load
duke
parents:
diff changeset
53 _max_gen_size(max_size)
a61af66fc99e Initial load
duke
parents:
diff changeset
54 {}
a61af66fc99e Initial load
duke
parents:
diff changeset
55
a61af66fc99e Initial load
duke
parents:
diff changeset
56 void PSOldGen::initialize(ReservedSpace rs, size_t alignment,
a61af66fc99e Initial load
duke
parents:
diff changeset
57 const char* perf_data_name, int level) {
a61af66fc99e Initial load
duke
parents:
diff changeset
58 initialize_virtual_space(rs, alignment);
a61af66fc99e Initial load
duke
parents:
diff changeset
59 initialize_work(perf_data_name, level);
a61af66fc99e Initial load
duke
parents:
diff changeset
60 // The old gen can grow to gen_size_limit(). _reserve reflects only
a61af66fc99e Initial load
duke
parents:
diff changeset
61 // the current maximum that can be committed.
a61af66fc99e Initial load
duke
parents:
diff changeset
62 assert(_reserved.byte_size() <= gen_size_limit(), "Consistency check");
a61af66fc99e Initial load
duke
parents:
diff changeset
63 }
a61af66fc99e Initial load
duke
parents:
diff changeset
64
a61af66fc99e Initial load
duke
parents:
diff changeset
65 void PSOldGen::initialize_virtual_space(ReservedSpace rs, size_t alignment) {
a61af66fc99e Initial load
duke
parents:
diff changeset
66
a61af66fc99e Initial load
duke
parents:
diff changeset
67 _virtual_space = new PSVirtualSpace(rs, alignment);
a61af66fc99e Initial load
duke
parents:
diff changeset
68 if (!_virtual_space->expand_by(_init_gen_size)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
69 vm_exit_during_initialization("Could not reserve enough space for "
a61af66fc99e Initial load
duke
parents:
diff changeset
70 "object heap");
a61af66fc99e Initial load
duke
parents:
diff changeset
71 }
a61af66fc99e Initial load
duke
parents:
diff changeset
72 }
a61af66fc99e Initial load
duke
parents:
diff changeset
73
a61af66fc99e Initial load
duke
parents:
diff changeset
74 void PSOldGen::initialize_work(const char* perf_data_name, int level) {
a61af66fc99e Initial load
duke
parents:
diff changeset
75 //
a61af66fc99e Initial load
duke
parents:
diff changeset
76 // Basic memory initialization
a61af66fc99e Initial load
duke
parents:
diff changeset
77 //
a61af66fc99e Initial load
duke
parents:
diff changeset
78
a61af66fc99e Initial load
duke
parents:
diff changeset
79 MemRegion limit_reserved((HeapWord*)virtual_space()->low_boundary(),
a61af66fc99e Initial load
duke
parents:
diff changeset
80 heap_word_size(_max_gen_size));
a61af66fc99e Initial load
duke
parents:
diff changeset
81 assert(limit_reserved.byte_size() == _max_gen_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
82 "word vs bytes confusion");
a61af66fc99e Initial load
duke
parents:
diff changeset
83 //
a61af66fc99e Initial load
duke
parents:
diff changeset
84 // Object start stuff
a61af66fc99e Initial load
duke
parents:
diff changeset
85 //
a61af66fc99e Initial load
duke
parents:
diff changeset
86
a61af66fc99e Initial load
duke
parents:
diff changeset
87 start_array()->initialize(limit_reserved);
a61af66fc99e Initial load
duke
parents:
diff changeset
88
a61af66fc99e Initial load
duke
parents:
diff changeset
89 _reserved = MemRegion((HeapWord*)virtual_space()->low_boundary(),
a61af66fc99e Initial load
duke
parents:
diff changeset
90 (HeapWord*)virtual_space()->high_boundary());
a61af66fc99e Initial load
duke
parents:
diff changeset
91
a61af66fc99e Initial load
duke
parents:
diff changeset
92 //
a61af66fc99e Initial load
duke
parents:
diff changeset
93 // Card table stuff
a61af66fc99e Initial load
duke
parents:
diff changeset
94 //
a61af66fc99e Initial load
duke
parents:
diff changeset
95
a61af66fc99e Initial load
duke
parents:
diff changeset
96 MemRegion cmr((HeapWord*)virtual_space()->low(),
a61af66fc99e Initial load
duke
parents:
diff changeset
97 (HeapWord*)virtual_space()->high());
263
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 0
diff changeset
98 if (ZapUnusedHeapArea) {
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 0
diff changeset
99 // Mangle newly committed space immediately rather than
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 0
diff changeset
100 // waiting for the initialization of the space even though
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 0
diff changeset
101 // mangling is related to spaces. Doing it here eliminates
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 0
diff changeset
102 // the need to carry along information that a complete mangling
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 0
diff changeset
103 // (bottom to end) needs to be done.
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 0
diff changeset
104 SpaceMangler::mangle_region(cmr);
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 0
diff changeset
105 }
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 0
diff changeset
106
0
a61af66fc99e Initial load
duke
parents:
diff changeset
107 Universe::heap()->barrier_set()->resize_covered_region(cmr);
a61af66fc99e Initial load
duke
parents:
diff changeset
108
a61af66fc99e Initial load
duke
parents:
diff changeset
109 CardTableModRefBS* _ct = (CardTableModRefBS*)Universe::heap()->barrier_set();
a61af66fc99e Initial load
duke
parents:
diff changeset
110 assert (_ct->kind() == BarrierSet::CardTableModRef, "Sanity");
a61af66fc99e Initial load
duke
parents:
diff changeset
111
a61af66fc99e Initial load
duke
parents:
diff changeset
112 // Verify that the start and end of this generation is the start of a card.
a61af66fc99e Initial load
duke
parents:
diff changeset
113 // If this wasn't true, a single card could span more than one generation,
a61af66fc99e Initial load
duke
parents:
diff changeset
114 // which would cause problems when we commit/uncommit memory, and when we
a61af66fc99e Initial load
duke
parents:
diff changeset
115 // clear and dirty cards.
a61af66fc99e Initial load
duke
parents:
diff changeset
116 guarantee(_ct->is_card_aligned(_reserved.start()), "generation must be card aligned");
a61af66fc99e Initial load
duke
parents:
diff changeset
117 if (_reserved.end() != Universe::heap()->reserved_region().end()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
118 // Don't check at the very end of the heap as we'll assert that we're probing off
a61af66fc99e Initial load
duke
parents:
diff changeset
119 // the end if we try.
a61af66fc99e Initial load
duke
parents:
diff changeset
120 guarantee(_ct->is_card_aligned(_reserved.end()), "generation must be card aligned");
a61af66fc99e Initial load
duke
parents:
diff changeset
121 }
a61af66fc99e Initial load
duke
parents:
diff changeset
122
a61af66fc99e Initial load
duke
parents:
diff changeset
123 //
a61af66fc99e Initial load
duke
parents:
diff changeset
124 // ObjectSpace stuff
a61af66fc99e Initial load
duke
parents:
diff changeset
125 //
a61af66fc99e Initial load
duke
parents:
diff changeset
126
535
4e400c36026f 6783381: NUMA allocator: don't pretouch eden space with UseNUMA
iveresov
parents: 380
diff changeset
127 _object_space = new MutableSpace(virtual_space()->alignment());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
128
a61af66fc99e Initial load
duke
parents:
diff changeset
129 if (_object_space == NULL)
a61af66fc99e Initial load
duke
parents:
diff changeset
130 vm_exit_during_initialization("Could not allocate an old gen space");
a61af66fc99e Initial load
duke
parents:
diff changeset
131
263
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 0
diff changeset
132 object_space()->initialize(cmr,
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 0
diff changeset
133 SpaceDecorator::Clear,
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 0
diff changeset
134 SpaceDecorator::Mangle);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
135
a61af66fc99e Initial load
duke
parents:
diff changeset
136 _object_mark_sweep = new PSMarkSweepDecorator(_object_space, start_array(), MarkSweepDeadRatio);
a61af66fc99e Initial load
duke
parents:
diff changeset
137
a61af66fc99e Initial load
duke
parents:
diff changeset
138 if (_object_mark_sweep == NULL)
a61af66fc99e Initial load
duke
parents:
diff changeset
139 vm_exit_during_initialization("Could not complete allocation of old generation");
a61af66fc99e Initial load
duke
parents:
diff changeset
140
a61af66fc99e Initial load
duke
parents:
diff changeset
141 // Update the start_array
a61af66fc99e Initial load
duke
parents:
diff changeset
142 start_array()->set_covered_region(cmr);
a61af66fc99e Initial load
duke
parents:
diff changeset
143
a61af66fc99e Initial load
duke
parents:
diff changeset
144 // Generation Counters, generation 'level', 1 subspace
a61af66fc99e Initial load
duke
parents:
diff changeset
145 _gen_counters = new PSGenerationCounters(perf_data_name, level, 1,
a61af66fc99e Initial load
duke
parents:
diff changeset
146 virtual_space());
a61af66fc99e Initial load
duke
parents:
diff changeset
147 _space_counters = new SpaceCounters(perf_data_name, 0,
a61af66fc99e Initial load
duke
parents:
diff changeset
148 virtual_space()->reserved_size(),
a61af66fc99e Initial load
duke
parents:
diff changeset
149 _object_space, _gen_counters);
a61af66fc99e Initial load
duke
parents:
diff changeset
150 }
a61af66fc99e Initial load
duke
parents:
diff changeset
151
a61af66fc99e Initial load
duke
parents:
diff changeset
152 // Assume that the generation has been allocated if its
a61af66fc99e Initial load
duke
parents:
diff changeset
153 // reserved size is not 0.
a61af66fc99e Initial load
duke
parents:
diff changeset
154 bool PSOldGen::is_allocated() {
a61af66fc99e Initial load
duke
parents:
diff changeset
155 return virtual_space()->reserved_size() != 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
156 }
a61af66fc99e Initial load
duke
parents:
diff changeset
157
a61af66fc99e Initial load
duke
parents:
diff changeset
158 void PSOldGen::precompact() {
a61af66fc99e Initial load
duke
parents:
diff changeset
159 ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap();
a61af66fc99e Initial load
duke
parents:
diff changeset
160 assert(heap->kind() == CollectedHeap::ParallelScavengeHeap, "Sanity");
a61af66fc99e Initial load
duke
parents:
diff changeset
161
a61af66fc99e Initial load
duke
parents:
diff changeset
162 // Reset start array first.
a61af66fc99e Initial load
duke
parents:
diff changeset
163 start_array()->reset();
a61af66fc99e Initial load
duke
parents:
diff changeset
164
a61af66fc99e Initial load
duke
parents:
diff changeset
165 object_mark_sweep()->precompact();
a61af66fc99e Initial load
duke
parents:
diff changeset
166
a61af66fc99e Initial load
duke
parents:
diff changeset
167 // Now compact the young gen
a61af66fc99e Initial load
duke
parents:
diff changeset
168 heap->young_gen()->precompact();
a61af66fc99e Initial load
duke
parents:
diff changeset
169 }
a61af66fc99e Initial load
duke
parents:
diff changeset
170
a61af66fc99e Initial load
duke
parents:
diff changeset
171 void PSOldGen::adjust_pointers() {
a61af66fc99e Initial load
duke
parents:
diff changeset
172 object_mark_sweep()->adjust_pointers();
a61af66fc99e Initial load
duke
parents:
diff changeset
173 }
a61af66fc99e Initial load
duke
parents:
diff changeset
174
a61af66fc99e Initial load
duke
parents:
diff changeset
175 void PSOldGen::compact() {
a61af66fc99e Initial load
duke
parents:
diff changeset
176 object_mark_sweep()->compact(ZapUnusedHeapArea);
a61af66fc99e Initial load
duke
parents:
diff changeset
177 }
a61af66fc99e Initial load
duke
parents:
diff changeset
178
a61af66fc99e Initial load
duke
parents:
diff changeset
179 void PSOldGen::move_and_update(ParCompactionManager* cm) {
a61af66fc99e Initial load
duke
parents:
diff changeset
180 PSParallelCompact::move_and_update(cm, PSParallelCompact::old_space_id);
a61af66fc99e Initial load
duke
parents:
diff changeset
181 }
a61af66fc99e Initial load
duke
parents:
diff changeset
182
a61af66fc99e Initial load
duke
parents:
diff changeset
183 size_t PSOldGen::contiguous_available() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
184 return object_space()->free_in_bytes() + virtual_space()->uncommitted_size();
a61af66fc99e Initial load
duke
parents:
diff changeset
185 }
a61af66fc99e Initial load
duke
parents:
diff changeset
186
a61af66fc99e Initial load
duke
parents:
diff changeset
187 // Allocation. We report all successful allocations to the size policy
a61af66fc99e Initial load
duke
parents:
diff changeset
188 // Note that the perm gen does not use this method, and should not!
a61af66fc99e Initial load
duke
parents:
diff changeset
189 HeapWord* PSOldGen::allocate(size_t word_size, bool is_tlab) {
a61af66fc99e Initial load
duke
parents:
diff changeset
190 assert_locked_or_safepoint(Heap_lock);
a61af66fc99e Initial load
duke
parents:
diff changeset
191 HeapWord* res = allocate_noexpand(word_size, is_tlab);
a61af66fc99e Initial load
duke
parents:
diff changeset
192
a61af66fc99e Initial load
duke
parents:
diff changeset
193 if (res == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
194 res = expand_and_allocate(word_size, is_tlab);
a61af66fc99e Initial load
duke
parents:
diff changeset
195 }
a61af66fc99e Initial load
duke
parents:
diff changeset
196
a61af66fc99e Initial load
duke
parents:
diff changeset
197 // Allocations in the old generation need to be reported
a61af66fc99e Initial load
duke
parents:
diff changeset
198 if (res != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
199 ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap();
a61af66fc99e Initial load
duke
parents:
diff changeset
200 heap->size_policy()->tenured_allocation(word_size);
a61af66fc99e Initial load
duke
parents:
diff changeset
201 }
a61af66fc99e Initial load
duke
parents:
diff changeset
202
a61af66fc99e Initial load
duke
parents:
diff changeset
203 return res;
a61af66fc99e Initial load
duke
parents:
diff changeset
204 }
a61af66fc99e Initial load
duke
parents:
diff changeset
205
a61af66fc99e Initial load
duke
parents:
diff changeset
206 HeapWord* PSOldGen::expand_and_allocate(size_t word_size, bool is_tlab) {
a61af66fc99e Initial load
duke
parents:
diff changeset
207 assert(!is_tlab, "TLAB's are not supported in PSOldGen");
a61af66fc99e Initial load
duke
parents:
diff changeset
208 expand(word_size*HeapWordSize);
a61af66fc99e Initial load
duke
parents:
diff changeset
209 if (GCExpandToAllocateDelayMillis > 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
210 os::sleep(Thread::current(), GCExpandToAllocateDelayMillis, false);
a61af66fc99e Initial load
duke
parents:
diff changeset
211 }
a61af66fc99e Initial load
duke
parents:
diff changeset
212 return allocate_noexpand(word_size, is_tlab);
a61af66fc99e Initial load
duke
parents:
diff changeset
213 }
a61af66fc99e Initial load
duke
parents:
diff changeset
214
a61af66fc99e Initial load
duke
parents:
diff changeset
215 HeapWord* PSOldGen::expand_and_cas_allocate(size_t word_size) {
a61af66fc99e Initial load
duke
parents:
diff changeset
216 expand(word_size*HeapWordSize);
a61af66fc99e Initial load
duke
parents:
diff changeset
217 if (GCExpandToAllocateDelayMillis > 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
218 os::sleep(Thread::current(), GCExpandToAllocateDelayMillis, false);
a61af66fc99e Initial load
duke
parents:
diff changeset
219 }
a61af66fc99e Initial load
duke
parents:
diff changeset
220 return cas_allocate_noexpand(word_size);
a61af66fc99e Initial load
duke
parents:
diff changeset
221 }
a61af66fc99e Initial load
duke
parents:
diff changeset
222
a61af66fc99e Initial load
duke
parents:
diff changeset
223 void PSOldGen::expand(size_t bytes) {
271
818a18cd69a8 6730514: assertion failure in mangling code when expanding by 0 bytes
jmasa
parents: 263
diff changeset
224 if (bytes == 0) {
818a18cd69a8 6730514: assertion failure in mangling code when expanding by 0 bytes
jmasa
parents: 263
diff changeset
225 return;
818a18cd69a8 6730514: assertion failure in mangling code when expanding by 0 bytes
jmasa
parents: 263
diff changeset
226 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
227 MutexLocker x(ExpandHeap_lock);
a61af66fc99e Initial load
duke
parents:
diff changeset
228 const size_t alignment = virtual_space()->alignment();
a61af66fc99e Initial load
duke
parents:
diff changeset
229 size_t aligned_bytes = align_size_up(bytes, alignment);
a61af66fc99e Initial load
duke
parents:
diff changeset
230 size_t aligned_expand_bytes = align_size_up(MinHeapDeltaBytes, alignment);
271
818a18cd69a8 6730514: assertion failure in mangling code when expanding by 0 bytes
jmasa
parents: 263
diff changeset
231 if (aligned_bytes == 0){
818a18cd69a8 6730514: assertion failure in mangling code when expanding by 0 bytes
jmasa
parents: 263
diff changeset
232 // The alignment caused the number of bytes to wrap. An expand_by(0) will
818a18cd69a8 6730514: assertion failure in mangling code when expanding by 0 bytes
jmasa
parents: 263
diff changeset
233 // return true with the implication that and expansion was done when it
818a18cd69a8 6730514: assertion failure in mangling code when expanding by 0 bytes
jmasa
parents: 263
diff changeset
234 // was not. A call to expand implies a best effort to expand by "bytes"
818a18cd69a8 6730514: assertion failure in mangling code when expanding by 0 bytes
jmasa
parents: 263
diff changeset
235 // but not a guarantee. Align down to give a best effort. This is likely
818a18cd69a8 6730514: assertion failure in mangling code when expanding by 0 bytes
jmasa
parents: 263
diff changeset
236 // the most that the generation can expand since it has some capacity to
818a18cd69a8 6730514: assertion failure in mangling code when expanding by 0 bytes
jmasa
parents: 263
diff changeset
237 // start with.
818a18cd69a8 6730514: assertion failure in mangling code when expanding by 0 bytes
jmasa
parents: 263
diff changeset
238 aligned_bytes = align_size_down(bytes, alignment);
818a18cd69a8 6730514: assertion failure in mangling code when expanding by 0 bytes
jmasa
parents: 263
diff changeset
239 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
240
a61af66fc99e Initial load
duke
parents:
diff changeset
241 bool success = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
242 if (aligned_expand_bytes > aligned_bytes) {
a61af66fc99e Initial load
duke
parents:
diff changeset
243 success = expand_by(aligned_expand_bytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
244 }
a61af66fc99e Initial load
duke
parents:
diff changeset
245 if (!success) {
a61af66fc99e Initial load
duke
parents:
diff changeset
246 success = expand_by(aligned_bytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
247 }
a61af66fc99e Initial load
duke
parents:
diff changeset
248 if (!success) {
a61af66fc99e Initial load
duke
parents:
diff changeset
249 success = expand_to_reserved();
a61af66fc99e Initial load
duke
parents:
diff changeset
250 }
a61af66fc99e Initial load
duke
parents:
diff changeset
251
271
818a18cd69a8 6730514: assertion failure in mangling code when expanding by 0 bytes
jmasa
parents: 263
diff changeset
252 if (PrintGC && Verbose) {
818a18cd69a8 6730514: assertion failure in mangling code when expanding by 0 bytes
jmasa
parents: 263
diff changeset
253 if (success && GC_locker::is_active()) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
254 gclog_or_tty->print_cr("Garbage collection disabled, expanded heap instead");
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 bool PSOldGen::expand_by(size_t bytes) {
a61af66fc99e Initial load
duke
parents:
diff changeset
260 assert_lock_strong(ExpandHeap_lock);
a61af66fc99e Initial load
duke
parents:
diff changeset
261 assert_locked_or_safepoint(Heap_lock);
271
818a18cd69a8 6730514: assertion failure in mangling code when expanding by 0 bytes
jmasa
parents: 263
diff changeset
262 if (bytes == 0) {
818a18cd69a8 6730514: assertion failure in mangling code when expanding by 0 bytes
jmasa
parents: 263
diff changeset
263 return true; // That's what virtual_space()->expand_by(0) would return
818a18cd69a8 6730514: assertion failure in mangling code when expanding by 0 bytes
jmasa
parents: 263
diff changeset
264 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
265 bool result = virtual_space()->expand_by(bytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
266 if (result) {
263
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 0
diff changeset
267 if (ZapUnusedHeapArea) {
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 0
diff changeset
268 // We need to mangle the newly expanded area. The memregion spans
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 0
diff changeset
269 // end -> new_end, we assume that top -> end is already mangled.
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 0
diff changeset
270 // Do the mangling before post_resize() is called because
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 0
diff changeset
271 // the space is available for allocation after post_resize();
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 0
diff changeset
272 HeapWord* const virtual_space_high = (HeapWord*) virtual_space()->high();
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 0
diff changeset
273 assert(object_space()->end() < virtual_space_high,
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 0
diff changeset
274 "Should be true before post_resize()");
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 0
diff changeset
275 MemRegion mangle_region(object_space()->end(), virtual_space_high);
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 0
diff changeset
276 // Note that the object space has not yet been updated to
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 0
diff changeset
277 // coincede with the new underlying virtual space.
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 0
diff changeset
278 SpaceMangler::mangle_region(mangle_region);
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 0
diff changeset
279 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
280 post_resize();
a61af66fc99e Initial load
duke
parents:
diff changeset
281 if (UsePerfData) {
a61af66fc99e Initial load
duke
parents:
diff changeset
282 _space_counters->update_capacity();
a61af66fc99e Initial load
duke
parents:
diff changeset
283 _gen_counters->update_all();
a61af66fc99e Initial load
duke
parents:
diff changeset
284 }
a61af66fc99e Initial load
duke
parents:
diff changeset
285 }
a61af66fc99e Initial load
duke
parents:
diff changeset
286
a61af66fc99e Initial load
duke
parents:
diff changeset
287 if (result && Verbose && PrintGC) {
a61af66fc99e Initial load
duke
parents:
diff changeset
288 size_t new_mem_size = virtual_space()->committed_size();
a61af66fc99e Initial load
duke
parents:
diff changeset
289 size_t old_mem_size = new_mem_size - bytes;
a61af66fc99e Initial load
duke
parents:
diff changeset
290 gclog_or_tty->print_cr("Expanding %s from " SIZE_FORMAT "K by "
a61af66fc99e Initial load
duke
parents:
diff changeset
291 SIZE_FORMAT "K to "
a61af66fc99e Initial load
duke
parents:
diff changeset
292 SIZE_FORMAT "K",
a61af66fc99e Initial load
duke
parents:
diff changeset
293 name(), old_mem_size/K, bytes/K, new_mem_size/K);
a61af66fc99e Initial load
duke
parents:
diff changeset
294 }
a61af66fc99e Initial load
duke
parents:
diff changeset
295
a61af66fc99e Initial load
duke
parents:
diff changeset
296 return result;
a61af66fc99e Initial load
duke
parents:
diff changeset
297 }
a61af66fc99e Initial load
duke
parents:
diff changeset
298
a61af66fc99e Initial load
duke
parents:
diff changeset
299 bool PSOldGen::expand_to_reserved() {
a61af66fc99e Initial load
duke
parents:
diff changeset
300 assert_lock_strong(ExpandHeap_lock);
a61af66fc99e Initial load
duke
parents:
diff changeset
301 assert_locked_or_safepoint(Heap_lock);
a61af66fc99e Initial load
duke
parents:
diff changeset
302
a61af66fc99e Initial load
duke
parents:
diff changeset
303 bool result = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
304 const size_t remaining_bytes = virtual_space()->uncommitted_size();
a61af66fc99e Initial load
duke
parents:
diff changeset
305 if (remaining_bytes > 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
306 result = expand_by(remaining_bytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
307 DEBUG_ONLY(if (!result) warning("grow to reserve failed"));
a61af66fc99e Initial load
duke
parents:
diff changeset
308 }
a61af66fc99e Initial load
duke
parents:
diff changeset
309 return result;
a61af66fc99e Initial load
duke
parents:
diff changeset
310 }
a61af66fc99e Initial load
duke
parents:
diff changeset
311
a61af66fc99e Initial load
duke
parents:
diff changeset
312 void PSOldGen::shrink(size_t bytes) {
a61af66fc99e Initial load
duke
parents:
diff changeset
313 assert_lock_strong(ExpandHeap_lock);
a61af66fc99e Initial load
duke
parents:
diff changeset
314 assert_locked_or_safepoint(Heap_lock);
a61af66fc99e Initial load
duke
parents:
diff changeset
315
a61af66fc99e Initial load
duke
parents:
diff changeset
316 size_t size = align_size_down(bytes, virtual_space()->alignment());
a61af66fc99e Initial load
duke
parents:
diff changeset
317 if (size > 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
318 assert_lock_strong(ExpandHeap_lock);
a61af66fc99e Initial load
duke
parents:
diff changeset
319 virtual_space()->shrink_by(bytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
320 post_resize();
a61af66fc99e Initial load
duke
parents:
diff changeset
321
a61af66fc99e Initial load
duke
parents:
diff changeset
322 if (Verbose && PrintGC) {
a61af66fc99e Initial load
duke
parents:
diff changeset
323 size_t new_mem_size = virtual_space()->committed_size();
a61af66fc99e Initial load
duke
parents:
diff changeset
324 size_t old_mem_size = new_mem_size + bytes;
a61af66fc99e Initial load
duke
parents:
diff changeset
325 gclog_or_tty->print_cr("Shrinking %s from " SIZE_FORMAT "K by "
a61af66fc99e Initial load
duke
parents:
diff changeset
326 SIZE_FORMAT "K to "
a61af66fc99e Initial load
duke
parents:
diff changeset
327 SIZE_FORMAT "K",
a61af66fc99e Initial load
duke
parents:
diff changeset
328 name(), old_mem_size/K, bytes/K, new_mem_size/K);
a61af66fc99e Initial load
duke
parents:
diff changeset
329 }
a61af66fc99e Initial load
duke
parents:
diff changeset
330 }
a61af66fc99e Initial load
duke
parents:
diff changeset
331 }
a61af66fc99e Initial load
duke
parents:
diff changeset
332
a61af66fc99e Initial load
duke
parents:
diff changeset
333 void PSOldGen::resize(size_t desired_free_space) {
a61af66fc99e Initial load
duke
parents:
diff changeset
334 const size_t alignment = virtual_space()->alignment();
a61af66fc99e Initial load
duke
parents:
diff changeset
335 const size_t size_before = virtual_space()->committed_size();
a61af66fc99e Initial load
duke
parents:
diff changeset
336 size_t new_size = used_in_bytes() + desired_free_space;
a61af66fc99e Initial load
duke
parents:
diff changeset
337 if (new_size < used_in_bytes()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
338 // Overflowed the addition.
a61af66fc99e Initial load
duke
parents:
diff changeset
339 new_size = gen_size_limit();
a61af66fc99e Initial load
duke
parents:
diff changeset
340 }
a61af66fc99e Initial load
duke
parents:
diff changeset
341 // Adjust according to our min and max
a61af66fc99e Initial load
duke
parents:
diff changeset
342 new_size = MAX2(MIN2(new_size, gen_size_limit()), min_gen_size());
a61af66fc99e Initial load
duke
parents:
diff changeset
343
a61af66fc99e Initial load
duke
parents:
diff changeset
344 assert(gen_size_limit() >= reserved().byte_size(), "max new size problem?");
a61af66fc99e Initial load
duke
parents:
diff changeset
345 new_size = align_size_up(new_size, alignment);
a61af66fc99e Initial load
duke
parents:
diff changeset
346
a61af66fc99e Initial load
duke
parents:
diff changeset
347 const size_t current_size = capacity_in_bytes();
a61af66fc99e Initial load
duke
parents:
diff changeset
348
a61af66fc99e Initial load
duke
parents:
diff changeset
349 if (PrintAdaptiveSizePolicy && Verbose) {
a61af66fc99e Initial load
duke
parents:
diff changeset
350 gclog_or_tty->print_cr("AdaptiveSizePolicy::old generation size: "
a61af66fc99e Initial load
duke
parents:
diff changeset
351 "desired free: " SIZE_FORMAT " used: " SIZE_FORMAT
a61af66fc99e Initial load
duke
parents:
diff changeset
352 " new size: " SIZE_FORMAT " current size " SIZE_FORMAT
a61af66fc99e Initial load
duke
parents:
diff changeset
353 " gen limits: " SIZE_FORMAT " / " SIZE_FORMAT,
a61af66fc99e Initial load
duke
parents:
diff changeset
354 desired_free_space, used_in_bytes(), new_size, current_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
355 gen_size_limit(), min_gen_size());
a61af66fc99e Initial load
duke
parents:
diff changeset
356 }
a61af66fc99e Initial load
duke
parents:
diff changeset
357
a61af66fc99e Initial load
duke
parents:
diff changeset
358 if (new_size == current_size) {
a61af66fc99e Initial load
duke
parents:
diff changeset
359 // No change requested
a61af66fc99e Initial load
duke
parents:
diff changeset
360 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
361 }
a61af66fc99e Initial load
duke
parents:
diff changeset
362 if (new_size > current_size) {
a61af66fc99e Initial load
duke
parents:
diff changeset
363 size_t change_bytes = new_size - current_size;
a61af66fc99e Initial load
duke
parents:
diff changeset
364 expand(change_bytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
365 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
366 size_t change_bytes = current_size - new_size;
a61af66fc99e Initial load
duke
parents:
diff changeset
367 // shrink doesn't grab this lock, expand does. Is that right?
a61af66fc99e Initial load
duke
parents:
diff changeset
368 MutexLocker x(ExpandHeap_lock);
a61af66fc99e Initial load
duke
parents:
diff changeset
369 shrink(change_bytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
370 }
a61af66fc99e Initial load
duke
parents:
diff changeset
371
a61af66fc99e Initial load
duke
parents:
diff changeset
372 if (PrintAdaptiveSizePolicy) {
a61af66fc99e Initial load
duke
parents:
diff changeset
373 ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap();
a61af66fc99e Initial load
duke
parents:
diff changeset
374 assert(heap->kind() == CollectedHeap::ParallelScavengeHeap, "Sanity");
a61af66fc99e Initial load
duke
parents:
diff changeset
375 gclog_or_tty->print_cr("AdaptiveSizePolicy::old generation size: "
a61af66fc99e Initial load
duke
parents:
diff changeset
376 "collection: %d "
a61af66fc99e Initial load
duke
parents:
diff changeset
377 "(" SIZE_FORMAT ") -> (" SIZE_FORMAT ") ",
a61af66fc99e Initial load
duke
parents:
diff changeset
378 heap->total_collections(),
a61af66fc99e Initial load
duke
parents:
diff changeset
379 size_before, virtual_space()->committed_size());
a61af66fc99e Initial load
duke
parents:
diff changeset
380 }
a61af66fc99e Initial load
duke
parents:
diff changeset
381 }
a61af66fc99e Initial load
duke
parents:
diff changeset
382
a61af66fc99e Initial load
duke
parents:
diff changeset
383 // NOTE! We need to be careful about resizing. During a GC, multiple
a61af66fc99e Initial load
duke
parents:
diff changeset
384 // allocators may be active during heap expansion. If we allow the
a61af66fc99e Initial load
duke
parents:
diff changeset
385 // heap resizing to become visible before we have correctly resized
a61af66fc99e Initial load
duke
parents:
diff changeset
386 // all heap related data structures, we may cause program failures.
a61af66fc99e Initial load
duke
parents:
diff changeset
387 void PSOldGen::post_resize() {
a61af66fc99e Initial load
duke
parents:
diff changeset
388 // First construct a memregion representing the new size
a61af66fc99e Initial load
duke
parents:
diff changeset
389 MemRegion new_memregion((HeapWord*)virtual_space()->low(),
a61af66fc99e Initial load
duke
parents:
diff changeset
390 (HeapWord*)virtual_space()->high());
a61af66fc99e Initial load
duke
parents:
diff changeset
391 size_t new_word_size = new_memregion.word_size();
a61af66fc99e Initial load
duke
parents:
diff changeset
392
a61af66fc99e Initial load
duke
parents:
diff changeset
393 start_array()->set_covered_region(new_memregion);
a61af66fc99e Initial load
duke
parents:
diff changeset
394 Universe::heap()->barrier_set()->resize_covered_region(new_memregion);
a61af66fc99e Initial load
duke
parents:
diff changeset
395
a61af66fc99e Initial load
duke
parents:
diff changeset
396 // ALWAYS do this last!!
535
4e400c36026f 6783381: NUMA allocator: don't pretouch eden space with UseNUMA
iveresov
parents: 380
diff changeset
397 object_space()->initialize(new_memregion,
4e400c36026f 6783381: NUMA allocator: don't pretouch eden space with UseNUMA
iveresov
parents: 380
diff changeset
398 SpaceDecorator::DontClear,
4e400c36026f 6783381: NUMA allocator: don't pretouch eden space with UseNUMA
iveresov
parents: 380
diff changeset
399 SpaceDecorator::DontMangle);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
400
a61af66fc99e Initial load
duke
parents:
diff changeset
401 assert(new_word_size == heap_word_size(object_space()->capacity_in_bytes()),
a61af66fc99e Initial load
duke
parents:
diff changeset
402 "Sanity");
a61af66fc99e Initial load
duke
parents:
diff changeset
403 }
a61af66fc99e Initial load
duke
parents:
diff changeset
404
a61af66fc99e Initial load
duke
parents:
diff changeset
405 size_t PSOldGen::gen_size_limit() {
a61af66fc99e Initial load
duke
parents:
diff changeset
406 return _max_gen_size;
a61af66fc99e Initial load
duke
parents:
diff changeset
407 }
a61af66fc99e Initial load
duke
parents:
diff changeset
408
a61af66fc99e Initial load
duke
parents:
diff changeset
409 void PSOldGen::reset_after_change() {
a61af66fc99e Initial load
duke
parents:
diff changeset
410 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
411 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
412 }
a61af66fc99e Initial load
duke
parents:
diff changeset
413
a61af66fc99e Initial load
duke
parents:
diff changeset
414 size_t PSOldGen::available_for_expansion() {
a61af66fc99e Initial load
duke
parents:
diff changeset
415 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
416 return 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
417 }
a61af66fc99e Initial load
duke
parents:
diff changeset
418
a61af66fc99e Initial load
duke
parents:
diff changeset
419 size_t PSOldGen::available_for_contraction() {
a61af66fc99e Initial load
duke
parents:
diff changeset
420 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
421 return 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
422 }
a61af66fc99e Initial load
duke
parents:
diff changeset
423
a61af66fc99e Initial load
duke
parents:
diff changeset
424 void PSOldGen::print() const { print_on(tty);}
a61af66fc99e Initial load
duke
parents:
diff changeset
425 void PSOldGen::print_on(outputStream* st) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
426 st->print(" %-15s", name());
a61af66fc99e Initial load
duke
parents:
diff changeset
427 if (PrintGCDetails && Verbose) {
a61af66fc99e Initial load
duke
parents:
diff changeset
428 st->print(" total " SIZE_FORMAT ", used " SIZE_FORMAT,
a61af66fc99e Initial load
duke
parents:
diff changeset
429 capacity_in_bytes(), used_in_bytes());
a61af66fc99e Initial load
duke
parents:
diff changeset
430 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
431 st->print(" total " SIZE_FORMAT "K, used " SIZE_FORMAT "K",
a61af66fc99e Initial load
duke
parents:
diff changeset
432 capacity_in_bytes()/K, used_in_bytes()/K);
a61af66fc99e Initial load
duke
parents:
diff changeset
433 }
a61af66fc99e Initial load
duke
parents:
diff changeset
434 st->print_cr(" [" INTPTR_FORMAT ", " INTPTR_FORMAT ", " INTPTR_FORMAT ")",
a61af66fc99e Initial load
duke
parents:
diff changeset
435 virtual_space()->low_boundary(),
a61af66fc99e Initial load
duke
parents:
diff changeset
436 virtual_space()->high(),
a61af66fc99e Initial load
duke
parents:
diff changeset
437 virtual_space()->high_boundary());
a61af66fc99e Initial load
duke
parents:
diff changeset
438
a61af66fc99e Initial load
duke
parents:
diff changeset
439 st->print(" object"); object_space()->print_on(st);
a61af66fc99e Initial load
duke
parents:
diff changeset
440 }
a61af66fc99e Initial load
duke
parents:
diff changeset
441
a61af66fc99e Initial load
duke
parents:
diff changeset
442 void PSOldGen::print_used_change(size_t prev_used) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
443 gclog_or_tty->print(" [%s:", name());
a61af66fc99e Initial load
duke
parents:
diff changeset
444 gclog_or_tty->print(" " SIZE_FORMAT "K"
a61af66fc99e Initial load
duke
parents:
diff changeset
445 "->" SIZE_FORMAT "K"
a61af66fc99e Initial load
duke
parents:
diff changeset
446 "(" SIZE_FORMAT "K)",
a61af66fc99e Initial load
duke
parents:
diff changeset
447 prev_used / K, used_in_bytes() / K,
a61af66fc99e Initial load
duke
parents:
diff changeset
448 capacity_in_bytes() / K);
a61af66fc99e Initial load
duke
parents:
diff changeset
449 gclog_or_tty->print("]");
a61af66fc99e Initial load
duke
parents:
diff changeset
450 }
a61af66fc99e Initial load
duke
parents:
diff changeset
451
a61af66fc99e Initial load
duke
parents:
diff changeset
452 void PSOldGen::update_counters() {
a61af66fc99e Initial load
duke
parents:
diff changeset
453 if (UsePerfData) {
a61af66fc99e Initial load
duke
parents:
diff changeset
454 _space_counters->update_all();
a61af66fc99e Initial load
duke
parents:
diff changeset
455 _gen_counters->update_all();
a61af66fc99e Initial load
duke
parents:
diff changeset
456 }
a61af66fc99e Initial load
duke
parents:
diff changeset
457 }
a61af66fc99e Initial load
duke
parents:
diff changeset
458
a61af66fc99e Initial load
duke
parents:
diff changeset
459 #ifndef PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
460
a61af66fc99e Initial load
duke
parents:
diff changeset
461 void PSOldGen::space_invariants() {
a61af66fc99e Initial load
duke
parents:
diff changeset
462 assert(object_space()->end() == (HeapWord*) virtual_space()->high(),
a61af66fc99e Initial load
duke
parents:
diff changeset
463 "Space invariant");
a61af66fc99e Initial load
duke
parents:
diff changeset
464 assert(object_space()->bottom() == (HeapWord*) virtual_space()->low(),
a61af66fc99e Initial load
duke
parents:
diff changeset
465 "Space invariant");
a61af66fc99e Initial load
duke
parents:
diff changeset
466 assert(virtual_space()->low_boundary() <= virtual_space()->low(),
a61af66fc99e Initial load
duke
parents:
diff changeset
467 "Space invariant");
a61af66fc99e Initial load
duke
parents:
diff changeset
468 assert(virtual_space()->high_boundary() >= virtual_space()->high(),
a61af66fc99e Initial load
duke
parents:
diff changeset
469 "Space invariant");
a61af66fc99e Initial load
duke
parents:
diff changeset
470 assert(virtual_space()->low_boundary() == (char*) _reserved.start(),
a61af66fc99e Initial load
duke
parents:
diff changeset
471 "Space invariant");
a61af66fc99e Initial load
duke
parents:
diff changeset
472 assert(virtual_space()->high_boundary() == (char*) _reserved.end(),
a61af66fc99e Initial load
duke
parents:
diff changeset
473 "Space invariant");
a61af66fc99e Initial load
duke
parents:
diff changeset
474 assert(virtual_space()->committed_size() <= virtual_space()->reserved_size(),
a61af66fc99e Initial load
duke
parents:
diff changeset
475 "Space invariant");
a61af66fc99e Initial load
duke
parents:
diff changeset
476 }
a61af66fc99e Initial load
duke
parents:
diff changeset
477 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
478
a61af66fc99e Initial load
duke
parents:
diff changeset
479 void PSOldGen::verify(bool allow_dirty) {
a61af66fc99e Initial load
duke
parents:
diff changeset
480 object_space()->verify(allow_dirty);
a61af66fc99e Initial load
duke
parents:
diff changeset
481 }
a61af66fc99e Initial load
duke
parents:
diff changeset
482 class VerifyObjectStartArrayClosure : public ObjectClosure {
a61af66fc99e Initial load
duke
parents:
diff changeset
483 PSOldGen* _gen;
a61af66fc99e Initial load
duke
parents:
diff changeset
484 ObjectStartArray* _start_array;
a61af66fc99e Initial load
duke
parents:
diff changeset
485
a61af66fc99e Initial load
duke
parents:
diff changeset
486 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
487 VerifyObjectStartArrayClosure(PSOldGen* gen, ObjectStartArray* start_array) :
a61af66fc99e Initial load
duke
parents:
diff changeset
488 _gen(gen), _start_array(start_array) { }
a61af66fc99e Initial load
duke
parents:
diff changeset
489
a61af66fc99e Initial load
duke
parents:
diff changeset
490 virtual void do_object(oop obj) {
a61af66fc99e Initial load
duke
parents:
diff changeset
491 HeapWord* test_addr = (HeapWord*)obj + 1;
a61af66fc99e Initial load
duke
parents:
diff changeset
492 guarantee(_start_array->object_start(test_addr) == (HeapWord*)obj, "ObjectStartArray cannot find start of object");
a61af66fc99e Initial load
duke
parents:
diff changeset
493 guarantee(_start_array->is_block_allocated((HeapWord*)obj), "ObjectStartArray missing block allocation");
a61af66fc99e Initial load
duke
parents:
diff changeset
494 }
a61af66fc99e Initial load
duke
parents:
diff changeset
495 };
a61af66fc99e Initial load
duke
parents:
diff changeset
496
a61af66fc99e Initial load
duke
parents:
diff changeset
497 void PSOldGen::verify_object_start_array() {
a61af66fc99e Initial load
duke
parents:
diff changeset
498 VerifyObjectStartArrayClosure check( this, &_start_array );
a61af66fc99e Initial load
duke
parents:
diff changeset
499 object_iterate(&check);
a61af66fc99e Initial load
duke
parents:
diff changeset
500 }
263
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 0
diff changeset
501
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 0
diff changeset
502 #ifndef PRODUCT
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 0
diff changeset
503 void PSOldGen::record_spaces_top() {
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 0
diff changeset
504 assert(ZapUnusedHeapArea, "Not mangling unused space");
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 0
diff changeset
505 object_space()->set_top_for_allocations();
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 0
diff changeset
506 }
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 0
diff changeset
507 #endif