18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #ifndef SHARE_VM_GC_PARALLEL_PARALLELSCAVENGEHEAP_HPP
26 #define SHARE_VM_GC_PARALLEL_PARALLELSCAVENGEHEAP_HPP
27
28 #include "gc/parallel/generationSizer.hpp"
29 #include "gc/parallel/objectStartArray.hpp"
30 #include "gc/parallel/psGCAdaptivePolicyCounters.hpp"
31 #include "gc/parallel/psOldGen.hpp"
32 #include "gc/parallel/psYoungGen.hpp"
33 #include "gc/shared/collectedHeap.hpp"
34 #include "gc/shared/collectorPolicy.hpp"
35 #include "gc/shared/gcPolicyCounters.hpp"
36 #include "gc/shared/gcWhen.hpp"
37 #include "gc/shared/strongRootsScope.hpp"
38 #include "utilities/ostream.hpp"
39
40 class AdjoiningGenerations;
41 class GCHeapSummary;
42 class GCTaskManager;
43 class PSAdaptiveSizePolicy;
44 class PSHeapSummary;
45
46 class ParallelScavengeHeap : public CollectedHeap {
47 friend class VMStructs;
48 private:
49 static PSYoungGen* _young_gen;
50 static PSOldGen* _old_gen;
51
52 // Sizing policy for entire heap
53 static PSAdaptiveSizePolicy* _size_policy;
54 static PSGCAdaptivePolicyCounters* _gc_policy_counters;
55
56 GenerationSizer* _collector_policy;
57
70 HeapWord* allocate_new_tlab(size_t size);
71
72 inline bool should_alloc_in_eden(size_t size) const;
73 inline void death_march_check(HeapWord* const result, size_t size);
74 HeapWord* mem_allocate_old_gen(size_t size);
75
76 public:
77 ParallelScavengeHeap(GenerationSizer* policy) :
78 CollectedHeap(), _collector_policy(policy), _death_march_count(0) { }
79
80 // For use by VM operations
81 enum CollectionType {
82 Scavenge,
83 MarkSweep
84 };
85
86 virtual Name kind() const {
87 return CollectedHeap::ParallelScavengeHeap;
88 }
89
90 virtual CollectorPolicy* collector_policy() const { return _collector_policy; }
91
92 static PSYoungGen* young_gen() { return _young_gen; }
93 static PSOldGen* old_gen() { return _old_gen; }
94
95 virtual PSAdaptiveSizePolicy* size_policy() { return _size_policy; }
96
97 static PSGCAdaptivePolicyCounters* gc_policy_counters() { return _gc_policy_counters; }
98
99 static ParallelScavengeHeap* heap();
100
101 static GCTaskManager* const gc_task_manager() { return _gc_task_manager; }
102
103 AdjoiningGenerations* gens() { return _gens; }
104
105 // Returns JNI_OK on success
106 virtual jint initialize();
107
108 void post_initialize();
109 void update_counters();
198 // initializing stores to an object at this address.
199 virtual bool can_elide_initializing_store_barrier(oop new_obj);
200
201 void object_iterate(ObjectClosure* cl);
202 void safe_object_iterate(ObjectClosure* cl) { object_iterate(cl); }
203
204 HeapWord* block_start(const void* addr) const;
205 size_t block_size(const HeapWord* addr) const;
206 bool block_is_obj(const HeapWord* addr) const;
207
208 jlong millis_since_last_gc();
209
210 void prepare_for_verify();
211 PSHeapSummary create_ps_heap_summary();
212 virtual void print_on(outputStream* st) const;
213 virtual void print_on_error(outputStream* st) const;
214 virtual void print_gc_threads_on(outputStream* st) const;
215 virtual void gc_threads_do(ThreadClosure* tc) const;
216 virtual void print_tracing_info() const;
217
218 void verify(bool silent, VerifyOption option /* ignored */);
219
220 void print_heap_change(size_t prev_used);
221
222 // Resize the young generation. The reserved space for the
223 // generation may be expanded in preparation for the resize.
224 void resize_young_gen(size_t eden_size, size_t survivor_size);
225
226 // Resize the old generation. The reserved space for the
227 // generation may be expanded in preparation for the resize.
228 void resize_old_gen(size_t desired_free_space);
229
230 // Save the tops of the spaces in all generations
231 void record_gen_tops_before_GC() PRODUCT_RETURN;
232
233 // Mangle the unused parts of all spaces in the heap
234 void gen_mangle_unused_area() PRODUCT_RETURN;
235
236 // Call these in sequential code around the processing of strong roots.
237 class ParStrongRootsScope : public MarkScope {
238 public:
239 ParStrongRootsScope();
240 ~ParStrongRootsScope();
241 };
242 };
243
244 #endif // SHARE_VM_GC_PARALLEL_PARALLELSCAVENGEHEAP_HPP
|
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #ifndef SHARE_VM_GC_PARALLEL_PARALLELSCAVENGEHEAP_HPP
26 #define SHARE_VM_GC_PARALLEL_PARALLELSCAVENGEHEAP_HPP
27
28 #include "gc/parallel/generationSizer.hpp"
29 #include "gc/parallel/objectStartArray.hpp"
30 #include "gc/parallel/psGCAdaptivePolicyCounters.hpp"
31 #include "gc/parallel/psOldGen.hpp"
32 #include "gc/parallel/psYoungGen.hpp"
33 #include "gc/shared/collectedHeap.hpp"
34 #include "gc/shared/collectorPolicy.hpp"
35 #include "gc/shared/gcPolicyCounters.hpp"
36 #include "gc/shared/gcWhen.hpp"
37 #include "gc/shared/strongRootsScope.hpp"
38 #include "memory/metaspace.hpp"
39 #include "utilities/ostream.hpp"
40
41 class AdjoiningGenerations;
42 class GCHeapSummary;
43 class GCTaskManager;
44 class PSAdaptiveSizePolicy;
45 class PSHeapSummary;
46
47 class ParallelScavengeHeap : public CollectedHeap {
48 friend class VMStructs;
49 private:
50 static PSYoungGen* _young_gen;
51 static PSOldGen* _old_gen;
52
53 // Sizing policy for entire heap
54 static PSAdaptiveSizePolicy* _size_policy;
55 static PSGCAdaptivePolicyCounters* _gc_policy_counters;
56
57 GenerationSizer* _collector_policy;
58
71 HeapWord* allocate_new_tlab(size_t size);
72
73 inline bool should_alloc_in_eden(size_t size) const;
74 inline void death_march_check(HeapWord* const result, size_t size);
75 HeapWord* mem_allocate_old_gen(size_t size);
76
77 public:
78 ParallelScavengeHeap(GenerationSizer* policy) :
79 CollectedHeap(), _collector_policy(policy), _death_march_count(0) { }
80
81 // For use by VM operations
82 enum CollectionType {
83 Scavenge,
84 MarkSweep
85 };
86
87 virtual Name kind() const {
88 return CollectedHeap::ParallelScavengeHeap;
89 }
90
91 virtual const char* name() const {
92 return "Parallel";
93 }
94
95 virtual CollectorPolicy* collector_policy() const { return _collector_policy; }
96
97 static PSYoungGen* young_gen() { return _young_gen; }
98 static PSOldGen* old_gen() { return _old_gen; }
99
100 virtual PSAdaptiveSizePolicy* size_policy() { return _size_policy; }
101
102 static PSGCAdaptivePolicyCounters* gc_policy_counters() { return _gc_policy_counters; }
103
104 static ParallelScavengeHeap* heap();
105
106 static GCTaskManager* const gc_task_manager() { return _gc_task_manager; }
107
108 AdjoiningGenerations* gens() { return _gens; }
109
110 // Returns JNI_OK on success
111 virtual jint initialize();
112
113 void post_initialize();
114 void update_counters();
203 // initializing stores to an object at this address.
204 virtual bool can_elide_initializing_store_barrier(oop new_obj);
205
206 void object_iterate(ObjectClosure* cl);
207 void safe_object_iterate(ObjectClosure* cl) { object_iterate(cl); }
208
209 HeapWord* block_start(const void* addr) const;
210 size_t block_size(const HeapWord* addr) const;
211 bool block_is_obj(const HeapWord* addr) const;
212
213 jlong millis_since_last_gc();
214
215 void prepare_for_verify();
216 PSHeapSummary create_ps_heap_summary();
217 virtual void print_on(outputStream* st) const;
218 virtual void print_on_error(outputStream* st) const;
219 virtual void print_gc_threads_on(outputStream* st) const;
220 virtual void gc_threads_do(ThreadClosure* tc) const;
221 virtual void print_tracing_info() const;
222
223 void verify(VerifyOption option /* ignored */);
224
225 // Resize the young generation. The reserved space for the
226 // generation may be expanded in preparation for the resize.
227 void resize_young_gen(size_t eden_size, size_t survivor_size);
228
229 // Resize the old generation. The reserved space for the
230 // generation may be expanded in preparation for the resize.
231 void resize_old_gen(size_t desired_free_space);
232
233 // Save the tops of the spaces in all generations
234 void record_gen_tops_before_GC() PRODUCT_RETURN;
235
236 // Mangle the unused parts of all spaces in the heap
237 void gen_mangle_unused_area() PRODUCT_RETURN;
238
239 // Call these in sequential code around the processing of strong roots.
240 class ParStrongRootsScope : public MarkScope {
241 public:
242 ParStrongRootsScope();
243 ~ParStrongRootsScope();
244 };
245 };
246
247 // Simple class for storing info about the heap at the start of GC, to be used
248 // after GC for comparison/printing.
249 class PreGCValues {
250 public:
251 PreGCValues(ParallelScavengeHeap* heap) :
252 _heap_used(heap->used()),
253 _young_gen_used(heap->young_gen()->used_in_bytes()),
254 _old_gen_used(heap->old_gen()->used_in_bytes()),
255 _metadata_used(MetaspaceAux::used_bytes()) { };
256
257 size_t heap_used() const { return _heap_used; }
258 size_t young_gen_used() const { return _young_gen_used; }
259 size_t old_gen_used() const { return _old_gen_used; }
260 size_t metadata_used() const { return _metadata_used; }
261
262 private:
263 size_t _heap_used;
264 size_t _young_gen_used;
265 size_t _old_gen_used;
266 size_t _metadata_used;
267 };
268
269 #endif // SHARE_VM_GC_PARALLEL_PARALLELSCAVENGEHEAP_HPP
|