hotspot/src/share/vm/gc/shared/generation.hpp
changeset 32623 390a27af5657
parent 31358 693058672cc6
child 33205 bc9fec5e7656
equal deleted inserted replaced
32622:7ed47d0b888a 32623:390a27af5657
    78   size_t num_words;
    78   size_t num_words;
    79   HeapWord scratch_space[1];  // Actually, of size "num_words-2" (assuming
    79   HeapWord scratch_space[1];  // Actually, of size "num_words-2" (assuming
    80                               // first two fields are word-sized.)
    80                               // first two fields are word-sized.)
    81 };
    81 };
    82 
    82 
    83 
       
    84 class Generation: public CHeapObj<mtGC> {
    83 class Generation: public CHeapObj<mtGC> {
    85   friend class VMStructs;
    84   friend class VMStructs;
    86  private:
    85  private:
    87   jlong _time_of_last_gc; // time when last gc on this generation happened (ms)
    86   jlong _time_of_last_gc; // time when last gc on this generation happened (ms)
    88   MemRegion _prev_used_region; // for collectors that want to "remember" a value for
    87   MemRegion _prev_used_region; // for collectors that want to "remember" a value for
   297   // "word_sz".  If possible, allocate space for "obj", copy obj into it
   296   // "word_sz".  If possible, allocate space for "obj", copy obj into it
   298   // (taking care to copy "m" into the mark word when done, since the mark
   297   // (taking care to copy "m" into the mark word when done, since the mark
   299   // word of "obj" may have been overwritten with a forwarding pointer, and
   298   // word of "obj" may have been overwritten with a forwarding pointer, and
   300   // also taking care to copy the klass pointer *last*.  Returns the new
   299   // also taking care to copy the klass pointer *last*.  Returns the new
   301   // object if successful, or else NULL.
   300   // object if successful, or else NULL.
   302   virtual oop par_promote(int thread_num,
   301   virtual oop par_promote(int thread_num, oop obj, markOop m, size_t word_sz);
   303                           oop obj, markOop m, size_t word_sz);
       
   304 
   302 
   305   // Informs the current generation that all par_promote_alloc's in the
   303   // Informs the current generation that all par_promote_alloc's in the
   306   // collection have been completed; any supporting data structures can be
   304   // collection have been completed; any supporting data structures can be
   307   // reset.  Default is to do nothing.
   305   // reset.  Default is to do nothing.
   308   virtual void par_promote_alloc_done(int thread_num) {}
   306   virtual void par_promote_alloc_done(int thread_num) {}
   313   // do nothing.
   311   // do nothing.
   314   virtual void par_oop_since_save_marks_iterate_done(int thread_num) {}
   312   virtual void par_oop_since_save_marks_iterate_done(int thread_num) {}
   315 
   313 
   316   // This generation will collect all younger generations
   314   // This generation will collect all younger generations
   317   // during a full collection.
   315   // during a full collection.
   318   virtual bool full_collects_younger_generations() const { return false; }
   316   virtual bool full_collects_young_generation() const { return false; }
   319 
   317 
   320   // This generation does in-place marking, meaning that mark words
   318   // This generation does in-place marking, meaning that mark words
   321   // are mutated during the marking phase and presumably reinitialized
   319   // are mutated during the marking phase and presumably reinitialized
   322   // to a canonical value after the GC. This is currently used by the
   320   // to a canonical value after the GC. This is currently used by the
   323   // biased locking implementation to determine whether additional
   321   // biased locking implementation to determine whether additional
   368                                         bool is_tlab,
   366                                         bool is_tlab,
   369                                         bool parallel = false) = 0;
   367                                         bool parallel = false) = 0;
   370 
   368 
   371   // Some generations may require some cleanup or preparation actions before
   369   // Some generations may require some cleanup or preparation actions before
   372   // allowing a collection.  The default is to do nothing.
   370   // allowing a collection.  The default is to do nothing.
   373   virtual void gc_prologue(bool full) {};
   371   virtual void gc_prologue(bool full) {}
   374 
   372 
   375   // Some generations may require some cleanup actions after a collection.
   373   // Some generations may require some cleanup actions after a collection.
   376   // The default is to do nothing.
   374   // The default is to do nothing.
   377   virtual void gc_epilogue(bool full) {};
   375   virtual void gc_epilogue(bool full) {}
   378 
   376 
   379   // Save the high water marks for the used space in a generation.
   377   // Save the high water marks for the used space in a generation.
   380   virtual void record_spaces_top() {};
   378   virtual void record_spaces_top() {}
   381 
   379 
   382   // Some generations may need to be "fixed-up" after some allocation
   380   // Some generations may need to be "fixed-up" after some allocation
   383   // activity to make them parsable again. The default is to do nothing.
   381   // activity to make them parsable again. The default is to do nothing.
   384   virtual void ensure_parsability() {};
   382   virtual void ensure_parsability() {}
   385 
   383 
   386   // Time (in ms) when we were last collected or now if a collection is
   384   // Time (in ms) when we were last collected or now if a collection is
   387   // in progress.
   385   // in progress.
   388   virtual jlong time_of_last_gc(jlong now) {
   386   virtual jlong time_of_last_gc(jlong now) {
   389     // Both _time_of_last_gc and now are set using a time source
   387     // Both _time_of_last_gc and now are set using a time source
   415   virtual void prepare_for_compaction(CompactPoint* cp);
   413   virtual void prepare_for_compaction(CompactPoint* cp);
   416   // Mark sweep support phase3
   414   // Mark sweep support phase3
   417   virtual void adjust_pointers();
   415   virtual void adjust_pointers();
   418   // Mark sweep support phase4
   416   // Mark sweep support phase4
   419   virtual void compact();
   417   virtual void compact();
   420   virtual void post_compact() {ShouldNotReachHere();}
   418   virtual void post_compact() { ShouldNotReachHere(); }
   421 
   419 
   422   // Support for CMS's rescan. In this general form we return a pointer
   420   // Support for CMS's rescan. In this general form we return a pointer
   423   // to an abstract object that can be used, based on specific previously
   421   // to an abstract object that can be used, based on specific previously
   424   // decided protocols, to exchange information between generations,
   422   // decided protocols, to exchange information between generations,
   425   // information that may be useful for speeding up certain types of
   423   // information that may be useful for speeding up certain types of
   430   virtual void* get_data_recorder(int thr_num) { return NULL; }
   428   virtual void* get_data_recorder(int thr_num) { return NULL; }
   431   virtual void sample_eden_chunk() {}
   429   virtual void sample_eden_chunk() {}
   432 
   430 
   433   // Some generations may require some cleanup actions before allowing
   431   // Some generations may require some cleanup actions before allowing
   434   // a verification.
   432   // a verification.
   435   virtual void prepare_for_verify() {};
   433   virtual void prepare_for_verify() {}
   436 
   434 
   437   // Accessing "marks".
   435   // Accessing "marks".
   438 
   436 
   439   // This function gives a generation a chance to note a point between
   437   // This function gives a generation a chance to note a point between
   440   // collections.  For example, a contiguous generation might note the
   438   // collections.  For example, a contiguous generation might note the
   481   virtual void contribute_scratch(ScratchBlock*& list, Generation* requestor,
   479   virtual void contribute_scratch(ScratchBlock*& list, Generation* requestor,
   482                                   size_t max_alloc_words) {}
   480                                   size_t max_alloc_words) {}
   483 
   481 
   484   // Give each generation an opportunity to do clean up for any
   482   // Give each generation an opportunity to do clean up for any
   485   // contributed scratch.
   483   // contributed scratch.
   486   virtual void reset_scratch() {};
   484   virtual void reset_scratch() {}
   487 
   485 
   488   // When an older generation has been collected, and perhaps resized,
   486   // When an older generation has been collected, and perhaps resized,
   489   // this method will be invoked on all younger generations (from older to
   487   // this method will be invoked on all younger generations (from older to
   490   // younger), allowing them to resize themselves as appropriate.
   488   // younger), allowing them to resize themselves as appropriate.
   491   virtual void compute_new_size() = 0;
   489   virtual void compute_new_size() = 0;