annotate src/share/vm/memory/generation.cpp @ 17937:78bbf4d43a14

8037816: Fix for 8036122 breaks build with Xcode5/clang 8043029: Change 8037816 breaks HS build with older GCC versions which don't support diagnostic pragmas 8043164: Format warning in traceStream.hpp Summary: Backport of main fix + two corrections, enables clang compilation, turns on format attributes, corrects/mutes warnings Reviewed-by: kvn, coleenp, iveresov, twisti
author drchase
date Thu, 22 May 2014 15:52:41 -0400
parents 86e6d691f2e1
children 30c99d8e0f02
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
17937
78bbf4d43a14 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 13400
diff changeset
2 * Copyright (c) 1997, 2014, 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: 1051
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1051
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: 1051
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: 1888
diff changeset
25 #include "precompiled.hpp"
10405
f2110083203d 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 9072
diff changeset
26 #include "gc_implementation/shared/gcTimer.hpp"
f2110083203d 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 9072
diff changeset
27 #include "gc_implementation/shared/gcTrace.hpp"
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1888
diff changeset
28 #include "gc_implementation/shared/spaceDecorator.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1888
diff changeset
29 #include "gc_interface/collectedHeap.inline.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1888
diff changeset
30 #include "memory/allocation.inline.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1888
diff changeset
31 #include "memory/blockOffsetTable.inline.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1888
diff changeset
32 #include "memory/cardTableRS.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1888
diff changeset
33 #include "memory/gcLocker.inline.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1888
diff changeset
34 #include "memory/genCollectedHeap.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1888
diff changeset
35 #include "memory/genMarkSweep.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1888
diff changeset
36 #include "memory/genOopClosures.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1888
diff changeset
37 #include "memory/genOopClosures.inline.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1888
diff changeset
38 #include "memory/generation.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1888
diff changeset
39 #include "memory/generation.inline.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1888
diff changeset
40 #include "memory/space.inline.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1888
diff changeset
41 #include "oops/oop.inline.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1888
diff changeset
42 #include "runtime/java.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1888
diff changeset
43 #include "utilities/copy.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1888
diff changeset
44 #include "utilities/events.hpp"
0
a61af66fc99e Initial load
duke
parents:
diff changeset
45
17937
78bbf4d43a14 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 13400
diff changeset
46 PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
78bbf4d43a14 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 13400
diff changeset
47
0
a61af66fc99e Initial load
duke
parents:
diff changeset
48 Generation::Generation(ReservedSpace rs, size_t initial_size, int level) :
a61af66fc99e Initial load
duke
parents:
diff changeset
49 _level(level),
a61af66fc99e Initial load
duke
parents:
diff changeset
50 _ref_processor(NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
51 if (!_virtual_space.initialize(rs, initial_size)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
52 vm_exit_during_initialization("Could not reserve enough space for "
a61af66fc99e Initial load
duke
parents:
diff changeset
53 "object heap");
a61af66fc99e Initial load
duke
parents:
diff changeset
54 }
263
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 113
diff changeset
55 // Mangle all of the the initial generation.
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 113
diff changeset
56 if (ZapUnusedHeapArea) {
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 113
diff changeset
57 MemRegion mangle_region((HeapWord*)_virtual_space.low(),
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 113
diff changeset
58 (HeapWord*)_virtual_space.high());
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 113
diff changeset
59 SpaceMangler::mangle_region(mangle_region);
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 113
diff changeset
60 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
61 _reserved = MemRegion((HeapWord*)_virtual_space.low_boundary(),
a61af66fc99e Initial load
duke
parents:
diff changeset
62 (HeapWord*)_virtual_space.high_boundary());
a61af66fc99e Initial load
duke
parents:
diff changeset
63 }
a61af66fc99e Initial load
duke
parents:
diff changeset
64
a61af66fc99e Initial load
duke
parents:
diff changeset
65 GenerationSpec* Generation::spec() {
a61af66fc99e Initial load
duke
parents:
diff changeset
66 GenCollectedHeap* gch = GenCollectedHeap::heap();
a61af66fc99e Initial load
duke
parents:
diff changeset
67 assert(0 <= level() && level() < gch->_n_gens, "Bad gen level");
a61af66fc99e Initial load
duke
parents:
diff changeset
68 return gch->_gen_specs[level()];
a61af66fc99e Initial load
duke
parents:
diff changeset
69 }
a61af66fc99e Initial load
duke
parents:
diff changeset
70
a61af66fc99e Initial load
duke
parents:
diff changeset
71 size_t Generation::max_capacity() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
72 return reserved().byte_size();
a61af66fc99e Initial load
duke
parents:
diff changeset
73 }
a61af66fc99e Initial load
duke
parents:
diff changeset
74
a61af66fc99e Initial load
duke
parents:
diff changeset
75 void Generation::print_heap_change(size_t prev_used) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
76 if (PrintGCDetails && Verbose) {
a61af66fc99e Initial load
duke
parents:
diff changeset
77 gclog_or_tty->print(" " SIZE_FORMAT
a61af66fc99e Initial load
duke
parents:
diff changeset
78 "->" SIZE_FORMAT
a61af66fc99e Initial load
duke
parents:
diff changeset
79 "(" SIZE_FORMAT ")",
a61af66fc99e Initial load
duke
parents:
diff changeset
80 prev_used, used(), capacity());
a61af66fc99e Initial load
duke
parents:
diff changeset
81 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
82 gclog_or_tty->print(" " SIZE_FORMAT "K"
a61af66fc99e Initial load
duke
parents:
diff changeset
83 "->" SIZE_FORMAT "K"
a61af66fc99e Initial load
duke
parents:
diff changeset
84 "(" SIZE_FORMAT "K)",
a61af66fc99e Initial load
duke
parents:
diff changeset
85 prev_used / K, used() / K, capacity() / K);
a61af66fc99e Initial load
duke
parents:
diff changeset
86 }
a61af66fc99e Initial load
duke
parents:
diff changeset
87 }
a61af66fc99e Initial load
duke
parents:
diff changeset
88
a61af66fc99e Initial load
duke
parents:
diff changeset
89 // By default we get a single threaded default reference processor;
2369
92da084fefc9 6668573: CMS: reference processing crash if ParallelCMSThreads > ParallelGCThreads
ysr
parents: 1972
diff changeset
90 // generations needing multi-threaded refs processing or discovery override this method.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
91 void Generation::ref_processor_init() {
a61af66fc99e Initial load
duke
parents:
diff changeset
92 assert(_ref_processor == NULL, "a reference processor already exists");
a61af66fc99e Initial load
duke
parents:
diff changeset
93 assert(!_reserved.is_empty(), "empty generation?");
2369
92da084fefc9 6668573: CMS: reference processing crash if ParallelCMSThreads > ParallelGCThreads
ysr
parents: 1972
diff changeset
94 _ref_processor = new ReferenceProcessor(_reserved); // a vanilla reference processor
0
a61af66fc99e Initial load
duke
parents:
diff changeset
95 if (_ref_processor == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
96 vm_exit_during_initialization("Could not allocate ReferenceProcessor object");
a61af66fc99e Initial load
duke
parents:
diff changeset
97 }
a61af66fc99e Initial load
duke
parents:
diff changeset
98 }
a61af66fc99e Initial load
duke
parents:
diff changeset
99
a61af66fc99e Initial load
duke
parents:
diff changeset
100 void Generation::print() const { print_on(tty); }
a61af66fc99e Initial load
duke
parents:
diff changeset
101
a61af66fc99e Initial load
duke
parents:
diff changeset
102 void Generation::print_on(outputStream* st) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
103 st->print(" %-20s", name());
a61af66fc99e Initial load
duke
parents:
diff changeset
104 st->print(" total " SIZE_FORMAT "K, used " SIZE_FORMAT "K",
a61af66fc99e Initial load
duke
parents:
diff changeset
105 capacity()/K, used()/K);
a61af66fc99e Initial load
duke
parents:
diff changeset
106 st->print_cr(" [" INTPTR_FORMAT ", " INTPTR_FORMAT ", " INTPTR_FORMAT ")",
a61af66fc99e Initial load
duke
parents:
diff changeset
107 _virtual_space.low_boundary(),
a61af66fc99e Initial load
duke
parents:
diff changeset
108 _virtual_space.high(),
a61af66fc99e Initial load
duke
parents:
diff changeset
109 _virtual_space.high_boundary());
a61af66fc99e Initial load
duke
parents:
diff changeset
110 }
a61af66fc99e Initial load
duke
parents:
diff changeset
111
a61af66fc99e Initial load
duke
parents:
diff changeset
112 void Generation::print_summary_info() { print_summary_info_on(tty); }
a61af66fc99e Initial load
duke
parents:
diff changeset
113
a61af66fc99e Initial load
duke
parents:
diff changeset
114 void Generation::print_summary_info_on(outputStream* st) {
a61af66fc99e Initial load
duke
parents:
diff changeset
115 StatRecord* sr = stat_record();
a61af66fc99e Initial load
duke
parents:
diff changeset
116 double time = sr->accumulated_time.seconds();
a61af66fc99e Initial load
duke
parents:
diff changeset
117 st->print_cr("[Accumulated GC generation %d time %3.7f secs, "
a61af66fc99e Initial load
duke
parents:
diff changeset
118 "%d GC's, avg GC time %3.7f]",
a61af66fc99e Initial load
duke
parents:
diff changeset
119 level(), time, sr->invocations,
a61af66fc99e Initial load
duke
parents:
diff changeset
120 sr->invocations > 0 ? time / sr->invocations : 0.0);
a61af66fc99e Initial load
duke
parents:
diff changeset
121 }
a61af66fc99e Initial load
duke
parents:
diff changeset
122
a61af66fc99e Initial load
duke
parents:
diff changeset
123 // Utility iterator classes
a61af66fc99e Initial load
duke
parents:
diff changeset
124
a61af66fc99e Initial load
duke
parents:
diff changeset
125 class GenerationIsInReservedClosure : public SpaceClosure {
a61af66fc99e Initial load
duke
parents:
diff changeset
126 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
127 const void* _p;
a61af66fc99e Initial load
duke
parents:
diff changeset
128 Space* sp;
a61af66fc99e Initial load
duke
parents:
diff changeset
129 virtual void do_space(Space* s) {
a61af66fc99e Initial load
duke
parents:
diff changeset
130 if (sp == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
131 if (s->is_in_reserved(_p)) sp = s;
a61af66fc99e Initial load
duke
parents:
diff changeset
132 }
a61af66fc99e Initial load
duke
parents:
diff changeset
133 }
a61af66fc99e Initial load
duke
parents:
diff changeset
134 GenerationIsInReservedClosure(const void* p) : _p(p), sp(NULL) {}
a61af66fc99e Initial load
duke
parents:
diff changeset
135 };
a61af66fc99e Initial load
duke
parents:
diff changeset
136
a61af66fc99e Initial load
duke
parents:
diff changeset
137 class GenerationIsInClosure : public SpaceClosure {
a61af66fc99e Initial load
duke
parents:
diff changeset
138 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
139 const void* _p;
a61af66fc99e Initial load
duke
parents:
diff changeset
140 Space* sp;
a61af66fc99e Initial load
duke
parents:
diff changeset
141 virtual void do_space(Space* s) {
a61af66fc99e Initial load
duke
parents:
diff changeset
142 if (sp == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
143 if (s->is_in(_p)) sp = s;
a61af66fc99e Initial load
duke
parents:
diff changeset
144 }
a61af66fc99e Initial load
duke
parents:
diff changeset
145 }
a61af66fc99e Initial load
duke
parents:
diff changeset
146 GenerationIsInClosure(const void* p) : _p(p), sp(NULL) {}
a61af66fc99e Initial load
duke
parents:
diff changeset
147 };
a61af66fc99e Initial load
duke
parents:
diff changeset
148
a61af66fc99e Initial load
duke
parents:
diff changeset
149 bool Generation::is_in(const void* p) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
150 GenerationIsInClosure blk(p);
a61af66fc99e Initial load
duke
parents:
diff changeset
151 ((Generation*)this)->space_iterate(&blk);
a61af66fc99e Initial load
duke
parents:
diff changeset
152 return blk.sp != NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
153 }
a61af66fc99e Initial load
duke
parents:
diff changeset
154
a61af66fc99e Initial load
duke
parents:
diff changeset
155 DefNewGeneration* Generation::as_DefNewGeneration() {
a61af66fc99e Initial load
duke
parents:
diff changeset
156 assert((kind() == Generation::DefNew) ||
a61af66fc99e Initial load
duke
parents:
diff changeset
157 (kind() == Generation::ParNew) ||
a61af66fc99e Initial load
duke
parents:
diff changeset
158 (kind() == Generation::ASParNew),
a61af66fc99e Initial load
duke
parents:
diff changeset
159 "Wrong youngest generation type");
a61af66fc99e Initial load
duke
parents:
diff changeset
160 return (DefNewGeneration*) this;
a61af66fc99e Initial load
duke
parents:
diff changeset
161 }
a61af66fc99e Initial load
duke
parents:
diff changeset
162
a61af66fc99e Initial load
duke
parents:
diff changeset
163 Generation* Generation::next_gen() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
164 GenCollectedHeap* gch = GenCollectedHeap::heap();
a61af66fc99e Initial load
duke
parents:
diff changeset
165 int next = level() + 1;
a61af66fc99e Initial load
duke
parents:
diff changeset
166 if (next < gch->_n_gens) {
a61af66fc99e Initial load
duke
parents:
diff changeset
167 return gch->_gens[next];
a61af66fc99e Initial load
duke
parents:
diff changeset
168 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
169 return NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
170 }
a61af66fc99e Initial load
duke
parents:
diff changeset
171 }
a61af66fc99e Initial load
duke
parents:
diff changeset
172
a61af66fc99e Initial load
duke
parents:
diff changeset
173 size_t Generation::max_contiguous_available() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
174 // The largest number of contiguous free words in this or any higher generation.
a61af66fc99e Initial load
duke
parents:
diff changeset
175 size_t max = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
176 for (const Generation* gen = this; gen != NULL; gen = gen->next_gen()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
177 size_t avail = gen->contiguous_available();
a61af66fc99e Initial load
duke
parents:
diff changeset
178 if (avail > max) {
a61af66fc99e Initial load
duke
parents:
diff changeset
179 max = avail;
a61af66fc99e Initial load
duke
parents:
diff changeset
180 }
a61af66fc99e Initial load
duke
parents:
diff changeset
181 }
a61af66fc99e Initial load
duke
parents:
diff changeset
182 return max;
a61af66fc99e Initial load
duke
parents:
diff changeset
183 }
a61af66fc99e Initial load
duke
parents:
diff changeset
184
1888
a7214d79fcf1 6896603: CMS/GCH: collection_attempt_is_safe() ergo should use more recent data
ysr
parents: 1552
diff changeset
185 bool Generation::promotion_attempt_is_safe(size_t max_promotion_in_bytes) const {
a7214d79fcf1 6896603: CMS/GCH: collection_attempt_is_safe() ergo should use more recent data
ysr
parents: 1552
diff changeset
186 size_t available = max_contiguous_available();
a7214d79fcf1 6896603: CMS/GCH: collection_attempt_is_safe() ergo should use more recent data
ysr
parents: 1552
diff changeset
187 bool res = (available >= max_promotion_in_bytes);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
188 if (PrintGC && Verbose) {
1888
a7214d79fcf1 6896603: CMS/GCH: collection_attempt_is_safe() ergo should use more recent data
ysr
parents: 1552
diff changeset
189 gclog_or_tty->print_cr(
a7214d79fcf1 6896603: CMS/GCH: collection_attempt_is_safe() ergo should use more recent data
ysr
parents: 1552
diff changeset
190 "Generation: promo attempt is%s safe: available("SIZE_FORMAT") %s max_promo("SIZE_FORMAT")",
a7214d79fcf1 6896603: CMS/GCH: collection_attempt_is_safe() ergo should use more recent data
ysr
parents: 1552
diff changeset
191 res? "":" not", available, res? ">=":"<",
a7214d79fcf1 6896603: CMS/GCH: collection_attempt_is_safe() ergo should use more recent data
ysr
parents: 1552
diff changeset
192 max_promotion_in_bytes);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
193 }
1888
a7214d79fcf1 6896603: CMS/GCH: collection_attempt_is_safe() ergo should use more recent data
ysr
parents: 1552
diff changeset
194 return res;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
195 }
a61af66fc99e Initial load
duke
parents:
diff changeset
196
a61af66fc99e Initial load
duke
parents:
diff changeset
197 // Ignores "ref" and calls allocate().
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
198 oop Generation::promote(oop obj, size_t obj_size) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
199 assert(obj_size == (size_t)obj->size(), "bad obj_size passed in");
a61af66fc99e Initial load
duke
parents:
diff changeset
200
a61af66fc99e Initial load
duke
parents:
diff changeset
201 #ifndef PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
202 if (Universe::heap()->promotion_should_fail()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
203 return NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
204 }
a61af66fc99e Initial load
duke
parents:
diff changeset
205 #endif // #ifndef PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
206
a61af66fc99e Initial load
duke
parents:
diff changeset
207 HeapWord* result = allocate(obj_size, false);
a61af66fc99e Initial load
duke
parents:
diff changeset
208 if (result != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
209 Copy::aligned_disjoint_words((HeapWord*)obj, result, obj_size);
a61af66fc99e Initial load
duke
parents:
diff changeset
210 return oop(result);
a61af66fc99e Initial load
duke
parents:
diff changeset
211 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
212 GenCollectedHeap* gch = GenCollectedHeap::heap();
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
213 return gch->handle_failed_promotion(this, obj, obj_size);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
214 }
a61af66fc99e Initial load
duke
parents:
diff changeset
215 }
a61af66fc99e Initial load
duke
parents:
diff changeset
216
a61af66fc99e Initial load
duke
parents:
diff changeset
217 oop Generation::par_promote(int thread_num,
a61af66fc99e Initial load
duke
parents:
diff changeset
218 oop obj, markOop m, size_t word_sz) {
a61af66fc99e Initial load
duke
parents:
diff changeset
219 // Could do a bad general impl here that gets a lock. But no.
a61af66fc99e Initial load
duke
parents:
diff changeset
220 ShouldNotCallThis();
a61af66fc99e Initial load
duke
parents:
diff changeset
221 return NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
222 }
a61af66fc99e Initial load
duke
parents:
diff changeset
223
a61af66fc99e Initial load
duke
parents:
diff changeset
224 void Generation::par_promote_alloc_undo(int thread_num,
a61af66fc99e Initial load
duke
parents:
diff changeset
225 HeapWord* obj, size_t word_sz) {
a61af66fc99e Initial load
duke
parents:
diff changeset
226 // Could do a bad general impl here that gets a lock. But no.
a61af66fc99e Initial load
duke
parents:
diff changeset
227 guarantee(false, "No good general implementation.");
a61af66fc99e Initial load
duke
parents:
diff changeset
228 }
a61af66fc99e Initial load
duke
parents:
diff changeset
229
a61af66fc99e Initial load
duke
parents:
diff changeset
230 Space* Generation::space_containing(const void* p) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
231 GenerationIsInReservedClosure blk(p);
a61af66fc99e Initial load
duke
parents:
diff changeset
232 // Cast away const
a61af66fc99e Initial load
duke
parents:
diff changeset
233 ((Generation*)this)->space_iterate(&blk);
a61af66fc99e Initial load
duke
parents:
diff changeset
234 return blk.sp;
a61af66fc99e Initial load
duke
parents:
diff changeset
235 }
a61af66fc99e Initial load
duke
parents:
diff changeset
236
a61af66fc99e Initial load
duke
parents:
diff changeset
237 // Some of these are mediocre general implementations. Should be
a61af66fc99e Initial load
duke
parents:
diff changeset
238 // overridden to get better performance.
a61af66fc99e Initial load
duke
parents:
diff changeset
239
a61af66fc99e Initial load
duke
parents:
diff changeset
240 class GenerationBlockStartClosure : public SpaceClosure {
a61af66fc99e Initial load
duke
parents:
diff changeset
241 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
242 const void* _p;
a61af66fc99e Initial load
duke
parents:
diff changeset
243 HeapWord* _start;
a61af66fc99e Initial load
duke
parents:
diff changeset
244 virtual void do_space(Space* s) {
a61af66fc99e Initial load
duke
parents:
diff changeset
245 if (_start == NULL && s->is_in_reserved(_p)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
246 _start = s->block_start(_p);
a61af66fc99e Initial load
duke
parents:
diff changeset
247 }
a61af66fc99e Initial load
duke
parents:
diff changeset
248 }
a61af66fc99e Initial load
duke
parents:
diff changeset
249 GenerationBlockStartClosure(const void* p) { _p = p; _start = NULL; }
a61af66fc99e Initial load
duke
parents:
diff changeset
250 };
a61af66fc99e Initial load
duke
parents:
diff changeset
251
a61af66fc99e Initial load
duke
parents:
diff changeset
252 HeapWord* Generation::block_start(const void* p) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
253 GenerationBlockStartClosure blk(p);
a61af66fc99e Initial load
duke
parents:
diff changeset
254 // Cast away const
a61af66fc99e Initial load
duke
parents:
diff changeset
255 ((Generation*)this)->space_iterate(&blk);
a61af66fc99e Initial load
duke
parents:
diff changeset
256 return blk._start;
a61af66fc99e Initial load
duke
parents:
diff changeset
257 }
a61af66fc99e Initial load
duke
parents:
diff changeset
258
a61af66fc99e Initial load
duke
parents:
diff changeset
259 class GenerationBlockSizeClosure : public SpaceClosure {
a61af66fc99e Initial load
duke
parents:
diff changeset
260 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
261 const HeapWord* _p;
a61af66fc99e Initial load
duke
parents:
diff changeset
262 size_t size;
a61af66fc99e Initial load
duke
parents:
diff changeset
263 virtual void do_space(Space* s) {
a61af66fc99e Initial load
duke
parents:
diff changeset
264 if (size == 0 && s->is_in_reserved(_p)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
265 size = s->block_size(_p);
a61af66fc99e Initial load
duke
parents:
diff changeset
266 }
a61af66fc99e Initial load
duke
parents:
diff changeset
267 }
a61af66fc99e Initial load
duke
parents:
diff changeset
268 GenerationBlockSizeClosure(const HeapWord* p) { _p = p; size = 0; }
a61af66fc99e Initial load
duke
parents:
diff changeset
269 };
a61af66fc99e Initial load
duke
parents:
diff changeset
270
a61af66fc99e Initial load
duke
parents:
diff changeset
271 size_t Generation::block_size(const HeapWord* p) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
272 GenerationBlockSizeClosure blk(p);
a61af66fc99e Initial load
duke
parents:
diff changeset
273 // Cast away const
a61af66fc99e Initial load
duke
parents:
diff changeset
274 ((Generation*)this)->space_iterate(&blk);
a61af66fc99e Initial load
duke
parents:
diff changeset
275 assert(blk.size > 0, "seems reasonable");
a61af66fc99e Initial load
duke
parents:
diff changeset
276 return blk.size;
a61af66fc99e Initial load
duke
parents:
diff changeset
277 }
a61af66fc99e Initial load
duke
parents:
diff changeset
278
a61af66fc99e Initial load
duke
parents:
diff changeset
279 class GenerationBlockIsObjClosure : public SpaceClosure {
a61af66fc99e Initial load
duke
parents:
diff changeset
280 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
281 const HeapWord* _p;
a61af66fc99e Initial load
duke
parents:
diff changeset
282 bool is_obj;
a61af66fc99e Initial load
duke
parents:
diff changeset
283 virtual void do_space(Space* s) {
a61af66fc99e Initial load
duke
parents:
diff changeset
284 if (!is_obj && s->is_in_reserved(_p)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
285 is_obj |= s->block_is_obj(_p);
a61af66fc99e Initial load
duke
parents:
diff changeset
286 }
a61af66fc99e Initial load
duke
parents:
diff changeset
287 }
a61af66fc99e Initial load
duke
parents:
diff changeset
288 GenerationBlockIsObjClosure(const HeapWord* p) { _p = p; is_obj = false; }
a61af66fc99e Initial load
duke
parents:
diff changeset
289 };
a61af66fc99e Initial load
duke
parents:
diff changeset
290
a61af66fc99e Initial load
duke
parents:
diff changeset
291 bool Generation::block_is_obj(const HeapWord* p) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
292 GenerationBlockIsObjClosure blk(p);
a61af66fc99e Initial load
duke
parents:
diff changeset
293 // Cast away const
a61af66fc99e Initial load
duke
parents:
diff changeset
294 ((Generation*)this)->space_iterate(&blk);
a61af66fc99e Initial load
duke
parents:
diff changeset
295 return blk.is_obj;
a61af66fc99e Initial load
duke
parents:
diff changeset
296 }
a61af66fc99e Initial load
duke
parents:
diff changeset
297
a61af66fc99e Initial load
duke
parents:
diff changeset
298 class GenerationOopIterateClosure : public SpaceClosure {
a61af66fc99e Initial load
duke
parents:
diff changeset
299 public:
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6008
diff changeset
300 ExtendedOopClosure* cl;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
301 MemRegion mr;
a61af66fc99e Initial load
duke
parents:
diff changeset
302 virtual void do_space(Space* s) {
a61af66fc99e Initial load
duke
parents:
diff changeset
303 s->oop_iterate(mr, cl);
a61af66fc99e Initial load
duke
parents:
diff changeset
304 }
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6008
diff changeset
305 GenerationOopIterateClosure(ExtendedOopClosure* _cl, MemRegion _mr) :
0
a61af66fc99e Initial load
duke
parents:
diff changeset
306 cl(_cl), mr(_mr) {}
a61af66fc99e Initial load
duke
parents:
diff changeset
307 };
a61af66fc99e Initial load
duke
parents:
diff changeset
308
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6008
diff changeset
309 void Generation::oop_iterate(ExtendedOopClosure* cl) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
310 GenerationOopIterateClosure blk(cl, _reserved);
a61af66fc99e Initial load
duke
parents:
diff changeset
311 space_iterate(&blk);
a61af66fc99e Initial load
duke
parents:
diff changeset
312 }
a61af66fc99e Initial load
duke
parents:
diff changeset
313
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6008
diff changeset
314 void Generation::oop_iterate(MemRegion mr, ExtendedOopClosure* cl) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
315 GenerationOopIterateClosure blk(cl, mr);
a61af66fc99e Initial load
duke
parents:
diff changeset
316 space_iterate(&blk);
a61af66fc99e Initial load
duke
parents:
diff changeset
317 }
a61af66fc99e Initial load
duke
parents:
diff changeset
318
a61af66fc99e Initial load
duke
parents:
diff changeset
319 void Generation::younger_refs_in_space_iterate(Space* sp,
a61af66fc99e Initial load
duke
parents:
diff changeset
320 OopsInGenClosure* cl) {
a61af66fc99e Initial load
duke
parents:
diff changeset
321 GenRemSet* rs = SharedHeap::heap()->rem_set();
a61af66fc99e Initial load
duke
parents:
diff changeset
322 rs->younger_refs_in_space_iterate(sp, cl);
a61af66fc99e Initial load
duke
parents:
diff changeset
323 }
a61af66fc99e Initial load
duke
parents:
diff changeset
324
a61af66fc99e Initial load
duke
parents:
diff changeset
325 class GenerationObjIterateClosure : public SpaceClosure {
a61af66fc99e Initial load
duke
parents:
diff changeset
326 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
327 ObjectClosure* _cl;
a61af66fc99e Initial load
duke
parents:
diff changeset
328 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
329 virtual void do_space(Space* s) {
a61af66fc99e Initial load
duke
parents:
diff changeset
330 s->object_iterate(_cl);
a61af66fc99e Initial load
duke
parents:
diff changeset
331 }
a61af66fc99e Initial load
duke
parents:
diff changeset
332 GenerationObjIterateClosure(ObjectClosure* cl) : _cl(cl) {}
a61af66fc99e Initial load
duke
parents:
diff changeset
333 };
a61af66fc99e Initial load
duke
parents:
diff changeset
334
a61af66fc99e Initial load
duke
parents:
diff changeset
335 void Generation::object_iterate(ObjectClosure* cl) {
a61af66fc99e Initial load
duke
parents:
diff changeset
336 GenerationObjIterateClosure blk(cl);
a61af66fc99e Initial load
duke
parents:
diff changeset
337 space_iterate(&blk);
a61af66fc99e Initial load
duke
parents:
diff changeset
338 }
a61af66fc99e Initial load
duke
parents:
diff changeset
339
517
e9be0e04635a 6689653: JMapPerm fails with UseConcMarkSweepIncGC and compressed oops off
jmasa
parents: 271
diff changeset
340 class GenerationSafeObjIterateClosure : public SpaceClosure {
e9be0e04635a 6689653: JMapPerm fails with UseConcMarkSweepIncGC and compressed oops off
jmasa
parents: 271
diff changeset
341 private:
e9be0e04635a 6689653: JMapPerm fails with UseConcMarkSweepIncGC and compressed oops off
jmasa
parents: 271
diff changeset
342 ObjectClosure* _cl;
e9be0e04635a 6689653: JMapPerm fails with UseConcMarkSweepIncGC and compressed oops off
jmasa
parents: 271
diff changeset
343 public:
e9be0e04635a 6689653: JMapPerm fails with UseConcMarkSweepIncGC and compressed oops off
jmasa
parents: 271
diff changeset
344 virtual void do_space(Space* s) {
e9be0e04635a 6689653: JMapPerm fails with UseConcMarkSweepIncGC and compressed oops off
jmasa
parents: 271
diff changeset
345 s->safe_object_iterate(_cl);
e9be0e04635a 6689653: JMapPerm fails with UseConcMarkSweepIncGC and compressed oops off
jmasa
parents: 271
diff changeset
346 }
e9be0e04635a 6689653: JMapPerm fails with UseConcMarkSweepIncGC and compressed oops off
jmasa
parents: 271
diff changeset
347 GenerationSafeObjIterateClosure(ObjectClosure* cl) : _cl(cl) {}
e9be0e04635a 6689653: JMapPerm fails with UseConcMarkSweepIncGC and compressed oops off
jmasa
parents: 271
diff changeset
348 };
e9be0e04635a 6689653: JMapPerm fails with UseConcMarkSweepIncGC and compressed oops off
jmasa
parents: 271
diff changeset
349
e9be0e04635a 6689653: JMapPerm fails with UseConcMarkSweepIncGC and compressed oops off
jmasa
parents: 271
diff changeset
350 void Generation::safe_object_iterate(ObjectClosure* cl) {
e9be0e04635a 6689653: JMapPerm fails with UseConcMarkSweepIncGC and compressed oops off
jmasa
parents: 271
diff changeset
351 GenerationSafeObjIterateClosure blk(cl);
e9be0e04635a 6689653: JMapPerm fails with UseConcMarkSweepIncGC and compressed oops off
jmasa
parents: 271
diff changeset
352 space_iterate(&blk);
e9be0e04635a 6689653: JMapPerm fails with UseConcMarkSweepIncGC and compressed oops off
jmasa
parents: 271
diff changeset
353 }
e9be0e04635a 6689653: JMapPerm fails with UseConcMarkSweepIncGC and compressed oops off
jmasa
parents: 271
diff changeset
354
0
a61af66fc99e Initial load
duke
parents:
diff changeset
355 void Generation::prepare_for_compaction(CompactPoint* cp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
356 // Generic implementation, can be specialized
a61af66fc99e Initial load
duke
parents:
diff changeset
357 CompactibleSpace* space = first_compaction_space();
a61af66fc99e Initial load
duke
parents:
diff changeset
358 while (space != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
359 space->prepare_for_compaction(cp);
a61af66fc99e Initial load
duke
parents:
diff changeset
360 space = space->next_compaction_space();
a61af66fc99e Initial load
duke
parents:
diff changeset
361 }
a61af66fc99e Initial load
duke
parents:
diff changeset
362 }
a61af66fc99e Initial load
duke
parents:
diff changeset
363
a61af66fc99e Initial load
duke
parents:
diff changeset
364 class AdjustPointersClosure: public SpaceClosure {
a61af66fc99e Initial load
duke
parents:
diff changeset
365 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
366 void do_space(Space* sp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
367 sp->adjust_pointers();
a61af66fc99e Initial load
duke
parents:
diff changeset
368 }
a61af66fc99e Initial load
duke
parents:
diff changeset
369 };
a61af66fc99e Initial load
duke
parents:
diff changeset
370
a61af66fc99e Initial load
duke
parents:
diff changeset
371 void Generation::adjust_pointers() {
a61af66fc99e Initial load
duke
parents:
diff changeset
372 // Note that this is done over all spaces, not just the compactible
a61af66fc99e Initial load
duke
parents:
diff changeset
373 // ones.
a61af66fc99e Initial load
duke
parents:
diff changeset
374 AdjustPointersClosure blk;
a61af66fc99e Initial load
duke
parents:
diff changeset
375 space_iterate(&blk, true);
a61af66fc99e Initial load
duke
parents:
diff changeset
376 }
a61af66fc99e Initial load
duke
parents:
diff changeset
377
a61af66fc99e Initial load
duke
parents:
diff changeset
378 void Generation::compact() {
a61af66fc99e Initial load
duke
parents:
diff changeset
379 CompactibleSpace* sp = first_compaction_space();
a61af66fc99e Initial load
duke
parents:
diff changeset
380 while (sp != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
381 sp->compact();
a61af66fc99e Initial load
duke
parents:
diff changeset
382 sp = sp->next_compaction_space();
a61af66fc99e Initial load
duke
parents:
diff changeset
383 }
a61af66fc99e Initial load
duke
parents:
diff changeset
384 }
a61af66fc99e Initial load
duke
parents:
diff changeset
385
a61af66fc99e Initial load
duke
parents:
diff changeset
386 CardGeneration::CardGeneration(ReservedSpace rs, size_t initial_byte_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
387 int level,
a61af66fc99e Initial load
duke
parents:
diff changeset
388 GenRemSet* remset) :
9072
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
389 Generation(rs, initial_byte_size, level), _rs(remset),
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
390 _shrink_factor(0), _min_heap_delta_bytes(), _capacity_at_prologue(),
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
391 _used_at_prologue()
0
a61af66fc99e Initial load
duke
parents:
diff changeset
392 {
a61af66fc99e Initial load
duke
parents:
diff changeset
393 HeapWord* start = (HeapWord*)rs.base();
a61af66fc99e Initial load
duke
parents:
diff changeset
394 size_t reserved_byte_size = rs.size();
a61af66fc99e Initial load
duke
parents:
diff changeset
395 assert((uintptr_t(start) & 3) == 0, "bad alignment");
a61af66fc99e Initial load
duke
parents:
diff changeset
396 assert((reserved_byte_size & 3) == 0, "bad alignment");
a61af66fc99e Initial load
duke
parents:
diff changeset
397 MemRegion reserved_mr(start, heap_word_size(reserved_byte_size));
a61af66fc99e Initial load
duke
parents:
diff changeset
398 _bts = new BlockOffsetSharedArray(reserved_mr,
a61af66fc99e Initial load
duke
parents:
diff changeset
399 heap_word_size(initial_byte_size));
a61af66fc99e Initial load
duke
parents:
diff changeset
400 MemRegion committed_mr(start, heap_word_size(initial_byte_size));
a61af66fc99e Initial load
duke
parents:
diff changeset
401 _rs->resize_covered_region(committed_mr);
a61af66fc99e Initial load
duke
parents:
diff changeset
402 if (_bts == NULL)
a61af66fc99e Initial load
duke
parents:
diff changeset
403 vm_exit_during_initialization("Could not allocate a BlockOffsetArray");
a61af66fc99e Initial load
duke
parents:
diff changeset
404
a61af66fc99e Initial load
duke
parents:
diff changeset
405 // Verify that the start and end of this generation is the start of a card.
a61af66fc99e Initial load
duke
parents:
diff changeset
406 // If this wasn't true, a single card could span more than on generation,
a61af66fc99e Initial load
duke
parents:
diff changeset
407 // which would cause problems when we commit/uncommit memory, and when we
a61af66fc99e Initial load
duke
parents:
diff changeset
408 // clear and dirty cards.
a61af66fc99e Initial load
duke
parents:
diff changeset
409 guarantee(_rs->is_aligned(reserved_mr.start()), "generation must be card aligned");
a61af66fc99e Initial load
duke
parents:
diff changeset
410 if (reserved_mr.end() != Universe::heap()->reserved_region().end()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
411 // 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
412 // the end if we try.
a61af66fc99e Initial load
duke
parents:
diff changeset
413 guarantee(_rs->is_aligned(reserved_mr.end()), "generation must be card aligned");
a61af66fc99e Initial load
duke
parents:
diff changeset
414 }
9072
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
415 _min_heap_delta_bytes = MinHeapDeltaBytes;
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
416 _capacity_at_prologue = initial_byte_size;
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
417 _used_at_prologue = 0;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
418 }
a61af66fc99e Initial load
duke
parents:
diff changeset
419
271
818a18cd69a8 6730514: assertion failure in mangling code when expanding by 0 bytes
jmasa
parents: 269
diff changeset
420 bool CardGeneration::expand(size_t bytes, size_t expand_bytes) {
818a18cd69a8 6730514: assertion failure in mangling code when expanding by 0 bytes
jmasa
parents: 269
diff changeset
421 assert_locked_or_safepoint(Heap_lock);
818a18cd69a8 6730514: assertion failure in mangling code when expanding by 0 bytes
jmasa
parents: 269
diff changeset
422 if (bytes == 0) {
818a18cd69a8 6730514: assertion failure in mangling code when expanding by 0 bytes
jmasa
parents: 269
diff changeset
423 return true; // That's what grow_by(0) would return
818a18cd69a8 6730514: assertion failure in mangling code when expanding by 0 bytes
jmasa
parents: 269
diff changeset
424 }
818a18cd69a8 6730514: assertion failure in mangling code when expanding by 0 bytes
jmasa
parents: 269
diff changeset
425 size_t aligned_bytes = ReservedSpace::page_align_size_up(bytes);
818a18cd69a8 6730514: assertion failure in mangling code when expanding by 0 bytes
jmasa
parents: 269
diff changeset
426 if (aligned_bytes == 0){
818a18cd69a8 6730514: assertion failure in mangling code when expanding by 0 bytes
jmasa
parents: 269
diff changeset
427 // 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: 269
diff changeset
428 // return true with the implication that an expansion was done when it
818a18cd69a8 6730514: assertion failure in mangling code when expanding by 0 bytes
jmasa
parents: 269
diff changeset
429 // 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: 269
diff changeset
430 // 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: 269
diff changeset
431 // 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: 269
diff changeset
432 // start with.
818a18cd69a8 6730514: assertion failure in mangling code when expanding by 0 bytes
jmasa
parents: 269
diff changeset
433 aligned_bytes = ReservedSpace::page_align_size_down(bytes);
818a18cd69a8 6730514: assertion failure in mangling code when expanding by 0 bytes
jmasa
parents: 269
diff changeset
434 }
818a18cd69a8 6730514: assertion failure in mangling code when expanding by 0 bytes
jmasa
parents: 269
diff changeset
435 size_t aligned_expand_bytes = ReservedSpace::page_align_size_up(expand_bytes);
818a18cd69a8 6730514: assertion failure in mangling code when expanding by 0 bytes
jmasa
parents: 269
diff changeset
436 bool success = false;
818a18cd69a8 6730514: assertion failure in mangling code when expanding by 0 bytes
jmasa
parents: 269
diff changeset
437 if (aligned_expand_bytes > aligned_bytes) {
818a18cd69a8 6730514: assertion failure in mangling code when expanding by 0 bytes
jmasa
parents: 269
diff changeset
438 success = grow_by(aligned_expand_bytes);
818a18cd69a8 6730514: assertion failure in mangling code when expanding by 0 bytes
jmasa
parents: 269
diff changeset
439 }
818a18cd69a8 6730514: assertion failure in mangling code when expanding by 0 bytes
jmasa
parents: 269
diff changeset
440 if (!success) {
818a18cd69a8 6730514: assertion failure in mangling code when expanding by 0 bytes
jmasa
parents: 269
diff changeset
441 success = grow_by(aligned_bytes);
818a18cd69a8 6730514: assertion failure in mangling code when expanding by 0 bytes
jmasa
parents: 269
diff changeset
442 }
818a18cd69a8 6730514: assertion failure in mangling code when expanding by 0 bytes
jmasa
parents: 269
diff changeset
443 if (!success) {
818a18cd69a8 6730514: assertion failure in mangling code when expanding by 0 bytes
jmasa
parents: 269
diff changeset
444 success = grow_to_reserved();
818a18cd69a8 6730514: assertion failure in mangling code when expanding by 0 bytes
jmasa
parents: 269
diff changeset
445 }
818a18cd69a8 6730514: assertion failure in mangling code when expanding by 0 bytes
jmasa
parents: 269
diff changeset
446 if (PrintGC && Verbose) {
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6008
diff changeset
447 if (success && GC_locker::is_active_and_needs_gc()) {
271
818a18cd69a8 6730514: assertion failure in mangling code when expanding by 0 bytes
jmasa
parents: 269
diff changeset
448 gclog_or_tty->print_cr("Garbage collection disabled, expanded heap instead");
818a18cd69a8 6730514: assertion failure in mangling code when expanding by 0 bytes
jmasa
parents: 269
diff changeset
449 }
818a18cd69a8 6730514: assertion failure in mangling code when expanding by 0 bytes
jmasa
parents: 269
diff changeset
450 }
818a18cd69a8 6730514: assertion failure in mangling code when expanding by 0 bytes
jmasa
parents: 269
diff changeset
451
818a18cd69a8 6730514: assertion failure in mangling code when expanding by 0 bytes
jmasa
parents: 269
diff changeset
452 return success;
818a18cd69a8 6730514: assertion failure in mangling code when expanding by 0 bytes
jmasa
parents: 269
diff changeset
453 }
818a18cd69a8 6730514: assertion failure in mangling code when expanding by 0 bytes
jmasa
parents: 269
diff changeset
454
0
a61af66fc99e Initial load
duke
parents:
diff changeset
455
a61af66fc99e Initial load
duke
parents:
diff changeset
456 // No young generation references, clear this generation's cards.
a61af66fc99e Initial load
duke
parents:
diff changeset
457 void CardGeneration::clear_remembered_set() {
a61af66fc99e Initial load
duke
parents:
diff changeset
458 _rs->clear(reserved());
a61af66fc99e Initial load
duke
parents:
diff changeset
459 }
a61af66fc99e Initial load
duke
parents:
diff changeset
460
a61af66fc99e Initial load
duke
parents:
diff changeset
461
a61af66fc99e Initial load
duke
parents:
diff changeset
462 // Objects in this generation may have moved, invalidate this
a61af66fc99e Initial load
duke
parents:
diff changeset
463 // generation's cards.
a61af66fc99e Initial load
duke
parents:
diff changeset
464 void CardGeneration::invalidate_remembered_set() {
a61af66fc99e Initial load
duke
parents:
diff changeset
465 _rs->invalidate(used_region());
a61af66fc99e Initial load
duke
parents:
diff changeset
466 }
a61af66fc99e Initial load
duke
parents:
diff changeset
467
a61af66fc99e Initial load
duke
parents:
diff changeset
468
9072
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
469 void CardGeneration::compute_new_size() {
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
470 assert(_shrink_factor <= 100, "invalid shrink factor");
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
471 size_t current_shrink_factor = _shrink_factor;
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
472 _shrink_factor = 0;
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
473
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
474 // We don't have floating point command-line arguments
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
475 // Note: argument processing ensures that MinHeapFreeRatio < 100.
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
476 const double minimum_free_percentage = MinHeapFreeRatio / 100.0;
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
477 const double maximum_used_percentage = 1.0 - minimum_free_percentage;
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
478
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
479 // Compute some numbers about the state of the heap.
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
480 const size_t used_after_gc = used();
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
481 const size_t capacity_after_gc = capacity();
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
482
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
483 const double min_tmp = used_after_gc / maximum_used_percentage;
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
484 size_t minimum_desired_capacity = (size_t)MIN2(min_tmp, double(max_uintx));
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
485 // Don't shrink less than the initial generation size
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
486 minimum_desired_capacity = MAX2(minimum_desired_capacity,
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
487 spec()->init_size());
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
488 assert(used_after_gc <= minimum_desired_capacity, "sanity check");
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
489
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
490 if (PrintGC && Verbose) {
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
491 const size_t free_after_gc = free();
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
492 const double free_percentage = ((double)free_after_gc) / capacity_after_gc;
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
493 gclog_or_tty->print_cr("TenuredGeneration::compute_new_size: ");
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
494 gclog_or_tty->print_cr(" "
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
495 " minimum_free_percentage: %6.2f"
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
496 " maximum_used_percentage: %6.2f",
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
497 minimum_free_percentage,
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
498 maximum_used_percentage);
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
499 gclog_or_tty->print_cr(" "
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
500 " free_after_gc : %6.1fK"
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
501 " used_after_gc : %6.1fK"
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
502 " capacity_after_gc : %6.1fK",
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
503 free_after_gc / (double) K,
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
504 used_after_gc / (double) K,
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
505 capacity_after_gc / (double) K);
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
506 gclog_or_tty->print_cr(" "
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
507 " free_percentage: %6.2f",
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
508 free_percentage);
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
509 }
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
510
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
511 if (capacity_after_gc < minimum_desired_capacity) {
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
512 // If we have less free space than we want then expand
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
513 size_t expand_bytes = minimum_desired_capacity - capacity_after_gc;
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
514 // Don't expand unless it's significant
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
515 if (expand_bytes >= _min_heap_delta_bytes) {
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
516 expand(expand_bytes, 0); // safe if expansion fails
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
517 }
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
518 if (PrintGC && Verbose) {
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
519 gclog_or_tty->print_cr(" expanding:"
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
520 " minimum_desired_capacity: %6.1fK"
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
521 " expand_bytes: %6.1fK"
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
522 " _min_heap_delta_bytes: %6.1fK",
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
523 minimum_desired_capacity / (double) K,
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
524 expand_bytes / (double) K,
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
525 _min_heap_delta_bytes / (double) K);
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
526 }
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
527 return;
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
528 }
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
529
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
530 // No expansion, now see if we want to shrink
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
531 size_t shrink_bytes = 0;
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
532 // We would never want to shrink more than this
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
533 size_t max_shrink_bytes = capacity_after_gc - minimum_desired_capacity;
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
534
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
535 if (MaxHeapFreeRatio < 100) {
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
536 const double maximum_free_percentage = MaxHeapFreeRatio / 100.0;
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
537 const double minimum_used_percentage = 1.0 - maximum_free_percentage;
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
538 const double max_tmp = used_after_gc / minimum_used_percentage;
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
539 size_t maximum_desired_capacity = (size_t)MIN2(max_tmp, double(max_uintx));
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
540 maximum_desired_capacity = MAX2(maximum_desired_capacity,
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
541 spec()->init_size());
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
542 if (PrintGC && Verbose) {
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
543 gclog_or_tty->print_cr(" "
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
544 " maximum_free_percentage: %6.2f"
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
545 " minimum_used_percentage: %6.2f",
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
546 maximum_free_percentage,
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
547 minimum_used_percentage);
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
548 gclog_or_tty->print_cr(" "
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
549 " _capacity_at_prologue: %6.1fK"
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
550 " minimum_desired_capacity: %6.1fK"
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
551 " maximum_desired_capacity: %6.1fK",
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
552 _capacity_at_prologue / (double) K,
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
553 minimum_desired_capacity / (double) K,
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
554 maximum_desired_capacity / (double) K);
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
555 }
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
556 assert(minimum_desired_capacity <= maximum_desired_capacity,
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
557 "sanity check");
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
558
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
559 if (capacity_after_gc > maximum_desired_capacity) {
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
560 // Capacity too large, compute shrinking size
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
561 shrink_bytes = capacity_after_gc - maximum_desired_capacity;
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
562 // We don't want shrink all the way back to initSize if people call
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
563 // System.gc(), because some programs do that between "phases" and then
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
564 // we'd just have to grow the heap up again for the next phase. So we
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
565 // damp the shrinking: 0% on the first call, 10% on the second call, 40%
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
566 // on the third call, and 100% by the fourth call. But if we recompute
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
567 // size without shrinking, it goes back to 0%.
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
568 shrink_bytes = shrink_bytes / 100 * current_shrink_factor;
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
569 assert(shrink_bytes <= max_shrink_bytes, "invalid shrink size");
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
570 if (current_shrink_factor == 0) {
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
571 _shrink_factor = 10;
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
572 } else {
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
573 _shrink_factor = MIN2(current_shrink_factor * 4, (size_t) 100);
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
574 }
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
575 if (PrintGC && Verbose) {
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
576 gclog_or_tty->print_cr(" "
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
577 " shrinking:"
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
578 " initSize: %.1fK"
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
579 " maximum_desired_capacity: %.1fK",
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
580 spec()->init_size() / (double) K,
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
581 maximum_desired_capacity / (double) K);
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
582 gclog_or_tty->print_cr(" "
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
583 " shrink_bytes: %.1fK"
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
584 " current_shrink_factor: %d"
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
585 " new shrink factor: %d"
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
586 " _min_heap_delta_bytes: %.1fK",
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
587 shrink_bytes / (double) K,
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
588 current_shrink_factor,
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
589 _shrink_factor,
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
590 _min_heap_delta_bytes / (double) K);
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
591 }
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
592 }
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
593 }
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
594
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
595 if (capacity_after_gc > _capacity_at_prologue) {
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
596 // We might have expanded for promotions, in which case we might want to
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
597 // take back that expansion if there's room after GC. That keeps us from
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
598 // stretching the heap with promotions when there's plenty of room.
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
599 size_t expansion_for_promotion = capacity_after_gc - _capacity_at_prologue;
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
600 expansion_for_promotion = MIN2(expansion_for_promotion, max_shrink_bytes);
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
601 // We have two shrinking computations, take the largest
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
602 shrink_bytes = MAX2(shrink_bytes, expansion_for_promotion);
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
603 assert(shrink_bytes <= max_shrink_bytes, "invalid shrink size");
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
604 if (PrintGC && Verbose) {
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
605 gclog_or_tty->print_cr(" "
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
606 " aggressive shrinking:"
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
607 " _capacity_at_prologue: %.1fK"
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
608 " capacity_after_gc: %.1fK"
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
609 " expansion_for_promotion: %.1fK"
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
610 " shrink_bytes: %.1fK",
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
611 capacity_after_gc / (double) K,
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
612 _capacity_at_prologue / (double) K,
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
613 expansion_for_promotion / (double) K,
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
614 shrink_bytes / (double) K);
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
615 }
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
616 }
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
617 // Don't shrink unless it's significant
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
618 if (shrink_bytes >= _min_heap_delta_bytes) {
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
619 shrink(shrink_bytes);
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
620 }
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
621 }
8617e38bb4cb 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 6725
diff changeset
622
0
a61af66fc99e Initial load
duke
parents:
diff changeset
623 // Currently nothing to do.
a61af66fc99e Initial load
duke
parents:
diff changeset
624 void CardGeneration::prepare_for_verify() {}
a61af66fc99e Initial load
duke
parents:
diff changeset
625
a61af66fc99e Initial load
duke
parents:
diff changeset
626
a61af66fc99e Initial load
duke
parents:
diff changeset
627 void OneContigSpaceCardGeneration::collect(bool full,
a61af66fc99e Initial load
duke
parents:
diff changeset
628 bool clear_all_soft_refs,
a61af66fc99e Initial load
duke
parents:
diff changeset
629 size_t size,
a61af66fc99e Initial load
duke
parents:
diff changeset
630 bool is_tlab) {
10405
f2110083203d 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 9072
diff changeset
631 GenCollectedHeap* gch = GenCollectedHeap::heap();
f2110083203d 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 9072
diff changeset
632
0
a61af66fc99e Initial load
duke
parents:
diff changeset
633 SpecializationStats::clear();
a61af66fc99e Initial load
duke
parents:
diff changeset
634 // Temporarily expand the span of our ref processor, so
a61af66fc99e Initial load
duke
parents:
diff changeset
635 // refs discovery is over the entire heap, not just this generation
a61af66fc99e Initial load
duke
parents:
diff changeset
636 ReferenceProcessorSpanMutator
10405
f2110083203d 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 9072
diff changeset
637 x(ref_processor(), gch->reserved_region());
f2110083203d 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 9072
diff changeset
638
f2110083203d 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 9072
diff changeset
639 STWGCTimer* gc_timer = GenMarkSweep::gc_timer();
13400
86e6d691f2e1 8028128: Add a type safe alternative for working with counter based data
mgronlun
parents: 11096
diff changeset
640 gc_timer->register_gc_start();
10405
f2110083203d 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 9072
diff changeset
641
f2110083203d 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 9072
diff changeset
642 SerialOldTracer* gc_tracer = GenMarkSweep::gc_tracer();
f2110083203d 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 9072
diff changeset
643 gc_tracer->report_gc_start(gch->gc_cause(), gc_timer->gc_start());
f2110083203d 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 9072
diff changeset
644
0
a61af66fc99e Initial load
duke
parents:
diff changeset
645 GenMarkSweep::invoke_at_safepoint(_level, ref_processor(), clear_all_soft_refs);
10405
f2110083203d 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 9072
diff changeset
646
13400
86e6d691f2e1 8028128: Add a type safe alternative for working with counter based data
mgronlun
parents: 11096
diff changeset
647 gc_timer->register_gc_end();
10405
f2110083203d 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 9072
diff changeset
648
13400
86e6d691f2e1 8028128: Add a type safe alternative for working with counter based data
mgronlun
parents: 11096
diff changeset
649 gc_tracer->report_gc_end(gc_timer->gc_end(), gc_timer->time_partitions());
10405
f2110083203d 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 9072
diff changeset
650
0
a61af66fc99e Initial load
duke
parents:
diff changeset
651 SpecializationStats::print();
a61af66fc99e Initial load
duke
parents:
diff changeset
652 }
a61af66fc99e Initial load
duke
parents:
diff changeset
653
a61af66fc99e Initial load
duke
parents:
diff changeset
654 HeapWord*
a61af66fc99e Initial load
duke
parents:
diff changeset
655 OneContigSpaceCardGeneration::expand_and_allocate(size_t word_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
656 bool is_tlab,
a61af66fc99e Initial load
duke
parents:
diff changeset
657 bool parallel) {
a61af66fc99e Initial load
duke
parents:
diff changeset
658 assert(!is_tlab, "OneContigSpaceCardGeneration does not support TLAB allocation");
a61af66fc99e Initial load
duke
parents:
diff changeset
659 if (parallel) {
a61af66fc99e Initial load
duke
parents:
diff changeset
660 MutexLocker x(ParGCRareEvent_lock);
a61af66fc99e Initial load
duke
parents:
diff changeset
661 HeapWord* result = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
662 size_t byte_size = word_size * HeapWordSize;
a61af66fc99e Initial load
duke
parents:
diff changeset
663 while (true) {
a61af66fc99e Initial load
duke
parents:
diff changeset
664 expand(byte_size, _min_heap_delta_bytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
665 if (GCExpandToAllocateDelayMillis > 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
666 os::sleep(Thread::current(), GCExpandToAllocateDelayMillis, false);
a61af66fc99e Initial load
duke
parents:
diff changeset
667 }
a61af66fc99e Initial load
duke
parents:
diff changeset
668 result = _the_space->par_allocate(word_size);
a61af66fc99e Initial load
duke
parents:
diff changeset
669 if ( result != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
670 return result;
a61af66fc99e Initial load
duke
parents:
diff changeset
671 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
672 // If there's not enough expansion space available, give up.
a61af66fc99e Initial load
duke
parents:
diff changeset
673 if (_virtual_space.uncommitted_size() < byte_size) {
a61af66fc99e Initial load
duke
parents:
diff changeset
674 return NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
675 }
a61af66fc99e Initial load
duke
parents:
diff changeset
676 // else try again
a61af66fc99e Initial load
duke
parents:
diff changeset
677 }
a61af66fc99e Initial load
duke
parents:
diff changeset
678 }
a61af66fc99e Initial load
duke
parents:
diff changeset
679 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
680 expand(word_size*HeapWordSize, _min_heap_delta_bytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
681 return _the_space->allocate(word_size);
a61af66fc99e Initial load
duke
parents:
diff changeset
682 }
a61af66fc99e Initial load
duke
parents:
diff changeset
683 }
a61af66fc99e Initial load
duke
parents:
diff changeset
684
271
818a18cd69a8 6730514: assertion failure in mangling code when expanding by 0 bytes
jmasa
parents: 269
diff changeset
685 bool OneContigSpaceCardGeneration::expand(size_t bytes, size_t expand_bytes) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
686 GCMutexLocker x(ExpandHeap_lock);
271
818a18cd69a8 6730514: assertion failure in mangling code when expanding by 0 bytes
jmasa
parents: 269
diff changeset
687 return CardGeneration::expand(bytes, expand_bytes);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
688 }
a61af66fc99e Initial load
duke
parents:
diff changeset
689
a61af66fc99e Initial load
duke
parents:
diff changeset
690
a61af66fc99e Initial load
duke
parents:
diff changeset
691 void OneContigSpaceCardGeneration::shrink(size_t bytes) {
a61af66fc99e Initial load
duke
parents:
diff changeset
692 assert_locked_or_safepoint(ExpandHeap_lock);
a61af66fc99e Initial load
duke
parents:
diff changeset
693 size_t size = ReservedSpace::page_align_size_down(bytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
694 if (size > 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
695 shrink_by(size);
a61af66fc99e Initial load
duke
parents:
diff changeset
696 }
a61af66fc99e Initial load
duke
parents:
diff changeset
697 }
a61af66fc99e Initial load
duke
parents:
diff changeset
698
a61af66fc99e Initial load
duke
parents:
diff changeset
699
a61af66fc99e Initial load
duke
parents:
diff changeset
700 size_t OneContigSpaceCardGeneration::capacity() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
701 return _the_space->capacity();
a61af66fc99e Initial load
duke
parents:
diff changeset
702 }
a61af66fc99e Initial load
duke
parents:
diff changeset
703
a61af66fc99e Initial load
duke
parents:
diff changeset
704
a61af66fc99e Initial load
duke
parents:
diff changeset
705 size_t OneContigSpaceCardGeneration::used() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
706 return _the_space->used();
a61af66fc99e Initial load
duke
parents:
diff changeset
707 }
a61af66fc99e Initial load
duke
parents:
diff changeset
708
a61af66fc99e Initial load
duke
parents:
diff changeset
709
a61af66fc99e Initial load
duke
parents:
diff changeset
710 size_t OneContigSpaceCardGeneration::free() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
711 return _the_space->free();
a61af66fc99e Initial load
duke
parents:
diff changeset
712 }
a61af66fc99e Initial load
duke
parents:
diff changeset
713
a61af66fc99e Initial load
duke
parents:
diff changeset
714 MemRegion OneContigSpaceCardGeneration::used_region() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
715 return the_space()->used_region();
a61af66fc99e Initial load
duke
parents:
diff changeset
716 }
a61af66fc99e Initial load
duke
parents:
diff changeset
717
a61af66fc99e Initial load
duke
parents:
diff changeset
718 size_t OneContigSpaceCardGeneration::unsafe_max_alloc_nogc() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
719 return _the_space->free();
a61af66fc99e Initial load
duke
parents:
diff changeset
720 }
a61af66fc99e Initial load
duke
parents:
diff changeset
721
a61af66fc99e Initial load
duke
parents:
diff changeset
722 size_t OneContigSpaceCardGeneration::contiguous_available() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
723 return _the_space->free() + _virtual_space.uncommitted_size();
a61af66fc99e Initial load
duke
parents:
diff changeset
724 }
a61af66fc99e Initial load
duke
parents:
diff changeset
725
a61af66fc99e Initial load
duke
parents:
diff changeset
726 bool OneContigSpaceCardGeneration::grow_by(size_t bytes) {
a61af66fc99e Initial load
duke
parents:
diff changeset
727 assert_locked_or_safepoint(ExpandHeap_lock);
a61af66fc99e Initial load
duke
parents:
diff changeset
728 bool result = _virtual_space.expand_by(bytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
729 if (result) {
a61af66fc99e Initial load
duke
parents:
diff changeset
730 size_t new_word_size =
a61af66fc99e Initial load
duke
parents:
diff changeset
731 heap_word_size(_virtual_space.committed_size());
a61af66fc99e Initial load
duke
parents:
diff changeset
732 MemRegion mr(_the_space->bottom(), new_word_size);
a61af66fc99e Initial load
duke
parents:
diff changeset
733 // Expand card table
a61af66fc99e Initial load
duke
parents:
diff changeset
734 Universe::heap()->barrier_set()->resize_covered_region(mr);
a61af66fc99e Initial load
duke
parents:
diff changeset
735 // Expand shared block offset array
a61af66fc99e Initial load
duke
parents:
diff changeset
736 _bts->resize(new_word_size);
a61af66fc99e Initial load
duke
parents:
diff changeset
737
a61af66fc99e Initial load
duke
parents:
diff changeset
738 // Fix for bug #4668531
263
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 113
diff changeset
739 if (ZapUnusedHeapArea) {
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 113
diff changeset
740 MemRegion mangle_region(_the_space->end(),
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 113
diff changeset
741 (HeapWord*)_virtual_space.high());
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 113
diff changeset
742 SpaceMangler::mangle_region(mangle_region);
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 113
diff changeset
743 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
744
a61af66fc99e Initial load
duke
parents:
diff changeset
745 // Expand space -- also expands space's BOT
a61af66fc99e Initial load
duke
parents:
diff changeset
746 // (which uses (part of) shared array above)
a61af66fc99e Initial load
duke
parents:
diff changeset
747 _the_space->set_end((HeapWord*)_virtual_space.high());
a61af66fc99e Initial load
duke
parents:
diff changeset
748
a61af66fc99e Initial load
duke
parents:
diff changeset
749 // update the space and generation capacity counters
a61af66fc99e Initial load
duke
parents:
diff changeset
750 update_counters();
a61af66fc99e Initial load
duke
parents:
diff changeset
751
a61af66fc99e Initial load
duke
parents:
diff changeset
752 if (Verbose && PrintGC) {
a61af66fc99e Initial load
duke
parents:
diff changeset
753 size_t new_mem_size = _virtual_space.committed_size();
a61af66fc99e Initial load
duke
parents:
diff changeset
754 size_t old_mem_size = new_mem_size - bytes;
a61af66fc99e Initial load
duke
parents:
diff changeset
755 gclog_or_tty->print_cr("Expanding %s from " SIZE_FORMAT "K by "
a61af66fc99e Initial load
duke
parents:
diff changeset
756 SIZE_FORMAT "K to " SIZE_FORMAT "K",
a61af66fc99e Initial load
duke
parents:
diff changeset
757 name(), old_mem_size/K, bytes/K, new_mem_size/K);
a61af66fc99e Initial load
duke
parents:
diff changeset
758 }
a61af66fc99e Initial load
duke
parents:
diff changeset
759 }
a61af66fc99e Initial load
duke
parents:
diff changeset
760 return result;
a61af66fc99e Initial load
duke
parents:
diff changeset
761 }
a61af66fc99e Initial load
duke
parents:
diff changeset
762
a61af66fc99e Initial load
duke
parents:
diff changeset
763
a61af66fc99e Initial load
duke
parents:
diff changeset
764 bool OneContigSpaceCardGeneration::grow_to_reserved() {
a61af66fc99e Initial load
duke
parents:
diff changeset
765 assert_locked_or_safepoint(ExpandHeap_lock);
a61af66fc99e Initial load
duke
parents:
diff changeset
766 bool success = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
767 const size_t remaining_bytes = _virtual_space.uncommitted_size();
a61af66fc99e Initial load
duke
parents:
diff changeset
768 if (remaining_bytes > 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
769 success = grow_by(remaining_bytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
770 DEBUG_ONLY(if (!success) warning("grow to reserved failed");)
a61af66fc99e Initial load
duke
parents:
diff changeset
771 }
a61af66fc99e Initial load
duke
parents:
diff changeset
772 return success;
a61af66fc99e Initial load
duke
parents:
diff changeset
773 }
a61af66fc99e Initial load
duke
parents:
diff changeset
774
a61af66fc99e Initial load
duke
parents:
diff changeset
775 void OneContigSpaceCardGeneration::shrink_by(size_t bytes) {
a61af66fc99e Initial load
duke
parents:
diff changeset
776 assert_locked_or_safepoint(ExpandHeap_lock);
a61af66fc99e Initial load
duke
parents:
diff changeset
777 // Shrink committed space
a61af66fc99e Initial load
duke
parents:
diff changeset
778 _virtual_space.shrink_by(bytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
779 // Shrink space; this also shrinks the space's BOT
a61af66fc99e Initial load
duke
parents:
diff changeset
780 _the_space->set_end((HeapWord*) _virtual_space.high());
a61af66fc99e Initial load
duke
parents:
diff changeset
781 size_t new_word_size = heap_word_size(_the_space->capacity());
a61af66fc99e Initial load
duke
parents:
diff changeset
782 // Shrink the shared block offset array
a61af66fc99e Initial load
duke
parents:
diff changeset
783 _bts->resize(new_word_size);
a61af66fc99e Initial load
duke
parents:
diff changeset
784 MemRegion mr(_the_space->bottom(), new_word_size);
a61af66fc99e Initial load
duke
parents:
diff changeset
785 // Shrink the card table
a61af66fc99e Initial load
duke
parents:
diff changeset
786 Universe::heap()->barrier_set()->resize_covered_region(mr);
a61af66fc99e Initial load
duke
parents:
diff changeset
787
a61af66fc99e Initial load
duke
parents:
diff changeset
788 if (Verbose && PrintGC) {
a61af66fc99e Initial load
duke
parents:
diff changeset
789 size_t new_mem_size = _virtual_space.committed_size();
a61af66fc99e Initial load
duke
parents:
diff changeset
790 size_t old_mem_size = new_mem_size + bytes;
a61af66fc99e Initial load
duke
parents:
diff changeset
791 gclog_or_tty->print_cr("Shrinking %s from " SIZE_FORMAT "K to " SIZE_FORMAT "K",
a61af66fc99e Initial load
duke
parents:
diff changeset
792 name(), old_mem_size/K, new_mem_size/K);
a61af66fc99e Initial load
duke
parents:
diff changeset
793 }
a61af66fc99e Initial load
duke
parents:
diff changeset
794 }
a61af66fc99e Initial load
duke
parents:
diff changeset
795
a61af66fc99e Initial load
duke
parents:
diff changeset
796 // Currently nothing to do.
a61af66fc99e Initial load
duke
parents:
diff changeset
797 void OneContigSpaceCardGeneration::prepare_for_verify() {}
a61af66fc99e Initial load
duke
parents:
diff changeset
798
a61af66fc99e Initial load
duke
parents:
diff changeset
799
1051
26f1542097f1 6801625: CDS: HeapDump tests crash with internal error in compactingPermGenGen.cpp
ysr
parents: 579
diff changeset
800 // Override for a card-table generation with one contiguous
26f1542097f1 6801625: CDS: HeapDump tests crash with internal error in compactingPermGenGen.cpp
ysr
parents: 579
diff changeset
801 // space. NOTE: For reasons that are lost in the fog of history,
26f1542097f1 6801625: CDS: HeapDump tests crash with internal error in compactingPermGenGen.cpp
ysr
parents: 579
diff changeset
802 // this code is used when you iterate over perm gen objects,
26f1542097f1 6801625: CDS: HeapDump tests crash with internal error in compactingPermGenGen.cpp
ysr
parents: 579
diff changeset
803 // even when one uses CDS, where the perm gen has a couple of
26f1542097f1 6801625: CDS: HeapDump tests crash with internal error in compactingPermGenGen.cpp
ysr
parents: 579
diff changeset
804 // other spaces; this is because CompactingPermGenGen derives
26f1542097f1 6801625: CDS: HeapDump tests crash with internal error in compactingPermGenGen.cpp
ysr
parents: 579
diff changeset
805 // from OneContigSpaceCardGeneration. This should be cleaned up,
26f1542097f1 6801625: CDS: HeapDump tests crash with internal error in compactingPermGenGen.cpp
ysr
parents: 579
diff changeset
806 // see CR 6897789..
0
a61af66fc99e Initial load
duke
parents:
diff changeset
807 void OneContigSpaceCardGeneration::object_iterate(ObjectClosure* blk) {
a61af66fc99e Initial load
duke
parents:
diff changeset
808 _the_space->object_iterate(blk);
a61af66fc99e Initial load
duke
parents:
diff changeset
809 }
a61af66fc99e Initial load
duke
parents:
diff changeset
810
a61af66fc99e Initial load
duke
parents:
diff changeset
811 void OneContigSpaceCardGeneration::space_iterate(SpaceClosure* blk,
a61af66fc99e Initial load
duke
parents:
diff changeset
812 bool usedOnly) {
a61af66fc99e Initial load
duke
parents:
diff changeset
813 blk->do_space(_the_space);
a61af66fc99e Initial load
duke
parents:
diff changeset
814 }
a61af66fc99e Initial load
duke
parents:
diff changeset
815
a61af66fc99e Initial load
duke
parents:
diff changeset
816 void OneContigSpaceCardGeneration::younger_refs_iterate(OopsInGenClosure* blk) {
a61af66fc99e Initial load
duke
parents:
diff changeset
817 blk->set_generation(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
818 younger_refs_in_space_iterate(_the_space, blk);
a61af66fc99e Initial load
duke
parents:
diff changeset
819 blk->reset_generation();
a61af66fc99e Initial load
duke
parents:
diff changeset
820 }
a61af66fc99e Initial load
duke
parents:
diff changeset
821
a61af66fc99e Initial load
duke
parents:
diff changeset
822 void OneContigSpaceCardGeneration::save_marks() {
a61af66fc99e Initial load
duke
parents:
diff changeset
823 _the_space->set_saved_mark();
a61af66fc99e Initial load
duke
parents:
diff changeset
824 }
a61af66fc99e Initial load
duke
parents:
diff changeset
825
a61af66fc99e Initial load
duke
parents:
diff changeset
826
a61af66fc99e Initial load
duke
parents:
diff changeset
827 void OneContigSpaceCardGeneration::reset_saved_marks() {
a61af66fc99e Initial load
duke
parents:
diff changeset
828 _the_space->reset_saved_mark();
a61af66fc99e Initial load
duke
parents:
diff changeset
829 }
a61af66fc99e Initial load
duke
parents:
diff changeset
830
a61af66fc99e Initial load
duke
parents:
diff changeset
831
a61af66fc99e Initial load
duke
parents:
diff changeset
832 bool OneContigSpaceCardGeneration::no_allocs_since_save_marks() {
a61af66fc99e Initial load
duke
parents:
diff changeset
833 return _the_space->saved_mark_at_top();
a61af66fc99e Initial load
duke
parents:
diff changeset
834 }
a61af66fc99e Initial load
duke
parents:
diff changeset
835
a61af66fc99e Initial load
duke
parents:
diff changeset
836 #define OneContig_SINCE_SAVE_MARKS_ITERATE_DEFN(OopClosureType, nv_suffix) \
a61af66fc99e Initial load
duke
parents:
diff changeset
837 \
a61af66fc99e Initial load
duke
parents:
diff changeset
838 void OneContigSpaceCardGeneration:: \
a61af66fc99e Initial load
duke
parents:
diff changeset
839 oop_since_save_marks_iterate##nv_suffix(OopClosureType* blk) { \
a61af66fc99e Initial load
duke
parents:
diff changeset
840 blk->set_generation(this); \
a61af66fc99e Initial load
duke
parents:
diff changeset
841 _the_space->oop_since_save_marks_iterate##nv_suffix(blk); \
a61af66fc99e Initial load
duke
parents:
diff changeset
842 blk->reset_generation(); \
a61af66fc99e Initial load
duke
parents:
diff changeset
843 save_marks(); \
a61af66fc99e Initial load
duke
parents:
diff changeset
844 }
a61af66fc99e Initial load
duke
parents:
diff changeset
845
a61af66fc99e Initial load
duke
parents:
diff changeset
846 ALL_SINCE_SAVE_MARKS_CLOSURES(OneContig_SINCE_SAVE_MARKS_ITERATE_DEFN)
a61af66fc99e Initial load
duke
parents:
diff changeset
847
a61af66fc99e Initial load
duke
parents:
diff changeset
848 #undef OneContig_SINCE_SAVE_MARKS_ITERATE_DEFN
a61af66fc99e Initial load
duke
parents:
diff changeset
849
a61af66fc99e Initial load
duke
parents:
diff changeset
850
a61af66fc99e Initial load
duke
parents:
diff changeset
851 void OneContigSpaceCardGeneration::gc_epilogue(bool full) {
a61af66fc99e Initial load
duke
parents:
diff changeset
852 _last_gc = WaterMark(the_space(), the_space()->top());
a61af66fc99e Initial load
duke
parents:
diff changeset
853
a61af66fc99e Initial load
duke
parents:
diff changeset
854 // update the generation and space performance counters
a61af66fc99e Initial load
duke
parents:
diff changeset
855 update_counters();
263
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 113
diff changeset
856 if (ZapUnusedHeapArea) {
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 113
diff changeset
857 the_space()->check_mangled_unused_area_complete();
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 113
diff changeset
858 }
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 113
diff changeset
859 }
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 113
diff changeset
860
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 113
diff changeset
861 void OneContigSpaceCardGeneration::record_spaces_top() {
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 113
diff changeset
862 assert(ZapUnusedHeapArea, "Not mangling unused space");
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 113
diff changeset
863 the_space()->set_top_for_allocations();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
864 }
a61af66fc99e Initial load
duke
parents:
diff changeset
865
6008
b632e80fc9dc 4988100: oop_verify_old_oop appears to be dead
brutisso
parents: 2369
diff changeset
866 void OneContigSpaceCardGeneration::verify() {
b632e80fc9dc 4988100: oop_verify_old_oop appears to be dead
brutisso
parents: 2369
diff changeset
867 the_space()->verify();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
868 }
a61af66fc99e Initial load
duke
parents:
diff changeset
869
a61af66fc99e Initial load
duke
parents:
diff changeset
870 void OneContigSpaceCardGeneration::print_on(outputStream* st) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
871 Generation::print_on(st);
a61af66fc99e Initial load
duke
parents:
diff changeset
872 st->print(" the");
a61af66fc99e Initial load
duke
parents:
diff changeset
873 the_space()->print_on(st);
a61af66fc99e Initial load
duke
parents:
diff changeset
874 }