src/share/vm/memory/generation.hpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File hotspot Sdiff src/share/vm/memory

src/share/vm/memory/generation.hpp

Print this page
rev 7215 : imported patch remove_levels


  85 };
  86 
  87 
  88 class Generation: public CHeapObj<mtGC> {
  89   friend class VMStructs;
  90  private:
  91   jlong _time_of_last_gc; // time when last gc on this generation happened (ms)
  92   MemRegion _prev_used_region; // for collectors that want to "remember" a value for
  93                                // used region at some specific point during collection.
  94 
  95  protected:
  96   // Minimum and maximum addresses for memory reserved (not necessarily
  97   // committed) for generation.
  98   // Used by card marking code. Must not overlap with address ranges of
  99   // other generations.
 100   MemRegion _reserved;
 101 
 102   // Memory area reserved for generation
 103   VirtualSpace _virtual_space;
 104 
 105   // Level in the generation hierarchy.
 106   int _level;
 107 
 108   // ("Weak") Reference processing support
 109   ReferenceProcessor* _ref_processor;
 110 
 111   // Performance Counters
 112   CollectorCounters* _gc_counters;
 113 
 114   // Statistics for garbage collection
 115   GCStats* _gc_stats;
 116 
 117   // Returns the next generation in the configuration, or else NULL if this
 118   // is the highest generation.
 119   Generation* next_gen() const;
 120 
 121   // Initialize the generation.
 122   Generation(ReservedSpace rs, size_t initial_byte_size, int level);
 123 
 124   // Apply "cl->do_oop" to (the address of) (exactly) all the ref fields in
 125   // "sp" that point into younger generations.
 126   // The iteration is only over objects allocated at the start of the
 127   // iterations; objects allocated as a result of applying the closure are
 128   // not included.
 129   void younger_refs_in_space_iterate(Space* sp, OopsInGenClosure* cl);
 130 
 131  public:
 132   // The set of possible generation kinds.
 133   enum Name {
 134     DefNew,
 135     ParNew,
 136     MarkSweepCompact,
 137     ConcurrentMarkSweep,
 138     Other
 139   };
 140 





 141   enum SomePublicConstants {
 142     // Generations are GenGrain-aligned and have size that are multiples of
 143     // GenGrain.
 144     // Note: on ARM we add 1 bit for card_table_base to be properly aligned
 145     // (we expect its low byte to be zero - see implementation of post_barrier)
 146     LogOfGenGrain = 16 ARM_ONLY(+1),
 147     GenGrain = 1 << LogOfGenGrain
 148   };
 149 
 150   // allocate and initialize ("weak") refs processing support
 151   virtual void ref_processor_init();
 152   void set_ref_processor(ReferenceProcessor* rp) {
 153     assert(_ref_processor == NULL, "clobbering existing _ref_processor");
 154     _ref_processor = rp;
 155   }
 156 
 157   virtual Generation::Name kind() { return Generation::Other; }
 158   GenerationSpec* spec();
 159 
 160   // This properly belongs in the collector, but for now this


 421     NOT_PRODUCT(
 422       if (now < _time_of_last_gc) {
 423         warning("time warp: "INT64_FORMAT" to "INT64_FORMAT, (int64_t)_time_of_last_gc, (int64_t)now);
 424       }
 425     )
 426     return _time_of_last_gc;
 427   }
 428 
 429   virtual void update_time_of_last_gc(jlong now)  {
 430     _time_of_last_gc = now;
 431   }
 432 
 433   // Generations may keep statistics about collection.  This
 434   // method updates those statistics.  current_level is
 435   // the level of the collection that has most recently
 436   // occurred.  This allows the generation to decide what
 437   // statistics are valid to collect.  For example, the
 438   // generation can decide to gather the amount of promoted data
 439   // if the collection of the younger generations has completed.
 440   GCStats* gc_stats() const { return _gc_stats; }
 441   virtual void update_gc_stats(int current_level, bool full) {}
 442 
 443   // Mark sweep support phase2
 444   virtual void prepare_for_compaction(CompactPoint* cp);
 445   // Mark sweep support phase3
 446   virtual void adjust_pointers();
 447   // Mark sweep support phase4
 448   virtual void compact();
 449   virtual void post_compact() {ShouldNotReachHere();}
 450 
 451   // Support for CMS's rescan. In this general form we return a pointer
 452   // to an abstract object that can be used, based on specific previously
 453   // decided protocols, to exchange information between generations,
 454   // information that may be useful for speeding up certain types of
 455   // garbage collectors. A NULL value indicates to the client that
 456   // no data recording is expected by the provider. The data-recorder is
 457   // expected to be GC worker thread-local, with the worker index
 458   // indicated by "thr_num".
 459   virtual void* get_data_recorder(int thr_num) { return NULL; }
 460   virtual void sample_eden_chunk() {}
 461 


 506   // if the requestor is a young generation and the target is older).
 507   // If the target generation can provide any scratch space, it adds
 508   // it to "list", leaving "list" pointing to the head of the
 509   // augmented list.  The default is to offer no space.
 510   virtual void contribute_scratch(ScratchBlock*& list, Generation* requestor,
 511                                   size_t max_alloc_words) {}
 512 
 513   // Give each generation an opportunity to do clean up for any
 514   // contributed scratch.
 515   virtual void reset_scratch() {};
 516 
 517   // When an older generation has been collected, and perhaps resized,
 518   // this method will be invoked on all younger generations (from older to
 519   // younger), allowing them to resize themselves as appropriate.
 520   virtual void compute_new_size() = 0;
 521 
 522   // Printing
 523   virtual const char* name() const = 0;
 524   virtual const char* short_name() const = 0;
 525 
 526   int level() const { return _level; }
 527 
 528   // Attributes
 529 
 530   // True iff the given generation may only be the youngest generation.
 531   virtual bool must_be_youngest() const = 0;
 532   // True iff the given generation may only be the oldest generation.
 533   virtual bool must_be_oldest() const = 0;
 534 
 535   // Reference Processing accessor
 536   ReferenceProcessor* const ref_processor() { return _ref_processor; }
 537 
 538   // Iteration.
 539 
 540   // Iterate over all the ref-containing fields of all objects in the
 541   // generation, calling "cl.do_oop" on each.
 542   virtual void oop_iterate(ExtendedOopClosure* cl);
 543 
 544   // Iterate over all objects in the generation, calling "cl.do_object" on
 545   // each.
 546   virtual void object_iterate(ObjectClosure* cl);
 547 


 621 
 622 class CardGeneration: public Generation {
 623   friend class VMStructs;
 624  protected:
 625   // This is shared with other generations.
 626   GenRemSet* _rs;
 627   // This is local to this generation.
 628   BlockOffsetSharedArray* _bts;
 629 
 630   // current shrinking effect: this damps shrinking when the heap gets empty.
 631   size_t _shrink_factor;
 632 
 633   size_t _min_heap_delta_bytes;   // Minimum amount to expand.
 634 
 635   // Some statistics from before gc started.
 636   // These are gathered in the gc_prologue (and should_collect)
 637   // to control growing/shrinking policy in spite of promotions.
 638   size_t _capacity_at_prologue;
 639   size_t _used_at_prologue;
 640 
 641   CardGeneration(ReservedSpace rs, size_t initial_byte_size, int level,
 642                  GenRemSet* remset);
 643 
 644  public:
 645 
 646   // Attempt to expand the generation by "bytes".  Expand by at a
 647   // minimum "expand_bytes".  Return true if some amount (not
 648   // necessarily the full "bytes") was done.
 649   virtual bool expand(size_t bytes, size_t expand_bytes);
 650 
 651   // Shrink generation with specified size (returns false if unable to shrink)
 652   virtual void shrink(size_t bytes) = 0;
 653 
 654   virtual void compute_new_size();
 655 
 656   virtual void clear_remembered_set();
 657 
 658   virtual void invalidate_remembered_set();
 659 
 660   virtual void prepare_for_verify();
 661 
 662   // Grow generation with specified size (returns false if unable to grow)


 679   ContiguousSpace*  _the_space;       // actual space holding objects
 680   WaterMark  _last_gc;                // watermark between objects allocated before
 681                                       // and after last GC.
 682 
 683   // Grow generation with specified size (returns false if unable to grow)
 684   virtual bool grow_by(size_t bytes);
 685   // Grow generation to reserved size.
 686   virtual bool grow_to_reserved();
 687   // Shrink generation with specified size (returns false if unable to shrink)
 688   void shrink_by(size_t bytes);
 689 
 690   // Allocation failure
 691   virtual bool expand(size_t bytes, size_t expand_bytes);
 692   void shrink(size_t bytes);
 693 
 694   // Accessing spaces
 695   ContiguousSpace* the_space() const { return _the_space; }
 696 
 697  public:
 698   OneContigSpaceCardGeneration(ReservedSpace rs, size_t initial_byte_size,
 699                                int level, GenRemSet* remset,
 700                                ContiguousSpace* space) :
 701     CardGeneration(rs, initial_byte_size, level, remset),
 702     _the_space(space)
 703   {}
 704 
 705   inline bool is_in(const void* p) const;
 706 
 707   // Space enquiries
 708   size_t capacity() const;
 709   size_t used() const;
 710   size_t free() const;
 711 
 712   MemRegion used_region() const;
 713 
 714   size_t unsafe_max_alloc_nogc() const;
 715   size_t contiguous_available() const;
 716 
 717   // Iteration
 718   void object_iterate(ObjectClosure* blk);
 719   void space_iterate(SpaceClosure* blk, bool usedOnly = false);
 720 
 721   void younger_refs_iterate(OopsInGenClosure* blk);




  85 };
  86 
  87 
  88 class Generation: public CHeapObj<mtGC> {
  89   friend class VMStructs;
  90  private:
  91   jlong _time_of_last_gc; // time when last gc on this generation happened (ms)
  92   MemRegion _prev_used_region; // for collectors that want to "remember" a value for
  93                                // used region at some specific point during collection.
  94 
  95  protected:
  96   // Minimum and maximum addresses for memory reserved (not necessarily
  97   // committed) for generation.
  98   // Used by card marking code. Must not overlap with address ranges of
  99   // other generations.
 100   MemRegion _reserved;
 101 
 102   // Memory area reserved for generation
 103   VirtualSpace _virtual_space;
 104 



 105   // ("Weak") Reference processing support
 106   ReferenceProcessor* _ref_processor;
 107 
 108   // Performance Counters
 109   CollectorCounters* _gc_counters;
 110 
 111   // Statistics for garbage collection
 112   GCStats* _gc_stats;
 113 




 114   // Initialize the generation.
 115   Generation(ReservedSpace rs, size_t initial_byte_size);
 116 
 117   // Apply "cl->do_oop" to (the address of) (exactly) all the ref fields in
 118   // "sp" that point into younger generations.
 119   // The iteration is only over objects allocated at the start of the
 120   // iterations; objects allocated as a result of applying the closure are
 121   // not included.
 122   void younger_refs_in_space_iterate(Space* sp, OopsInGenClosure* cl);
 123 
 124  public:
 125   // The set of possible generation kinds.
 126   enum Name {
 127     DefNew,
 128     ParNew,
 129     MarkSweepCompact,
 130     ConcurrentMarkSweep,
 131     Other
 132   };
 133 
 134   enum Type {
 135     Young,
 136     Old
 137   };
 138 
 139   enum SomePublicConstants {
 140     // Generations are GenGrain-aligned and have size that are multiples of
 141     // GenGrain.
 142     // Note: on ARM we add 1 bit for card_table_base to be properly aligned
 143     // (we expect its low byte to be zero - see implementation of post_barrier)
 144     LogOfGenGrain = 16 ARM_ONLY(+1),
 145     GenGrain = 1 << LogOfGenGrain
 146   };
 147 
 148   // allocate and initialize ("weak") refs processing support
 149   virtual void ref_processor_init();
 150   void set_ref_processor(ReferenceProcessor* rp) {
 151     assert(_ref_processor == NULL, "clobbering existing _ref_processor");
 152     _ref_processor = rp;
 153   }
 154 
 155   virtual Generation::Name kind() { return Generation::Other; }
 156   GenerationSpec* spec();
 157 
 158   // This properly belongs in the collector, but for now this


 419     NOT_PRODUCT(
 420       if (now < _time_of_last_gc) {
 421         warning("time warp: "INT64_FORMAT" to "INT64_FORMAT, (int64_t)_time_of_last_gc, (int64_t)now);
 422       }
 423     )
 424     return _time_of_last_gc;
 425   }
 426 
 427   virtual void update_time_of_last_gc(jlong now)  {
 428     _time_of_last_gc = now;
 429   }
 430 
 431   // Generations may keep statistics about collection.  This
 432   // method updates those statistics.  current_level is
 433   // the level of the collection that has most recently
 434   // occurred.  This allows the generation to decide what
 435   // statistics are valid to collect.  For example, the
 436   // generation can decide to gather the amount of promoted data
 437   // if the collection of the younger generations has completed.
 438   GCStats* gc_stats() const { return _gc_stats; }
 439   virtual void update_gc_stats(Generation* current_generation, bool full) {}
 440 
 441   // Mark sweep support phase2
 442   virtual void prepare_for_compaction(CompactPoint* cp);
 443   // Mark sweep support phase3
 444   virtual void adjust_pointers();
 445   // Mark sweep support phase4
 446   virtual void compact();
 447   virtual void post_compact() {ShouldNotReachHere();}
 448 
 449   // Support for CMS's rescan. In this general form we return a pointer
 450   // to an abstract object that can be used, based on specific previously
 451   // decided protocols, to exchange information between generations,
 452   // information that may be useful for speeding up certain types of
 453   // garbage collectors. A NULL value indicates to the client that
 454   // no data recording is expected by the provider. The data-recorder is
 455   // expected to be GC worker thread-local, with the worker index
 456   // indicated by "thr_num".
 457   virtual void* get_data_recorder(int thr_num) { return NULL; }
 458   virtual void sample_eden_chunk() {}
 459 


 504   // if the requestor is a young generation and the target is older).
 505   // If the target generation can provide any scratch space, it adds
 506   // it to "list", leaving "list" pointing to the head of the
 507   // augmented list.  The default is to offer no space.
 508   virtual void contribute_scratch(ScratchBlock*& list, Generation* requestor,
 509                                   size_t max_alloc_words) {}
 510 
 511   // Give each generation an opportunity to do clean up for any
 512   // contributed scratch.
 513   virtual void reset_scratch() {};
 514 
 515   // When an older generation has been collected, and perhaps resized,
 516   // this method will be invoked on all younger generations (from older to
 517   // younger), allowing them to resize themselves as appropriate.
 518   virtual void compute_new_size() = 0;
 519 
 520   // Printing
 521   virtual const char* name() const = 0;
 522   virtual const char* short_name() const = 0;
 523 


 524   // Attributes
 525 
 526   // True iff the given generation may only be the youngest generation.
 527   virtual bool must_be_youngest() const = 0;
 528   // True iff the given generation may only be the oldest generation.
 529   virtual bool must_be_oldest() const = 0;
 530 
 531   // Reference Processing accessor
 532   ReferenceProcessor* const ref_processor() { return _ref_processor; }
 533 
 534   // Iteration.
 535 
 536   // Iterate over all the ref-containing fields of all objects in the
 537   // generation, calling "cl.do_oop" on each.
 538   virtual void oop_iterate(ExtendedOopClosure* cl);
 539 
 540   // Iterate over all objects in the generation, calling "cl.do_object" on
 541   // each.
 542   virtual void object_iterate(ObjectClosure* cl);
 543 


 617 
 618 class CardGeneration: public Generation {
 619   friend class VMStructs;
 620  protected:
 621   // This is shared with other generations.
 622   GenRemSet* _rs;
 623   // This is local to this generation.
 624   BlockOffsetSharedArray* _bts;
 625 
 626   // current shrinking effect: this damps shrinking when the heap gets empty.
 627   size_t _shrink_factor;
 628 
 629   size_t _min_heap_delta_bytes;   // Minimum amount to expand.
 630 
 631   // Some statistics from before gc started.
 632   // These are gathered in the gc_prologue (and should_collect)
 633   // to control growing/shrinking policy in spite of promotions.
 634   size_t _capacity_at_prologue;
 635   size_t _used_at_prologue;
 636 
 637   CardGeneration(ReservedSpace rs, size_t initial_byte_size, GenRemSet* remset);

 638 
 639  public:
 640 
 641   // Attempt to expand the generation by "bytes".  Expand by at a
 642   // minimum "expand_bytes".  Return true if some amount (not
 643   // necessarily the full "bytes") was done.
 644   virtual bool expand(size_t bytes, size_t expand_bytes);
 645 
 646   // Shrink generation with specified size (returns false if unable to shrink)
 647   virtual void shrink(size_t bytes) = 0;
 648 
 649   virtual void compute_new_size();
 650 
 651   virtual void clear_remembered_set();
 652 
 653   virtual void invalidate_remembered_set();
 654 
 655   virtual void prepare_for_verify();
 656 
 657   // Grow generation with specified size (returns false if unable to grow)


 674   ContiguousSpace*  _the_space;       // actual space holding objects
 675   WaterMark  _last_gc;                // watermark between objects allocated before
 676                                       // and after last GC.
 677 
 678   // Grow generation with specified size (returns false if unable to grow)
 679   virtual bool grow_by(size_t bytes);
 680   // Grow generation to reserved size.
 681   virtual bool grow_to_reserved();
 682   // Shrink generation with specified size (returns false if unable to shrink)
 683   void shrink_by(size_t bytes);
 684 
 685   // Allocation failure
 686   virtual bool expand(size_t bytes, size_t expand_bytes);
 687   void shrink(size_t bytes);
 688 
 689   // Accessing spaces
 690   ContiguousSpace* the_space() const { return _the_space; }
 691 
 692  public:
 693   OneContigSpaceCardGeneration(ReservedSpace rs, size_t initial_byte_size,
 694                                GenRemSet* remset, ContiguousSpace* space) :
 695     CardGeneration(rs, initial_byte_size, remset),

 696     _the_space(space)
 697   {}
 698 
 699   inline bool is_in(const void* p) const;
 700 
 701   // Space enquiries
 702   size_t capacity() const;
 703   size_t used() const;
 704   size_t free() const;
 705 
 706   MemRegion used_region() const;
 707 
 708   size_t unsafe_max_alloc_nogc() const;
 709   size_t contiguous_available() const;
 710 
 711   // Iteration
 712   void object_iterate(ObjectClosure* blk);
 713   void space_iterate(SpaceClosure* blk, bool usedOnly = false);
 714 
 715   void younger_refs_iterate(OopsInGenClosure* blk);


src/share/vm/memory/generation.hpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File