< prev index next >

src/share/vm/memory/genCollectedHeap.hpp

Print this page




  34 
  35 // A "GenCollectedHeap" is a SharedHeap that uses generational
  36 // collection.  It has two generations, young and old.
  37 class GenCollectedHeap : public SharedHeap {
  38   friend class GenCollectorPolicy;
  39   friend class Generation;
  40   friend class DefNewGeneration;
  41   friend class TenuredGeneration;
  42   friend class ConcurrentMarkSweepGeneration;
  43   friend class CMSCollector;
  44   friend class GenMarkSweep;
  45   friend class VM_GenCollectForAllocation;
  46   friend class VM_GenCollectFull;
  47   friend class VM_GenCollectFullConcurrent;
  48   friend class VM_GC_HeapInspection;
  49   friend class VM_HeapDumper;
  50   friend class HeapInspection;
  51   friend class GCCauseSetter;
  52   friend class VMStructs;
  53 public:
  54   enum SomeConstants {
  55     max_gens = 10
  56   };
  57 
  58   friend class VM_PopulateDumpSharedSpace;
  59 
  60  protected:
  61   // Fields:
  62   static GenCollectedHeap* _gch;
  63 
  64  private:
  65   int _n_gens;
  66 
  67   Generation* _young_gen;
  68   Generation* _old_gen;
  69 
  70   // The singleton Gen Remembered Set.
  71   GenRemSet* _rem_set;
  72 
  73   // The generational collector policy.
  74   GenCollectorPolicy* _gen_policy;
  75 
  76   // Indicates that the most recent previous incremental collection failed.
  77   // The flag is cleared when an action is taken that might clear the
  78   // condition that caused that incremental collection to fail.
  79   bool _incremental_collection_failed;
  80 
  81   // In support of ExplicitGCInvokesConcurrent functionality
  82   unsigned int _full_collections_completed;
  83 
  84   // Data structure for claiming the (potentially) parallel tasks in
  85   // (gen-specific) roots processing.
  86   SubTasksDone* _process_strong_tasks;


 353   // The functions below are helper functions that a subclass of
 354   // "CollectedHeap" can use in the implementation of its virtual
 355   // functions.
 356 
 357   class GenClosure : public StackObj {
 358    public:
 359     virtual void do_generation(Generation* gen) = 0;
 360   };
 361 
 362   // Apply "cl.do_generation" to all generations in the heap
 363   // If "old_to_young" determines the order.
 364   void generation_iterate(GenClosure* cl, bool old_to_young);
 365 
 366   void space_iterate(SpaceClosure* cl);
 367 
 368   // Return "true" if all generations have reached the
 369   // maximal committed limit that they can reach, without a garbage
 370   // collection.
 371   virtual bool is_maximal_no_gc() const;
 372 
 373   int n_gens() const {
 374     assert(_n_gens == gen_policy()->number_of_generations(), "Sanity");
 375     return _n_gens;
 376   }
 377 
 378   // This function returns the "GenRemSet" object that allows us to scan
 379   // generations in a fully generational heap.
 380   GenRemSet* rem_set() { return _rem_set; }
 381 
 382   // Convenience function to be used in situations where the heap type can be
 383   // asserted to be this type.
 384   static GenCollectedHeap* heap();
 385 
 386   void set_par_threads(uint t);
 387   void set_n_termination(uint t);
 388 
 389   // Invoke the "do_oop" method of one of the closures "not_older_gens"
 390   // or "older_gens" on root locations for the generation at
 391   // "level".  (The "older_gens" closure is used for scanning references
 392   // from older generations; "not_older_gens" is used everywhere else.)
 393   // If "younger_gens_as_roots" is false, younger generations are
 394   // not scanned as roots; in this case, the caller must be arranging to
 395   // scan the younger generations itself.  (For example, a generation might
 396   // explicitly mark reachable objects in younger generations, to avoid
 397   // excess storage retention.)




  34 
  35 // A "GenCollectedHeap" is a SharedHeap that uses generational
  36 // collection.  It has two generations, young and old.
  37 class GenCollectedHeap : public SharedHeap {
  38   friend class GenCollectorPolicy;
  39   friend class Generation;
  40   friend class DefNewGeneration;
  41   friend class TenuredGeneration;
  42   friend class ConcurrentMarkSweepGeneration;
  43   friend class CMSCollector;
  44   friend class GenMarkSweep;
  45   friend class VM_GenCollectForAllocation;
  46   friend class VM_GenCollectFull;
  47   friend class VM_GenCollectFullConcurrent;
  48   friend class VM_GC_HeapInspection;
  49   friend class VM_HeapDumper;
  50   friend class HeapInspection;
  51   friend class GCCauseSetter;
  52   friend class VMStructs;
  53 public:




  54   friend class VM_PopulateDumpSharedSpace;
  55 
  56  protected:
  57   // Fields:
  58   static GenCollectedHeap* _gch;
  59 
  60  private:


  61   Generation* _young_gen;
  62   Generation* _old_gen;
  63 
  64   // The singleton Gen Remembered Set.
  65   GenRemSet* _rem_set;
  66 
  67   // The generational collector policy.
  68   GenCollectorPolicy* _gen_policy;
  69 
  70   // Indicates that the most recent previous incremental collection failed.
  71   // The flag is cleared when an action is taken that might clear the
  72   // condition that caused that incremental collection to fail.
  73   bool _incremental_collection_failed;
  74 
  75   // In support of ExplicitGCInvokesConcurrent functionality
  76   unsigned int _full_collections_completed;
  77 
  78   // Data structure for claiming the (potentially) parallel tasks in
  79   // (gen-specific) roots processing.
  80   SubTasksDone* _process_strong_tasks;


 347   // The functions below are helper functions that a subclass of
 348   // "CollectedHeap" can use in the implementation of its virtual
 349   // functions.
 350 
 351   class GenClosure : public StackObj {
 352    public:
 353     virtual void do_generation(Generation* gen) = 0;
 354   };
 355 
 356   // Apply "cl.do_generation" to all generations in the heap
 357   // If "old_to_young" determines the order.
 358   void generation_iterate(GenClosure* cl, bool old_to_young);
 359 
 360   void space_iterate(SpaceClosure* cl);
 361 
 362   // Return "true" if all generations have reached the
 363   // maximal committed limit that they can reach, without a garbage
 364   // collection.
 365   virtual bool is_maximal_no_gc() const;
 366 





 367   // This function returns the "GenRemSet" object that allows us to scan
 368   // generations in a fully generational heap.
 369   GenRemSet* rem_set() { return _rem_set; }
 370 
 371   // Convenience function to be used in situations where the heap type can be
 372   // asserted to be this type.
 373   static GenCollectedHeap* heap();
 374 
 375   void set_par_threads(uint t);
 376   void set_n_termination(uint t);
 377 
 378   // Invoke the "do_oop" method of one of the closures "not_older_gens"
 379   // or "older_gens" on root locations for the generation at
 380   // "level".  (The "older_gens" closure is used for scanning references
 381   // from older generations; "not_older_gens" is used everywhere else.)
 382   // If "younger_gens_as_roots" is false, younger generations are
 383   // not scanned as roots; in this case, the caller must be arranging to
 384   // scan the younger generations itself.  (For example, a generation might
 385   // explicitly mark reachable objects in younger generations, to avoid
 386   // excess storage retention.)


< prev index next >