author | bpittore |
Wed, 24 Jun 2015 12:12:25 -0400 | |
changeset 31592 | 43f48e165466 |
parent 30764 | fec48bf5a827 |
child 33105 | 294e48b4f704 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
30264
142414794deb
8077265: Modify assert to help debug JDK-8068448
ecaspole
parents:
22551
diff
changeset
|
2 |
* Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved. |
1 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5402
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5402
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5402
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
30764 | 25 |
#ifndef SHARE_VM_GC_PARALLEL_PSOLDGEN_HPP |
26 |
#define SHARE_VM_GC_PARALLEL_PSOLDGEN_HPP |
|
7397 | 27 |
|
30764 | 28 |
#include "gc/parallel/mutableSpace.hpp" |
29 |
#include "gc/parallel/objectStartArray.hpp" |
|
30 |
#include "gc/parallel/psGenerationCounters.hpp" |
|
31 |
#include "gc/parallel/psVirtualspace.hpp" |
|
32 |
#include "gc/parallel/spaceCounters.hpp" |
|
7397 | 33 |
#include "runtime/safepoint.hpp" |
34 |
||
1 | 35 |
class PSMarkSweepDecorator; |
36 |
||
13195 | 37 |
class PSOldGen : public CHeapObj<mtGC> { |
1 | 38 |
friend class VMStructs; |
39 |
friend class PSPromotionManager; // Uses the cas_allocate methods |
|
40 |
friend class ParallelScavengeHeap; |
|
41 |
friend class AdjoiningGenerations; |
|
42 |
||
43 |
protected: |
|
44 |
MemRegion _reserved; // Used for simple containment tests |
|
45 |
PSVirtualSpace* _virtual_space; // Controls mapping and unmapping of virtual mem |
|
46 |
ObjectStartArray _start_array; // Keeps track of where objects start in a 512b block |
|
47 |
MutableSpace* _object_space; // Where all the objects live |
|
48 |
PSMarkSweepDecorator* _object_mark_sweep; // The mark sweep view of _object_space |
|
49 |
const char* const _name; // Name of this generation. |
|
50 |
||
51 |
// Performance Counters |
|
52 |
PSGenerationCounters* _gen_counters; |
|
53 |
SpaceCounters* _space_counters; |
|
54 |
||
55 |
// Sizing information, in bytes, set in constructor |
|
56 |
const size_t _init_gen_size; |
|
57 |
const size_t _min_gen_size; |
|
58 |
const size_t _max_gen_size; |
|
59 |
||
60 |
// Used when initializing the _name field. |
|
61 |
static inline const char* select_name(); |
|
62 |
||
30264
142414794deb
8077265: Modify assert to help debug JDK-8068448
ecaspole
parents:
22551
diff
changeset
|
63 |
#ifdef ASSERT |
142414794deb
8077265: Modify assert to help debug JDK-8068448
ecaspole
parents:
22551
diff
changeset
|
64 |
void assert_block_in_covered_region(MemRegion new_memregion) { |
142414794deb
8077265: Modify assert to help debug JDK-8068448
ecaspole
parents:
22551
diff
changeset
|
65 |
// Explictly capture current covered_region in a local |
142414794deb
8077265: Modify assert to help debug JDK-8068448
ecaspole
parents:
22551
diff
changeset
|
66 |
MemRegion covered_region = this->start_array()->covered_region(); |
142414794deb
8077265: Modify assert to help debug JDK-8068448
ecaspole
parents:
22551
diff
changeset
|
67 |
assert(covered_region.contains(new_memregion), |
31592
43f48e165466
8081202: Hotspot compile warning: "Invalid suffix on literal; C++11 requires a space between literal and identifier"
bpittore
parents:
30764
diff
changeset
|
68 |
err_msg("new region is not in covered_region [ " PTR_FORMAT ", " PTR_FORMAT " ], " |
43f48e165466
8081202: Hotspot compile warning: "Invalid suffix on literal; C++11 requires a space between literal and identifier"
bpittore
parents:
30764
diff
changeset
|
69 |
"new region [ " PTR_FORMAT ", " PTR_FORMAT " ], " |
43f48e165466
8081202: Hotspot compile warning: "Invalid suffix on literal; C++11 requires a space between literal and identifier"
bpittore
parents:
30764
diff
changeset
|
70 |
"object space [ " PTR_FORMAT ", " PTR_FORMAT " ]", |
30264
142414794deb
8077265: Modify assert to help debug JDK-8068448
ecaspole
parents:
22551
diff
changeset
|
71 |
p2i(covered_region.start()), |
142414794deb
8077265: Modify assert to help debug JDK-8068448
ecaspole
parents:
22551
diff
changeset
|
72 |
p2i(covered_region.end()), |
142414794deb
8077265: Modify assert to help debug JDK-8068448
ecaspole
parents:
22551
diff
changeset
|
73 |
p2i(new_memregion.start()), |
142414794deb
8077265: Modify assert to help debug JDK-8068448
ecaspole
parents:
22551
diff
changeset
|
74 |
p2i(new_memregion.end()), |
142414794deb
8077265: Modify assert to help debug JDK-8068448
ecaspole
parents:
22551
diff
changeset
|
75 |
p2i(this->object_space()->used_region().start()), |
142414794deb
8077265: Modify assert to help debug JDK-8068448
ecaspole
parents:
22551
diff
changeset
|
76 |
p2i(this->object_space()->used_region().end()))); |
142414794deb
8077265: Modify assert to help debug JDK-8068448
ecaspole
parents:
22551
diff
changeset
|
77 |
} |
142414794deb
8077265: Modify assert to help debug JDK-8068448
ecaspole
parents:
22551
diff
changeset
|
78 |
#endif |
142414794deb
8077265: Modify assert to help debug JDK-8068448
ecaspole
parents:
22551
diff
changeset
|
79 |
|
9997
b75b7939f448
6994322: Remove the is_tlab and is_noref / is_large_noref parameters from the CollectedHeap
tonyp
parents:
9178
diff
changeset
|
80 |
HeapWord* allocate_noexpand(size_t word_size) { |
1 | 81 |
// We assume the heap lock is held here. |
82 |
assert_locked_or_safepoint(Heap_lock); |
|
83 |
HeapWord* res = object_space()->allocate(word_size); |
|
84 |
if (res != NULL) { |
|
30264
142414794deb
8077265: Modify assert to help debug JDK-8068448
ecaspole
parents:
22551
diff
changeset
|
85 |
DEBUG_ONLY(assert_block_in_covered_region(MemRegion(res, word_size))); |
1 | 86 |
_start_array.allocate_block(res); |
87 |
} |
|
88 |
return res; |
|
89 |
} |
|
90 |
||
91 |
// Support for MT garbage collection. CAS allocation is lower overhead than grabbing |
|
92 |
// and releasing the heap lock, which is held during gc's anyway. This method is not |
|
93 |
// safe for use at the same time as allocate_noexpand()! |
|
94 |
HeapWord* cas_allocate_noexpand(size_t word_size) { |
|
5402
c51fd0c1d005
6888953: some calls to function-like macros are missing semicolons
jcoomes
parents:
1217
diff
changeset
|
95 |
assert(SafepointSynchronize::is_at_safepoint(), "Must only be called at safepoint"); |
1 | 96 |
HeapWord* res = object_space()->cas_allocate(word_size); |
97 |
if (res != NULL) { |
|
30264
142414794deb
8077265: Modify assert to help debug JDK-8068448
ecaspole
parents:
22551
diff
changeset
|
98 |
DEBUG_ONLY(assert_block_in_covered_region(MemRegion(res, word_size))); |
1 | 99 |
_start_array.allocate_block(res); |
100 |
} |
|
101 |
return res; |
|
102 |
} |
|
103 |
||
104 |
// Support for MT garbage collection. See above comment. |
|
105 |
HeapWord* cas_allocate(size_t word_size) { |
|
106 |
HeapWord* res = cas_allocate_noexpand(word_size); |
|
107 |
return (res == NULL) ? expand_and_cas_allocate(word_size) : res; |
|
108 |
} |
|
109 |
||
9997
b75b7939f448
6994322: Remove the is_tlab and is_noref / is_large_noref parameters from the CollectedHeap
tonyp
parents:
9178
diff
changeset
|
110 |
HeapWord* expand_and_allocate(size_t word_size); |
1 | 111 |
HeapWord* expand_and_cas_allocate(size_t word_size); |
112 |
void expand(size_t bytes); |
|
113 |
bool expand_by(size_t bytes); |
|
114 |
bool expand_to_reserved(); |
|
115 |
||
116 |
void shrink(size_t bytes); |
|
117 |
||
118 |
void post_resize(); |
|
119 |
||
120 |
public: |
|
121 |
// Initialize the generation. |
|
122 |
PSOldGen(ReservedSpace rs, size_t alignment, |
|
123 |
size_t initial_size, size_t min_size, size_t max_size, |
|
124 |
const char* perf_data_name, int level); |
|
125 |
||
126 |
PSOldGen(size_t initial_size, size_t min_size, size_t max_size, |
|
127 |
const char* perf_data_name, int level); |
|
128 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
129 |
virtual void initialize(ReservedSpace rs, size_t alignment, |
1 | 130 |
const char* perf_data_name, int level); |
131 |
void initialize_virtual_space(ReservedSpace rs, size_t alignment); |
|
18443 | 132 |
virtual void initialize_work(const char* perf_data_name, int level); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
133 |
virtual void initialize_performance_counters(const char* perf_data_name, int level); |
1 | 134 |
|
135 |
MemRegion reserved() const { return _reserved; } |
|
136 |
virtual size_t max_gen_size() { return _max_gen_size; } |
|
137 |
size_t min_gen_size() { return _min_gen_size; } |
|
138 |
||
139 |
// Returns limit on the maximum size of the generation. This |
|
140 |
// is the same as _max_gen_size for PSOldGen but need not be |
|
141 |
// for a derived class. |
|
142 |
virtual size_t gen_size_limit(); |
|
143 |
||
144 |
bool is_in(const void* p) const { |
|
145 |
return _virtual_space->contains((void *)p); |
|
146 |
} |
|
147 |
||
148 |
bool is_in_reserved(const void* p) const { |
|
149 |
return reserved().contains(p); |
|
150 |
} |
|
151 |
||
152 |
MutableSpace* object_space() const { return _object_space; } |
|
153 |
PSMarkSweepDecorator* object_mark_sweep() const { return _object_mark_sweep; } |
|
154 |
ObjectStartArray* start_array() { return &_start_array; } |
|
155 |
PSVirtualSpace* virtual_space() const { return _virtual_space;} |
|
156 |
||
157 |
// Has the generation been successfully allocated? |
|
158 |
bool is_allocated(); |
|
159 |
||
160 |
// MarkSweep methods |
|
161 |
virtual void precompact(); |
|
162 |
void adjust_pointers(); |
|
163 |
void compact(); |
|
164 |
||
165 |
// Size info |
|
166 |
size_t capacity_in_bytes() const { return object_space()->capacity_in_bytes(); } |
|
167 |
size_t used_in_bytes() const { return object_space()->used_in_bytes(); } |
|
168 |
size_t free_in_bytes() const { return object_space()->free_in_bytes(); } |
|
169 |
||
170 |
size_t capacity_in_words() const { return object_space()->capacity_in_words(); } |
|
171 |
size_t used_in_words() const { return object_space()->used_in_words(); } |
|
172 |
size_t free_in_words() const { return object_space()->free_in_words(); } |
|
173 |
||
174 |
// Includes uncommitted memory |
|
175 |
size_t contiguous_available() const; |
|
176 |
||
177 |
bool is_maximal_no_gc() const { |
|
178 |
return virtual_space()->uncommitted_size() == 0; |
|
179 |
} |
|
180 |
||
181 |
// Calculating new sizes |
|
182 |
void resize(size_t desired_free_space); |
|
183 |
||
184 |
// Allocation. We report all successful allocations to the size policy |
|
185 |
// Note that the perm gen does not use this method, and should not! |
|
9997
b75b7939f448
6994322: Remove the is_tlab and is_noref / is_large_noref parameters from the CollectedHeap
tonyp
parents:
9178
diff
changeset
|
186 |
HeapWord* allocate(size_t word_size); |
1 | 187 |
|
188 |
// Iteration. |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
189 |
void oop_iterate_no_header(OopClosure* cl) { object_space()->oop_iterate_no_header(cl); } |
1 | 190 |
void object_iterate(ObjectClosure* cl) { object_space()->object_iterate(cl); } |
191 |
||
192 |
// Debugging - do not use for time critical operations |
|
193 |
virtual void print() const; |
|
194 |
virtual void print_on(outputStream* st) const; |
|
195 |
void print_used_change(size_t prev_used) const; |
|
196 |
||
12379 | 197 |
void verify(); |
1 | 198 |
void verify_object_start_array(); |
199 |
||
200 |
// These should not used |
|
201 |
virtual void reset_after_change(); |
|
202 |
||
203 |
// These should not used |
|
204 |
virtual size_t available_for_expansion(); |
|
205 |
virtual size_t available_for_contraction(); |
|
206 |
||
207 |
void space_invariants() PRODUCT_RETURN; |
|
208 |
||
22551 | 209 |
// Performance Counter support |
1 | 210 |
void update_counters(); |
211 |
||
212 |
// Printing support |
|
213 |
virtual const char* name() const { return _name; } |
|
971
f0b20be4165d
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
1
diff
changeset
|
214 |
|
f0b20be4165d
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
1
diff
changeset
|
215 |
// Debugging support |
f0b20be4165d
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
1
diff
changeset
|
216 |
// Save the tops of all spaces for later use during mangling. |
f0b20be4165d
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
1
diff
changeset
|
217 |
void record_spaces_top() PRODUCT_RETURN; |
1 | 218 |
}; |
7397 | 219 |
|
30764 | 220 |
#endif // SHARE_VM_GC_PARALLEL_PSOLDGEN_HPP |