< prev index next >

src/hotspot/share/gc/parallel/parallelScavengeHeap.hpp

8224665: Parallel GC: Use WorkGang (7: remove task manager)

8224659: Parallel GC: Use WorkGang (1: PCRefProcTask)

18  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA                                                 
19  * or visit www.oracle.com if you need additional information or have any                                                  
20  * questions.                                                                                                              
21  *                                                                                                                         
22  */                                                                                                                        
23 
24 #ifndef SHARE_GC_PARALLEL_PARALLELSCAVENGEHEAP_HPP                                                                         
25 #define SHARE_GC_PARALLEL_PARALLELSCAVENGEHEAP_HPP                                                                         
26 
27 #include "gc/parallel/objectStartArray.hpp"                                                                                
28 #include "gc/parallel/psGCAdaptivePolicyCounters.hpp"                                                                      
29 #include "gc/parallel/psOldGen.hpp"                                                                                        
30 #include "gc/parallel/psYoungGen.hpp"                                                                                      
31 #include "gc/shared/cardTableBarrierSet.hpp"                                                                               
32 #include "gc/shared/collectedHeap.hpp"                                                                                     
33 #include "gc/shared/gcPolicyCounters.hpp"                                                                                  
34 #include "gc/shared/gcWhen.hpp"                                                                                            
35 #include "gc/shared/referenceProcessor.hpp"                                                                                
36 #include "gc/shared/softRefPolicy.hpp"                                                                                     
37 #include "gc/shared/strongRootsScope.hpp"                                                                                  
                                                                                                                           
38 #include "logging/log.hpp"                                                                                                 
39 #include "memory/metaspace.hpp"                                                                                            
40 #include "utilities/growableArray.hpp"                                                                                     
41 #include "utilities/ostream.hpp"                                                                                           
42 
43 class AdjoiningGenerations;                                                                                                
44 class GCHeapSummary;                                                                                                       
45 class GCTaskManager;                                                                                                       
46 class MemoryManager;                                                                                                       
47 class MemoryPool;                                                                                                          
48 class PSAdaptiveSizePolicy;                                                                                                
49 class PSCardTable;                                                                                                         
50 class PSHeapSummary;                                                                                                       
51 
52 class ParallelScavengeHeap : public CollectedHeap {                                                                        
53   friend class VMStructs;                                                                                                  
54  private:                                                                                                                  
55   static PSYoungGen* _young_gen;                                                                                           
56   static PSOldGen*   _old_gen;                                                                                             
57 
58   // Sizing policy for entire heap                                                                                         
59   static PSAdaptiveSizePolicy*       _size_policy;                                                                         
60   static PSGCAdaptivePolicyCounters* _gc_policy_counters;                                                                  
61 
62   SoftRefPolicy _soft_ref_policy;                                                                                          
63 
64   // Collection of generations that are adjacent in the                                                                    
65   // space reserved for the heap.                                                                                          
66   AdjoiningGenerations* _gens;                                                                                             
67   unsigned int _death_march_count;                                                                                         
68 
69   // The task manager                                                                                                      
70   static GCTaskManager* _gc_task_manager;                                                                                  
71                                                                                                                            
72   GCMemoryManager* _young_manager;                                                                                         
73   GCMemoryManager* _old_manager;                                                                                           
74 
75   MemoryPool* _eden_pool;                                                                                                  
76   MemoryPool* _survivor_pool;                                                                                              
77   MemoryPool* _old_pool;                                                                                                   
78 
                                                                                                                           
                                                                                                                           
79   virtual void initialize_serviceability();                                                                                
80 
81   void trace_heap(GCWhen::Type when, const GCTracer* tracer);                                                              
82 
83  protected:                                                                                                                
84   static inline size_t total_invocations();                                                                                
85   HeapWord* allocate_new_tlab(size_t min_size, size_t requested_size, size_t* actual_size);                                
86 
87   inline bool should_alloc_in_eden(size_t size) const;                                                                     
88   inline void death_march_check(HeapWord* const result, size_t size);                                                      
89   HeapWord* mem_allocate_old_gen(size_t size);                                                                             
90 
91  public:                                                                                                                   
92   ParallelScavengeHeap() :                                                                                                 
93     CollectedHeap(),                                                                                                       
94     _gens(NULL),                                                                                                           
95     _death_march_count(0),                                                                                                 
96     _young_manager(NULL),                                                                                                  
97     _old_manager(NULL),                                                                                                    
98     _eden_pool(NULL),                                                                                                      
99     _survivor_pool(NULL),                                                                                                  
100     _old_pool(NULL) { }                                                                                                    
                                                                                                                           
                                                                                                                           
                                                                                                                           
101 
102   // For use by VM operations                                                                                              
103   enum CollectionType {                                                                                                    
104     Scavenge,                                                                                                              
105     MarkSweep                                                                                                              
106   };                                                                                                                       
107 
108   virtual Name kind() const {                                                                                              
109     return CollectedHeap::Parallel;                                                                                        
110   }                                                                                                                        
111 
112   virtual const char* name() const {                                                                                       
113     return "Parallel";                                                                                                     
114   }                                                                                                                        
115 
116   virtual SoftRefPolicy* soft_ref_policy() { return &_soft_ref_policy; }                                                   
117 
118   virtual GrowableArray<GCMemoryManager*> memory_managers();                                                               
119   virtual GrowableArray<MemoryPool*> memory_pools();                                                                       
120 
121   static PSYoungGen* young_gen() { return _young_gen; }                                                                    
122   static PSOldGen* old_gen()     { return _old_gen; }                                                                      
123 
124   virtual PSAdaptiveSizePolicy* size_policy() { return _size_policy; }                                                     
125 
126   static PSGCAdaptivePolicyCounters* gc_policy_counters() { return _gc_policy_counters; }                                  
127 
128   static ParallelScavengeHeap* heap();                                                                                     
129 
130   static GCTaskManager* const gc_task_manager() { return _gc_task_manager; }                                               
131                                                                                                                            
132   CardTableBarrierSet* barrier_set();                                                                                      
133   PSCardTable* card_table();                                                                                               
134 
135   AdjoiningGenerations* gens() { return _gens; }                                                                           
136 
137   // Returns JNI_OK on success                                                                                             
138   virtual jint initialize();                                                                                               
139 
140   void post_initialize();                                                                                                  
141   void update_counters();                                                                                                  
142 
143   size_t capacity() const;                                                                                                 
144   size_t used() const;                                                                                                     
145 
146   // Return "true" if all generations have reached the                                                                     
147   // maximal committed limit that they can reach, without a garbage                                                        
148   // collection.                                                                                                           
149   virtual bool is_maximal_no_gc() const;                                                                                   
150 

18  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
19  * or visit www.oracle.com if you need additional information or have any
20  * questions.
21  *
22  */
23 
24 #ifndef SHARE_GC_PARALLEL_PARALLELSCAVENGEHEAP_HPP
25 #define SHARE_GC_PARALLEL_PARALLELSCAVENGEHEAP_HPP
26 
27 #include "gc/parallel/objectStartArray.hpp"
28 #include "gc/parallel/psGCAdaptivePolicyCounters.hpp"
29 #include "gc/parallel/psOldGen.hpp"
30 #include "gc/parallel/psYoungGen.hpp"
31 #include "gc/shared/cardTableBarrierSet.hpp"
32 #include "gc/shared/collectedHeap.hpp"
33 #include "gc/shared/gcPolicyCounters.hpp"
34 #include "gc/shared/gcWhen.hpp"
35 #include "gc/shared/referenceProcessor.hpp"
36 #include "gc/shared/softRefPolicy.hpp"
37 #include "gc/shared/strongRootsScope.hpp"
38 #include "gc/shared/workgroup.hpp"
39 #include "logging/log.hpp"
40 #include "memory/metaspace.hpp"
41 #include "utilities/growableArray.hpp"
42 #include "utilities/ostream.hpp"
43 
44 class AdjoiningGenerations;
45 class GCHeapSummary;

46 class MemoryManager;
47 class MemoryPool;
48 class PSAdaptiveSizePolicy;
49 class PSCardTable;
50 class PSHeapSummary;
51 
52 class ParallelScavengeHeap : public CollectedHeap {
53   friend class VMStructs;
54  private:
55   static PSYoungGen* _young_gen;
56   static PSOldGen*   _old_gen;
57 
58   // Sizing policy for entire heap
59   static PSAdaptiveSizePolicy*       _size_policy;
60   static PSGCAdaptivePolicyCounters* _gc_policy_counters;
61 
62   SoftRefPolicy _soft_ref_policy;
63 
64   // Collection of generations that are adjacent in the
65   // space reserved for the heap.
66   AdjoiningGenerations* _gens;
67   unsigned int _death_march_count;
68 



69   GCMemoryManager* _young_manager;
70   GCMemoryManager* _old_manager;
71 
72   MemoryPool* _eden_pool;
73   MemoryPool* _survivor_pool;
74   MemoryPool* _old_pool;
75 
76   WorkGang _workers;
77 
78   virtual void initialize_serviceability();
79 
80   void trace_heap(GCWhen::Type when, const GCTracer* tracer);
81 
82  protected:
83   static inline size_t total_invocations();
84   HeapWord* allocate_new_tlab(size_t min_size, size_t requested_size, size_t* actual_size);
85 
86   inline bool should_alloc_in_eden(size_t size) const;
87   inline void death_march_check(HeapWord* const result, size_t size);
88   HeapWord* mem_allocate_old_gen(size_t size);
89 
90  public:
91   ParallelScavengeHeap() :
92     CollectedHeap(),
93     _gens(NULL),
94     _death_march_count(0),
95     _young_manager(NULL),
96     _old_manager(NULL),
97     _eden_pool(NULL),
98     _survivor_pool(NULL),
99     _old_pool(NULL),
100     _workers("GC Thread", ParallelGCThreads,
101         true /* are_GC_task_threads */,
102         false /* are_ConcurrentGC_threads */) { }
103 
104   // For use by VM operations
105   enum CollectionType {
106     Scavenge,
107     MarkSweep
108   };
109 
110   virtual Name kind() const {
111     return CollectedHeap::Parallel;
112   }
113 
114   virtual const char* name() const {
115     return "Parallel";
116   }
117 
118   virtual SoftRefPolicy* soft_ref_policy() { return &_soft_ref_policy; }
119 
120   virtual GrowableArray<GCMemoryManager*> memory_managers();
121   virtual GrowableArray<MemoryPool*> memory_pools();
122 
123   static PSYoungGen* young_gen() { return _young_gen; }
124   static PSOldGen* old_gen()     { return _old_gen; }
125 
126   virtual PSAdaptiveSizePolicy* size_policy() { return _size_policy; }
127 
128   static PSGCAdaptivePolicyCounters* gc_policy_counters() { return _gc_policy_counters; }
129 
130   static ParallelScavengeHeap* heap();
131 


132   CardTableBarrierSet* barrier_set();
133   PSCardTable* card_table();
134 
135   AdjoiningGenerations* gens() { return _gens; }
136 
137   // Returns JNI_OK on success
138   virtual jint initialize();
139 
140   void post_initialize();
141   void update_counters();
142 
143   size_t capacity() const;
144   size_t used() const;
145 
146   // Return "true" if all generations have reached the
147   // maximal committed limit that they can reach, without a garbage
148   // collection.
149   virtual bool is_maximal_no_gc() const;
150 

230 
231   // Resize the old generation.  The reserved space for the                                                                
232   // generation may be expanded in preparation for the resize.                                                             
233   void resize_old_gen(size_t desired_free_space);                                                                          
234 
235   // Save the tops of the spaces in all generations                                                                        
236   void record_gen_tops_before_GC() PRODUCT_RETURN;                                                                         
237 
238   // Mangle the unused parts of all spaces in the heap                                                                     
239   void gen_mangle_unused_area() PRODUCT_RETURN;                                                                            
240 
241   // Call these in sequential code around the processing of strong roots.                                                  
242   class ParStrongRootsScope : public MarkScope {                                                                           
243    public:                                                                                                                 
244     ParStrongRootsScope();                                                                                                 
245     ~ParStrongRootsScope();                                                                                                
246   };                                                                                                                       
247 
248   GCMemoryManager* old_gc_manager() const { return _old_manager; }                                                         
249   GCMemoryManager* young_gc_manager() const { return _young_manager; }                                                     
                                                                                                                           
                                                                                                                           
                                                                                                                           
                                                                                                                           
250 };                                                                                                                         
251 
252 // Simple class for storing info about the heap at the start of GC, to be used                                             
253 // after GC for comparison/printing.                                                                                       
254 class PreGCValues {                                                                                                        
255 public:                                                                                                                    
256   PreGCValues(ParallelScavengeHeap* heap) :                                                                                
257       _heap_used(heap->used()),                                                                                            
258       _young_gen_used(heap->young_gen()->used_in_bytes()),                                                                 
259       _old_gen_used(heap->old_gen()->used_in_bytes()),                                                                     
260       _metadata_used(MetaspaceUtils::used_bytes()) { };                                                                    
261 
262   size_t heap_used() const      { return _heap_used; }                                                                     
263   size_t young_gen_used() const { return _young_gen_used; }                                                                
264   size_t old_gen_used() const   { return _old_gen_used; }                                                                  
265   size_t metadata_used() const  { return _metadata_used; }                                                                 
266 
267 private:                                                                                                                   
268   size_t _heap_used;                                                                                                       

230 
231   // Resize the old generation.  The reserved space for the
232   // generation may be expanded in preparation for the resize.
233   void resize_old_gen(size_t desired_free_space);
234 
235   // Save the tops of the spaces in all generations
236   void record_gen_tops_before_GC() PRODUCT_RETURN;
237 
238   // Mangle the unused parts of all spaces in the heap
239   void gen_mangle_unused_area() PRODUCT_RETURN;
240 
241   // Call these in sequential code around the processing of strong roots.
242   class ParStrongRootsScope : public MarkScope {
243    public:
244     ParStrongRootsScope();
245     ~ParStrongRootsScope();
246   };
247 
248   GCMemoryManager* old_gc_manager() const { return _old_manager; }
249   GCMemoryManager* young_gc_manager() const { return _young_manager; }
250 
251   WorkGang& workers() {
252     return _workers;
253   }
254 };
255 
256 // Simple class for storing info about the heap at the start of GC, to be used
257 // after GC for comparison/printing.
258 class PreGCValues {
259 public:
260   PreGCValues(ParallelScavengeHeap* heap) :
261       _heap_used(heap->used()),
262       _young_gen_used(heap->young_gen()->used_in_bytes()),
263       _old_gen_used(heap->old_gen()->used_in_bytes()),
264       _metadata_used(MetaspaceUtils::used_bytes()) { };
265 
266   size_t heap_used() const      { return _heap_used; }
267   size_t young_gen_used() const { return _young_gen_used; }
268   size_t old_gen_used() const   { return _old_gen_used; }
269   size_t metadata_used() const  { return _metadata_used; }
270 
271 private:
272   size_t _heap_used;
< prev index next >