src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.hpp

Print this page




  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  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_IMPLEMENTATION_CONCURRENTMARKSWEEP_CONCURRENTMARKSWEEPGENERATION_HPP
  26 #define SHARE_VM_GC_IMPLEMENTATION_CONCURRENTMARKSWEEP_CONCURRENTMARKSWEEPGENERATION_HPP
  27 
  28 #include "gc_implementation/shared/gcHeapSummary.hpp"
  29 #include "gc_implementation/shared/gSpaceCounters.hpp"
  30 #include "gc_implementation/shared/gcStats.hpp"

  31 #include "gc_implementation/shared/gcWhen.hpp"
  32 #include "gc_implementation/shared/generationCounters.hpp"
  33 #include "memory/freeBlockDictionary.hpp"
  34 #include "memory/generation.hpp"
  35 #include "memory/iterator.hpp"
  36 #include "runtime/mutexLocker.hpp"
  37 #include "runtime/virtualspace.hpp"
  38 #include "services/memoryService.hpp"
  39 #include "utilities/bitMap.inline.hpp"
  40 #include "utilities/stack.inline.hpp"
  41 #include "utilities/taskqueue.hpp"
  42 #include "utilities/yieldingWorkgroup.hpp"
  43 
  44 // ConcurrentMarkSweepGeneration is in support of a concurrent
  45 // mark-sweep old generation in the Detlefs-Printezis--Boehm-Demers-Schenker
  46 // style. We assume, for now, that this generation is always the
  47 // seniormost generation and for simplicity
  48 // in the first implementation, that this generation is a single compactible
  49 // space. Neither of these restrictions appears essential, and will be
  50 // relaxed in the future when more time is available to implement the


1161   CompactibleSpace* first_compaction_space() const;
1162   // Adjust quantities in the generation affected by
1163   // the compaction.
1164   void reset_after_compaction();
1165 
1166   // Allocation support
1167   HeapWord* allocate(size_t size, bool tlab);
1168   HeapWord* have_lock_and_allocate(size_t size, bool tlab);
1169   oop       promote(oop obj, size_t obj_size);
1170   HeapWord* par_allocate(size_t size, bool tlab) {
1171     return allocate(size, tlab);
1172   }
1173 
1174 
1175   // Used by CMSStats to track direct allocation.  The value is sampled and
1176   // reset after each young gen collection.
1177   size_t direct_allocated_words() const { return _direct_allocated_words; }
1178   void reset_direct_allocated_words()   { _direct_allocated_words = 0; }
1179 
1180   // Overrides for parallel promotion.
1181   virtual oop par_promote(int thread_num,

1182                           oop obj, markOop m, size_t word_sz);
1183   // This one should not be called for CMS.
1184   virtual void par_promote_alloc_undo(int thread_num,
1185                                       HeapWord* obj, size_t word_sz);
1186   virtual void par_promote_alloc_done(int thread_num);
1187   virtual void par_oop_since_save_marks_iterate_done(int thread_num);
1188 
1189   virtual bool promotion_attempt_is_safe(size_t promotion_in_bytes) const;
1190 
1191   // Inform this (non-young) generation that a promotion failure was
1192   // encountered during a collection of a younger generation that
1193   // promotes into this generation.
1194   virtual void promotion_failure_occurred();
1195 
1196   bool should_collect(bool full, size_t size, bool tlab);
1197   virtual bool should_concurrent_collect() const;
1198   virtual bool is_too_full() const;
1199   void collect(bool   full,
1200                bool   clear_all_soft_refs,
1201                size_t size,


1209   void gc_prologue(bool full);
1210   void gc_prologue_work(bool full, bool registerClosure,
1211                         ModUnionClosure* modUnionClosure);
1212   void gc_epilogue(bool full);
1213   void gc_epilogue_work(bool full);
1214 
1215   // Time since last GC of this generation
1216   jlong time_of_last_gc(jlong now) {
1217     return collector()->time_of_last_gc(now);
1218   }
1219   void update_time_of_last_gc(jlong now) {
1220     collector()-> update_time_of_last_gc(now);
1221   }
1222 
1223   // Allocation failure
1224   void expand(size_t bytes, size_t expand_bytes,
1225     CMSExpansionCause::Cause cause);
1226   virtual bool expand(size_t bytes, size_t expand_bytes);
1227   void shrink(size_t bytes);
1228   void shrink_by(size_t bytes);
1229   HeapWord* expand_and_par_lab_allocate(CMSParGCThreadState* ps, size_t word_sz);




1230   bool expand_and_ensure_spooling_space(PromotionInfo* promo);
1231 
1232   // Iteration support and related enquiries
1233   void save_marks();
1234   bool no_allocs_since_save_marks();
1235   void younger_refs_iterate(OopsInGenClosure* cl);
1236 
1237   // Iteration support specific to CMS generations
1238   void save_sweep_limit();
1239 
1240   // More iteration support
1241   virtual void oop_iterate(ExtendedOopClosure* cl);
1242   virtual void safe_object_iterate(ObjectClosure* cl);
1243   virtual void object_iterate(ObjectClosure* cl);
1244 
1245   // Need to declare the full complement of closures, whether we'll
1246   // override them or not, or get message from the compiler:
1247   //   oop_since_save_marks_iterate_nv hides virtual function...
1248   #define CMS_SINCE_SAVE_MARKS_DECL(OopClosureType, nv_suffix) \
1249     void oop_since_save_marks_iterate##nv_suffix(OopClosureType* cl);




  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  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_IMPLEMENTATION_CONCURRENTMARKSWEEP_CONCURRENTMARKSWEEPGENERATION_HPP
  26 #define SHARE_VM_GC_IMPLEMENTATION_CONCURRENTMARKSWEEP_CONCURRENTMARKSWEEPGENERATION_HPP
  27 
  28 #include "gc_implementation/shared/gcHeapSummary.hpp"
  29 #include "gc_implementation/shared/gSpaceCounters.hpp"
  30 #include "gc_implementation/shared/gcStats.hpp"
  31 #include "gc_implementation/shared/gcTrace.hpp"
  32 #include "gc_implementation/shared/gcWhen.hpp"
  33 #include "gc_implementation/shared/generationCounters.hpp"
  34 #include "memory/freeBlockDictionary.hpp"
  35 #include "memory/generation.hpp"
  36 #include "memory/iterator.hpp"
  37 #include "runtime/mutexLocker.hpp"
  38 #include "runtime/virtualspace.hpp"
  39 #include "services/memoryService.hpp"
  40 #include "utilities/bitMap.inline.hpp"
  41 #include "utilities/stack.inline.hpp"
  42 #include "utilities/taskqueue.hpp"
  43 #include "utilities/yieldingWorkgroup.hpp"
  44 
  45 // ConcurrentMarkSweepGeneration is in support of a concurrent
  46 // mark-sweep old generation in the Detlefs-Printezis--Boehm-Demers-Schenker
  47 // style. We assume, for now, that this generation is always the
  48 // seniormost generation and for simplicity
  49 // in the first implementation, that this generation is a single compactible
  50 // space. Neither of these restrictions appears essential, and will be
  51 // relaxed in the future when more time is available to implement the


1162   CompactibleSpace* first_compaction_space() const;
1163   // Adjust quantities in the generation affected by
1164   // the compaction.
1165   void reset_after_compaction();
1166 
1167   // Allocation support
1168   HeapWord* allocate(size_t size, bool tlab);
1169   HeapWord* have_lock_and_allocate(size_t size, bool tlab);
1170   oop       promote(oop obj, size_t obj_size);
1171   HeapWord* par_allocate(size_t size, bool tlab) {
1172     return allocate(size, tlab);
1173   }
1174 
1175 
1176   // Used by CMSStats to track direct allocation.  The value is sampled and
1177   // reset after each young gen collection.
1178   size_t direct_allocated_words() const { return _direct_allocated_words; }
1179   void reset_direct_allocated_words()   { _direct_allocated_words = 0; }
1180 
1181   // Overrides for parallel promotion.
1182   virtual oop par_promote(const ParNewTracer* gc_tracer,
1183                           int thread_num,
1184                           oop obj, markOop m, size_t word_sz);
1185   // This one should not be called for CMS.
1186   virtual void par_promote_alloc_undo(int thread_num,
1187                                       HeapWord* obj, size_t word_sz);
1188   virtual void par_promote_alloc_done(int thread_num);
1189   virtual void par_oop_since_save_marks_iterate_done(int thread_num);
1190 
1191   virtual bool promotion_attempt_is_safe(size_t promotion_in_bytes) const;
1192 
1193   // Inform this (non-young) generation that a promotion failure was
1194   // encountered during a collection of a younger generation that
1195   // promotes into this generation.
1196   virtual void promotion_failure_occurred();
1197 
1198   bool should_collect(bool full, size_t size, bool tlab);
1199   virtual bool should_concurrent_collect() const;
1200   virtual bool is_too_full() const;
1201   void collect(bool   full,
1202                bool   clear_all_soft_refs,
1203                size_t size,


1211   void gc_prologue(bool full);
1212   void gc_prologue_work(bool full, bool registerClosure,
1213                         ModUnionClosure* modUnionClosure);
1214   void gc_epilogue(bool full);
1215   void gc_epilogue_work(bool full);
1216 
1217   // Time since last GC of this generation
1218   jlong time_of_last_gc(jlong now) {
1219     return collector()->time_of_last_gc(now);
1220   }
1221   void update_time_of_last_gc(jlong now) {
1222     collector()-> update_time_of_last_gc(now);
1223   }
1224 
1225   // Allocation failure
1226   void expand(size_t bytes, size_t expand_bytes,
1227     CMSExpansionCause::Cause cause);
1228   virtual bool expand(size_t bytes, size_t expand_bytes);
1229   void shrink(size_t bytes);
1230   void shrink_by(size_t bytes);
1231   // The oop (old) is used to extract information for promotion trace event
1232   HeapWord* expand_and_par_lab_allocate(CMSParGCThreadState* ps, 
1233                                         const ParNewTracer* gc_tracer, 
1234                                         size_t word_sz,
1235                                         const oop old, const markOop m);
1236   bool expand_and_ensure_spooling_space(PromotionInfo* promo);
1237 
1238   // Iteration support and related enquiries
1239   void save_marks();
1240   bool no_allocs_since_save_marks();
1241   void younger_refs_iterate(OopsInGenClosure* cl);
1242 
1243   // Iteration support specific to CMS generations
1244   void save_sweep_limit();
1245 
1246   // More iteration support
1247   virtual void oop_iterate(ExtendedOopClosure* cl);
1248   virtual void safe_object_iterate(ObjectClosure* cl);
1249   virtual void object_iterate(ObjectClosure* cl);
1250 
1251   // Need to declare the full complement of closures, whether we'll
1252   // override them or not, or get message from the compiler:
1253   //   oop_since_save_marks_iterate_nv hides virtual function...
1254   #define CMS_SINCE_SAVE_MARKS_DECL(OopClosureType, nv_suffix) \
1255     void oop_since_save_marks_iterate##nv_suffix(OopClosureType* cl);