Mercurial > hg > truffle
annotate src/share/vm/gc_implementation/parallelScavenge/psOldGen.hpp @ 3687:7958ebb561b0
Merge
author | Lukas Stadler <lukas.stadler@jku.at> |
---|---|
date | Fri, 18 Nov 2011 17:20:38 +0100 |
parents | eda9eb483d29 |
children | c9ca3f51cf41 |
rev | line source |
---|---|
0 | 1 /* |
3251
eda9eb483d29
6841742: par compact - remove unused/unsupported options
jcoomes
parents:
1972
diff
changeset
|
2 * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved. |
0 | 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 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1489
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1489
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1489
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
1972 | 25 #ifndef SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSOLDGEN_HPP |
26 #define SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSOLDGEN_HPP | |
27 | |
28 #include "gc_implementation/parallelScavenge/objectStartArray.hpp" | |
29 #include "gc_implementation/parallelScavenge/psGenerationCounters.hpp" | |
30 #include "gc_implementation/parallelScavenge/psVirtualspace.hpp" | |
31 #include "gc_implementation/shared/mutableSpace.hpp" | |
32 #include "gc_implementation/shared/spaceCounters.hpp" | |
33 #include "runtime/safepoint.hpp" | |
34 | |
0 | 35 class PSMarkSweepDecorator; |
36 | |
37 class PSOldGen : public CHeapObj { | |
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 | |
63 HeapWord* allocate_noexpand(size_t word_size, bool is_tlab) { | |
64 // We assume the heap lock is held here. | |
65 assert(!is_tlab, "Does not support TLAB allocation"); | |
66 assert_locked_or_safepoint(Heap_lock); | |
67 HeapWord* res = object_space()->allocate(word_size); | |
68 if (res != NULL) { | |
69 _start_array.allocate_block(res); | |
70 } | |
71 return res; | |
72 } | |
73 | |
74 // Support for MT garbage collection. CAS allocation is lower overhead than grabbing | |
75 // and releasing the heap lock, which is held during gc's anyway. This method is not | |
76 // safe for use at the same time as allocate_noexpand()! | |
77 HeapWord* cas_allocate_noexpand(size_t word_size) { | |
1489
cff162798819
6888953: some calls to function-like macros are missing semicolons
jcoomes
parents:
337
diff
changeset
|
78 assert(SafepointSynchronize::is_at_safepoint(), "Must only be called at safepoint"); |
0 | 79 HeapWord* res = object_space()->cas_allocate(word_size); |
80 if (res != NULL) { | |
81 _start_array.allocate_block(res); | |
82 } | |
83 return res; | |
84 } | |
85 | |
86 // Support for MT garbage collection. See above comment. | |
87 HeapWord* cas_allocate(size_t word_size) { | |
88 HeapWord* res = cas_allocate_noexpand(word_size); | |
89 return (res == NULL) ? expand_and_cas_allocate(word_size) : res; | |
90 } | |
91 | |
92 HeapWord* expand_and_allocate(size_t word_size, bool is_tlab); | |
93 HeapWord* expand_and_cas_allocate(size_t word_size); | |
94 void expand(size_t bytes); | |
95 bool expand_by(size_t bytes); | |
96 bool expand_to_reserved(); | |
97 | |
98 void shrink(size_t bytes); | |
99 | |
100 void post_resize(); | |
101 | |
102 public: | |
103 // Initialize the generation. | |
104 PSOldGen(ReservedSpace rs, size_t alignment, | |
105 size_t initial_size, size_t min_size, size_t max_size, | |
106 const char* perf_data_name, int level); | |
107 | |
108 PSOldGen(size_t initial_size, size_t min_size, size_t max_size, | |
109 const char* perf_data_name, int level); | |
110 | |
111 void initialize(ReservedSpace rs, size_t alignment, | |
112 const char* perf_data_name, int level); | |
113 void initialize_virtual_space(ReservedSpace rs, size_t alignment); | |
114 void initialize_work(const char* perf_data_name, int level); | |
115 | |
116 MemRegion reserved() const { return _reserved; } | |
117 virtual size_t max_gen_size() { return _max_gen_size; } | |
118 size_t min_gen_size() { return _min_gen_size; } | |
119 | |
120 // Returns limit on the maximum size of the generation. This | |
121 // is the same as _max_gen_size for PSOldGen but need not be | |
122 // for a derived class. | |
123 virtual size_t gen_size_limit(); | |
124 | |
125 bool is_in(const void* p) const { | |
126 return _virtual_space->contains((void *)p); | |
127 } | |
128 | |
129 bool is_in_reserved(const void* p) const { | |
130 return reserved().contains(p); | |
131 } | |
132 | |
133 MutableSpace* object_space() const { return _object_space; } | |
134 PSMarkSweepDecorator* object_mark_sweep() const { return _object_mark_sweep; } | |
135 ObjectStartArray* start_array() { return &_start_array; } | |
136 PSVirtualSpace* virtual_space() const { return _virtual_space;} | |
137 | |
138 // Has the generation been successfully allocated? | |
139 bool is_allocated(); | |
140 | |
141 // MarkSweep methods | |
142 virtual void precompact(); | |
143 void adjust_pointers(); | |
144 void compact(); | |
145 | |
146 // Size info | |
147 size_t capacity_in_bytes() const { return object_space()->capacity_in_bytes(); } | |
148 size_t used_in_bytes() const { return object_space()->used_in_bytes(); } | |
149 size_t free_in_bytes() const { return object_space()->free_in_bytes(); } | |
150 | |
151 size_t capacity_in_words() const { return object_space()->capacity_in_words(); } | |
152 size_t used_in_words() const { return object_space()->used_in_words(); } | |
153 size_t free_in_words() const { return object_space()->free_in_words(); } | |
154 | |
155 // Includes uncommitted memory | |
156 size_t contiguous_available() const; | |
157 | |
158 bool is_maximal_no_gc() const { | |
159 return virtual_space()->uncommitted_size() == 0; | |
160 } | |
161 | |
162 // Calculating new sizes | |
163 void resize(size_t desired_free_space); | |
164 | |
165 // Allocation. We report all successful allocations to the size policy | |
166 // Note that the perm gen does not use this method, and should not! | |
167 HeapWord* allocate(size_t word_size, bool is_tlab); | |
168 | |
169 // Iteration. | |
170 void oop_iterate(OopClosure* cl) { object_space()->oop_iterate(cl); } | |
171 void object_iterate(ObjectClosure* cl) { object_space()->object_iterate(cl); } | |
172 | |
173 // Debugging - do not use for time critical operations | |
174 virtual void print() const; | |
175 virtual void print_on(outputStream* st) const; | |
176 void print_used_change(size_t prev_used) const; | |
177 | |
178 void verify(bool allow_dirty); | |
179 void verify_object_start_array(); | |
180 | |
181 // These should not used | |
182 virtual void reset_after_change(); | |
183 | |
184 // These should not used | |
185 virtual size_t available_for_expansion(); | |
186 virtual size_t available_for_contraction(); | |
187 | |
188 void space_invariants() PRODUCT_RETURN; | |
189 | |
190 // Performace Counter support | |
191 void update_counters(); | |
192 | |
193 // Printing support | |
194 virtual const char* name() const { return _name; } | |
263
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
0
diff
changeset
|
195 |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
0
diff
changeset
|
196 // Debugging support |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
0
diff
changeset
|
197 // Save the tops of all spaces for later use during mangling. |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
0
diff
changeset
|
198 void record_spaces_top() PRODUCT_RETURN; |
0 | 199 }; |
1972 | 200 |
201 #endif // SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSOLDGEN_HPP |