hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.hpp
changeset 28170 b985dc631984
parent 28163 322d55d167be
parent 28033 ab63acbd99ec
child 28511 3de39f0478f8
equal deleted inserted replaced
28167:f5a0bd510868 28170:b985dc631984
    28 #include "gc_implementation/shared/gcHeapSummary.hpp"
    28 #include "gc_implementation/shared/gcHeapSummary.hpp"
    29 #include "gc_implementation/shared/gSpaceCounters.hpp"
    29 #include "gc_implementation/shared/gSpaceCounters.hpp"
    30 #include "gc_implementation/shared/gcStats.hpp"
    30 #include "gc_implementation/shared/gcStats.hpp"
    31 #include "gc_implementation/shared/gcWhen.hpp"
    31 #include "gc_implementation/shared/gcWhen.hpp"
    32 #include "gc_implementation/shared/generationCounters.hpp"
    32 #include "gc_implementation/shared/generationCounters.hpp"
       
    33 #include "memory/cardGeneration.hpp"
    33 #include "memory/freeBlockDictionary.hpp"
    34 #include "memory/freeBlockDictionary.hpp"
    34 #include "memory/generation.hpp"
       
    35 #include "memory/iterator.hpp"
    35 #include "memory/iterator.hpp"
       
    36 #include "memory/space.hpp"
    36 #include "runtime/mutexLocker.hpp"
    37 #include "runtime/mutexLocker.hpp"
    37 #include "runtime/virtualspace.hpp"
    38 #include "runtime/virtualspace.hpp"
    38 #include "services/memoryService.hpp"
    39 #include "services/memoryService.hpp"
    39 #include "utilities/bitMap.inline.hpp"
    40 #include "utilities/bitMap.inline.hpp"
    40 #include "utilities/stack.inline.hpp"
    41 #include "utilities/stack.inline.hpp"
   169 };
   170 };
   170 
   171 
   171 // Represents a marking stack used by the CMS collector.
   172 // Represents a marking stack used by the CMS collector.
   172 // Ideally this should be GrowableArray<> just like MSC's marking stack(s).
   173 // Ideally this should be GrowableArray<> just like MSC's marking stack(s).
   173 class CMSMarkStack: public CHeapObj<mtGC>  {
   174 class CMSMarkStack: public CHeapObj<mtGC>  {
   174   //
       
   175   friend class CMSCollector;   // To get at expansion stats further below.
   175   friend class CMSCollector;   // To get at expansion stats further below.
   176   //
       
   177 
   176 
   178   VirtualSpace _virtual_space;  // Space for the stack
   177   VirtualSpace _virtual_space;  // Space for the stack
   179   oop*   _base;      // Bottom of stack
   178   oop*   _base;      // Bottom of stack
   180   size_t _index;     // One more than last occupied index
   179   size_t _index;     // One more than last occupied index
   181   size_t _capacity;  // Max #elements
   180   size_t _capacity;  // Max #elements
  1030 
  1029 
  1031   // accessors
  1030   // accessors
  1032   void set_expansion_cause(CMSExpansionCause::Cause v) { _expansion_cause = v;}
  1031   void set_expansion_cause(CMSExpansionCause::Cause v) { _expansion_cause = v;}
  1033   CMSExpansionCause::Cause expansion_cause() const { return _expansion_cause; }
  1032   CMSExpansionCause::Cause expansion_cause() const { return _expansion_cause; }
  1034 
  1033 
       
  1034   // Accessing spaces
       
  1035   CompactibleSpace* space() const { return (CompactibleSpace*)_cmsSpace; }
       
  1036 
  1035  private:
  1037  private:
  1036   // For parallel young-gen GC support.
  1038   // For parallel young-gen GC support.
  1037   CMSParGCThreadState** _par_gc_thread_states;
  1039   CMSParGCThreadState** _par_gc_thread_states;
  1038 
  1040 
  1039   // Reason generation was expanded
  1041   // Reason generation was expanded
  1062   size_t max_available() const;
  1064   size_t max_available() const;
  1063 
  1065 
  1064   // getter and initializer for _initiating_occupancy field.
  1066   // getter and initializer for _initiating_occupancy field.
  1065   double initiating_occupancy() const { return _initiating_occupancy; }
  1067   double initiating_occupancy() const { return _initiating_occupancy; }
  1066   void   init_initiating_occupancy(intx io, uintx tr);
  1068   void   init_initiating_occupancy(intx io, uintx tr);
       
  1069 
       
  1070   void expand_for_gc_cause(size_t bytes, size_t expand_bytes, CMSExpansionCause::Cause cause);
       
  1071 
       
  1072   void assert_correct_size_change_locking();
  1067 
  1073 
  1068  public:
  1074  public:
  1069   ConcurrentMarkSweepGeneration(ReservedSpace rs, size_t initial_byte_size,
  1075   ConcurrentMarkSweepGeneration(ReservedSpace rs, size_t initial_byte_size,
  1070                                 int level, CardTableRS* ct,
  1076                                 int level, CardTableRS* ct,
  1071                                 bool use_adaptive_freelists,
  1077                                 bool use_adaptive_freelists,
  1099   }
  1105   }
  1100 
  1106 
  1101   // Override
  1107   // Override
  1102   virtual void ref_processor_init();
  1108   virtual void ref_processor_init();
  1103 
  1109 
  1104   // Grow generation by specified size (returns false if unable to grow)
       
  1105   bool grow_by(size_t bytes);
       
  1106   // Grow generation to reserved size.
       
  1107   bool grow_to_reserved();
       
  1108 
       
  1109   void clear_expansion_cause() { _expansion_cause = CMSExpansionCause::_no_expansion; }
  1110   void clear_expansion_cause() { _expansion_cause = CMSExpansionCause::_no_expansion; }
  1110 
  1111 
  1111   // Space enquiries
  1112   // Space enquiries
  1112   size_t capacity() const;
       
  1113   size_t used() const;
       
  1114   size_t free() const;
       
  1115   double occupancy() const { return ((double)used())/((double)capacity()); }
  1113   double occupancy() const { return ((double)used())/((double)capacity()); }
  1116   size_t contiguous_available() const;
  1114   size_t contiguous_available() const;
  1117   size_t unsafe_max_alloc_nogc() const;
  1115   size_t unsafe_max_alloc_nogc() const;
  1118 
  1116 
  1119   // over-rides
  1117   // over-rides
  1120   MemRegion used_region() const;
       
  1121   MemRegion used_region_at_save_marks() const;
  1118   MemRegion used_region_at_save_marks() const;
  1122 
  1119 
  1123   // Does a "full" (forced) collection invoked on this generation collect
  1120   // Does a "full" (forced) collection invoked on this generation collect
  1124   // all younger generations as well? Note that the second conjunct is a
  1121   // all younger generations as well? Note that the second conjunct is a
  1125   // hack to allow the collection of the younger gen first if the flag is
  1122   // hack to allow the collection of the younger gen first if the flag is
  1126   // set.
  1123   // set.
  1127   virtual bool full_collects_younger_generations() const {
  1124   virtual bool full_collects_younger_generations() const {
  1128     return !ScavengeBeforeFullGC;
  1125     return !ScavengeBeforeFullGC;
  1129   }
  1126   }
  1130 
  1127 
  1131   void space_iterate(SpaceClosure* blk, bool usedOnly = false);
       
  1132 
       
  1133   // Support for compaction
       
  1134   CompactibleSpace* first_compaction_space() const;
       
  1135   // Adjust quantities in the generation affected by
  1128   // Adjust quantities in the generation affected by
  1136   // the compaction.
  1129   // the compaction.
  1137   void reset_after_compaction();
  1130   void reset_after_compaction();
  1138 
  1131 
  1139   // Allocation support
  1132   // Allocation support
  1189   void update_time_of_last_gc(jlong now) {
  1182   void update_time_of_last_gc(jlong now) {
  1190     collector()-> update_time_of_last_gc(now);
  1183     collector()-> update_time_of_last_gc(now);
  1191   }
  1184   }
  1192 
  1185 
  1193   // Allocation failure
  1186   // Allocation failure
  1194   void expand(size_t bytes, size_t expand_bytes,
       
  1195     CMSExpansionCause::Cause cause);
       
  1196   virtual bool expand(size_t bytes, size_t expand_bytes);
       
  1197   void shrink(size_t bytes);
  1187   void shrink(size_t bytes);
  1198   void shrink_by(size_t bytes);
       
  1199   HeapWord* expand_and_par_lab_allocate(CMSParGCThreadState* ps, size_t word_sz);
  1188   HeapWord* expand_and_par_lab_allocate(CMSParGCThreadState* ps, size_t word_sz);
  1200   bool expand_and_ensure_spooling_space(PromotionInfo* promo);
  1189   bool expand_and_ensure_spooling_space(PromotionInfo* promo);
  1201 
  1190 
  1202   // Iteration support and related enquiries
  1191   // Iteration support and related enquiries
  1203   void save_marks();
  1192   void save_marks();
  1204   bool no_allocs_since_save_marks();
  1193   bool no_allocs_since_save_marks();
  1205   void younger_refs_iterate(OopsInGenClosure* cl);
       
  1206 
  1194 
  1207   // Iteration support specific to CMS generations
  1195   // Iteration support specific to CMS generations
  1208   void save_sweep_limit();
  1196   void save_sweep_limit();
  1209 
  1197 
  1210   // More iteration support
  1198   // More iteration support