Print this page
rev 4535 : 6725714: par compact - add a table to speed up bitmap searches
Reviewed-by: jmasa, tschatzl
Split |
Split |
Close |
Expand all |
Collapse all |
--- old/src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.hpp
+++ new/src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.hpp
1 1 /*
2 2 * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 4 *
5 5 * This code is free software; you can redistribute it and/or modify it
6 6 * under the terms of the GNU General Public License version 2 only, as
7 7 * published by the Free Software Foundation.
8 8 *
9 9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 12 * version 2 for more details (a copy is included in the LICENSE file that
13 13 * accompanied this code).
14 14 *
15 15 * You should have received a copy of the GNU General Public License version
16 16 * 2 along with this work; if not, write to the Free Software Foundation,
17 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 18 *
19 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 20 * or visit www.oracle.com if you need additional information or have any
21 21 * questions.
22 22 *
23 23 */
24 24
25 25 #ifndef SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PARALLELSCAVENGEHEAP_HPP
26 26 #define SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PARALLELSCAVENGEHEAP_HPP
27 27
28 28 #include "gc_implementation/parallelScavenge/objectStartArray.hpp"
29 29 #include "gc_implementation/parallelScavenge/psGCAdaptivePolicyCounters.hpp"
30 30 #include "gc_implementation/parallelScavenge/psOldGen.hpp"
31 31 #include "gc_implementation/parallelScavenge/psPermGen.hpp"
32 32 #include "gc_implementation/parallelScavenge/psYoungGen.hpp"
33 33 #include "gc_implementation/shared/gcPolicyCounters.hpp"
34 34 #include "gc_interface/collectedHeap.inline.hpp"
35 35 #include "utilities/ostream.hpp"
36 36
37 37 class AdjoiningGenerations;
38 38 class CollectorPolicy;
39 39 class GCHeapSummary;
40 40 class GCTaskManager;
41 41 class GenerationSizer;
42 42 class CollectorPolicy;
43 43 class PSAdaptiveSizePolicy;
44 44 class PSHeapSummary;
45 45 class VirtualSpaceSummary;
46 46
47 47 class ParallelScavengeHeap : public CollectedHeap {
48 48 friend class VMStructs;
49 49 private:
50 50 static PSYoungGen* _young_gen;
51 51 static PSOldGen* _old_gen;
52 52 static PSPermGen* _perm_gen;
53 53
54 54 // Sizing policy for entire heap
55 55 static PSAdaptiveSizePolicy* _size_policy;
56 56 static PSGCAdaptivePolicyCounters* _gc_policy_counters;
57 57
58 58 static ParallelScavengeHeap* _psh;
59 59
60 60 size_t _perm_gen_alignment;
61 61 size_t _young_gen_alignment;
62 62 size_t _old_gen_alignment;
63 63
64 64 GenerationSizer* _collector_policy;
65 65
66 66 inline size_t set_alignment(size_t& var, size_t val);
67 67
68 68 // Collection of generations that are adjacent in the
69 69 // space reserved for the heap.
70 70 AdjoiningGenerations* _gens;
71 71 unsigned int _death_march_count;
72 72
73 73 static GCTaskManager* _gc_task_manager; // The task manager.
74 74
75 75 void trace_heap(GCWhen::Type when, GCTracer* tracer);
76 76
77 77 protected:
78 78 static inline size_t total_invocations();
79 79 HeapWord* allocate_new_tlab(size_t size);
80 80
81 81 inline bool should_alloc_in_eden(size_t size) const;
82 82 inline void death_march_check(HeapWord* const result, size_t size);
83 83 HeapWord* mem_allocate_old_gen(size_t size);
84 84
85 85 public:
86 86 ParallelScavengeHeap() : CollectedHeap() {
87 87 _death_march_count = 0;
88 88 set_alignment(_perm_gen_alignment, intra_heap_alignment());
89 89 set_alignment(_young_gen_alignment, intra_heap_alignment());
90 90 set_alignment(_old_gen_alignment, intra_heap_alignment());
91 91 }
92 92
93 93 // For use by VM operations
94 94 enum CollectionType {
95 95 Scavenge,
96 96 MarkSweep
97 97 };
98 98
99 99 ParallelScavengeHeap::Name kind() const {
100 100 return CollectedHeap::ParallelScavengeHeap;
101 101 }
102 102
103 103 CollectorPolicy* collector_policy() const { return (CollectorPolicy*) _collector_policy; }
104 104 // GenerationSizer* collector_policy() const { return _collector_policy; }
105 105
106 106 static PSYoungGen* young_gen() { return _young_gen; }
107 107 static PSOldGen* old_gen() { return _old_gen; }
108 108 static PSPermGen* perm_gen() { return _perm_gen; }
109 109
110 110 virtual PSAdaptiveSizePolicy* size_policy() { return _size_policy; }
111 111
112 112 static PSGCAdaptivePolicyCounters* gc_policy_counters() { return _gc_policy_counters; }
113 113
114 114 static ParallelScavengeHeap* heap();
115 115
116 116 static GCTaskManager* const gc_task_manager() { return _gc_task_manager; }
117 117
118 118 AdjoiningGenerations* gens() { return _gens; }
119 119
120 120 // Returns JNI_OK on success
121 121 virtual jint initialize();
↓ open down ↓ |
121 lines elided |
↑ open up ↑ |
122 122
123 123 void post_initialize();
124 124 void update_counters();
125 125 // The alignment used for the various generations.
126 126 size_t perm_gen_alignment() const { return _perm_gen_alignment; }
127 127 size_t young_gen_alignment() const { return _young_gen_alignment; }
128 128 size_t old_gen_alignment() const { return _old_gen_alignment; }
129 129
130 130 // The alignment used for eden and survivors within the young gen
131 131 // and for boundary between young gen and old gen.
132 - size_t intra_heap_alignment() const { return 64 * K; }
132 + size_t intra_heap_alignment() const { return 64 * K * HeapWordSize; }
133 133
134 134 size_t capacity() const;
135 135 size_t used() const;
136 136
137 137 // Return "true" if all generations (but perm) have reached the
138 138 // maximal committed limit that they can reach, without a garbage
139 139 // collection.
140 140 virtual bool is_maximal_no_gc() const;
141 141
142 142 // Return true if the reference points to an object that
143 143 // can be moved in a partial collection. For currently implemented
144 144 // generational collectors that means during a collection of
145 145 // the young gen.
146 146 virtual bool is_scavengable(const void* addr);
147 147
148 148 // Does this heap support heap inspection? (+PrintClassHistogram)
149 149 bool supports_heap_inspection() const { return true; }
150 150
151 151 size_t permanent_capacity() const;
152 152 size_t permanent_used() const;
153 153
154 154 size_t max_capacity() const;
155 155
156 156 // Whether p is in the allocated part of the heap
157 157 bool is_in(const void* p) const;
158 158
159 159 bool is_in_reserved(const void* p) const;
160 160 bool is_in_permanent(const void *p) const { // reserved part
161 161 return perm_gen()->reserved().contains(p);
162 162 }
163 163
164 164 #ifdef ASSERT
165 165 virtual bool is_in_partial_collection(const void *p);
166 166 #endif
167 167
168 168 bool is_permanent(const void *p) const { // committed part
169 169 return perm_gen()->is_in(p);
170 170 }
171 171
172 172 inline bool is_in_young(oop p); // reserved part
173 173 inline bool is_in_old_or_perm(oop p); // reserved part
174 174
175 175 // Memory allocation. "gc_time_limit_was_exceeded" will
176 176 // be set to true if the adaptive size policy determine that
177 177 // an excessive amount of time is being spent doing collections
178 178 // and caused a NULL to be returned. If a NULL is not returned,
179 179 // "gc_time_limit_was_exceeded" has an undefined meaning.
180 180 HeapWord* mem_allocate(size_t size,
181 181 bool* gc_overhead_limit_was_exceeded);
182 182
183 183 // Allocation attempt(s) during a safepoint. It should never be called
184 184 // to allocate a new TLAB as this allocation might be satisfied out
185 185 // of the old generation.
186 186 HeapWord* failed_mem_allocate(size_t size);
187 187
188 188 HeapWord* permanent_mem_allocate(size_t size);
189 189 HeapWord* failed_permanent_mem_allocate(size_t size);
190 190
191 191 // Support for System.gc()
192 192 void collect(GCCause::Cause cause);
193 193
194 194 // This interface assumes that it's being called by the
195 195 // vm thread. It collects the heap assuming that the
196 196 // heap lock is already held and that we are executing in
197 197 // the context of the vm thread.
198 198 void collect_as_vm_thread(GCCause::Cause cause);
199 199
200 200 // These also should be called by the vm thread at a safepoint (e.g., from a
201 201 // VM operation).
202 202 //
203 203 // The first collects the young generation only, unless the scavenge fails; it
204 204 // will then attempt a full gc. The second collects the entire heap; if
205 205 // maximum_compaction is true, it will compact everything and clear all soft
206 206 // references.
207 207 inline void invoke_scavenge();
208 208 inline void invoke_full_gc(bool maximum_compaction);
209 209
210 210 bool supports_inline_contig_alloc() const { return !UseNUMA; }
211 211
212 212 HeapWord** top_addr() const { return !UseNUMA ? young_gen()->top_addr() : (HeapWord**)-1; }
213 213 HeapWord** end_addr() const { return !UseNUMA ? young_gen()->end_addr() : (HeapWord**)-1; }
214 214
215 215 void ensure_parsability(bool retire_tlabs);
216 216 void accumulate_statistics_all_tlabs();
217 217 void resize_all_tlabs();
218 218
219 219 size_t unsafe_max_alloc();
220 220
221 221 bool supports_tlab_allocation() const { return true; }
222 222
223 223 size_t tlab_capacity(Thread* thr) const;
224 224 size_t unsafe_max_tlab_alloc(Thread* thr) const;
225 225
226 226 // Can a compiler initialize a new object without store barriers?
227 227 // This permission only extends from the creation of a new object
228 228 // via a TLAB up to the first subsequent safepoint.
229 229 virtual bool can_elide_tlab_store_barriers() const {
230 230 return true;
231 231 }
232 232
233 233 virtual bool card_mark_must_follow_store() const {
234 234 return false;
235 235 }
236 236
237 237 // Return true if we don't we need a store barrier for
238 238 // initializing stores to an object at this address.
239 239 virtual bool can_elide_initializing_store_barrier(oop new_obj);
240 240
241 241 // Can a compiler elide a store barrier when it writes
242 242 // a permanent oop into the heap? Applies when the compiler
243 243 // is storing x to the heap, where x->is_perm() is true.
244 244 virtual bool can_elide_permanent_oop_store_barriers() const {
245 245 return true;
246 246 }
247 247
248 248 void oop_iterate(OopClosure* cl);
249 249 void object_iterate(ObjectClosure* cl);
250 250 void safe_object_iterate(ObjectClosure* cl) { object_iterate(cl); }
251 251 void permanent_oop_iterate(OopClosure* cl);
252 252 void permanent_object_iterate(ObjectClosure* cl);
253 253
254 254 HeapWord* block_start(const void* addr) const;
255 255 size_t block_size(const HeapWord* addr) const;
256 256 bool block_is_obj(const HeapWord* addr) const;
257 257
258 258 jlong millis_since_last_gc();
259 259
260 260 void prepare_for_verify();
261 261 PSHeapSummary create_ps_heap_summary();
262 262 VirtualSpaceSummary create_perm_gen_space_summary();
263 263 virtual void print_on(outputStream* st) const;
264 264 virtual void print_gc_threads_on(outputStream* st) const;
265 265 virtual void gc_threads_do(ThreadClosure* tc) const;
266 266 virtual void print_tracing_info() const;
267 267
268 268 void verify(bool silent, VerifyOption option /* ignored */);
269 269
270 270 void print_heap_change(size_t prev_used);
271 271
272 272 // Resize the young generation. The reserved space for the
273 273 // generation may be expanded in preparation for the resize.
274 274 void resize_young_gen(size_t eden_size, size_t survivor_size);
275 275
276 276 // Resize the old generation. The reserved space for the
277 277 // generation may be expanded in preparation for the resize.
278 278 void resize_old_gen(size_t desired_free_space);
279 279
280 280 // Save the tops of the spaces in all generations
281 281 void record_gen_tops_before_GC() PRODUCT_RETURN;
282 282
283 283 // Mangle the unused parts of all spaces in the heap
284 284 void gen_mangle_unused_area() PRODUCT_RETURN;
285 285
286 286 // Call these in sequential code around the processing of strong roots.
287 287 class ParStrongRootsScope : public MarkingCodeBlobClosure::MarkScope {
288 288 public:
289 289 ParStrongRootsScope();
290 290 ~ParStrongRootsScope();
291 291 };
292 292 };
293 293
294 294 inline size_t ParallelScavengeHeap::set_alignment(size_t& var, size_t val)
295 295 {
296 296 assert(is_power_of_2((intptr_t)val), "must be a power of 2");
297 297 var = round_to(val, intra_heap_alignment());
298 298 return var;
299 299 }
300 300
301 301 #endif // SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PARALLELSCAVENGEHEAP_HPP
↓ open down ↓ |
159 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX