< prev index next >

src/share/vm/memory/defNewGeneration.hpp

Print this page
rev 7209 : [mq]: inccms


  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_MEMORY_DEFNEWGENERATION_HPP
  26 #define SHARE_VM_MEMORY_DEFNEWGENERATION_HPP
  27 
  28 #include "gc_implementation/shared/ageTable.hpp"
  29 #include "gc_implementation/shared/cSpaceCounters.hpp"
  30 #include "gc_implementation/shared/generationCounters.hpp"
  31 #include "gc_implementation/shared/copyFailedInfo.hpp"
  32 #include "memory/generation.inline.hpp"
  33 #include "utilities/stack.hpp"
  34 
  35 class EdenSpace;
  36 class ContiguousSpace;
  37 class ScanClosure;
  38 class STWGCTimer;
  39 
  40 // DefNewGeneration is a young generation containing eden, from- and
  41 // to-space.
  42 
  43 class DefNewGeneration: public Generation {
  44   friend class VMStructs;
  45 
  46 protected:
  47   Generation* _next_gen;
  48   uint        _tenuring_threshold;   // Tenuring threshold for next collection.
  49   ageTable    _age_table;
  50   // Size of object to pretenure in words; command line provides bytes
  51   size_t      _pretenure_size_threshold_words;
  52 
  53   ageTable*   age_table() { return &_age_table; }
  54 
  55   // Initialize state to optimistically assume no promotion failure will


 115   // sizing information
 116   size_t               _max_eden_size;
 117   size_t               _max_survivor_size;
 118 
 119   // Allocation support
 120   bool _should_allocate_from_space;
 121   bool should_allocate_from_space() const {
 122     return _should_allocate_from_space;
 123   }
 124   void clear_should_allocate_from_space() {
 125     _should_allocate_from_space = false;
 126   }
 127   void set_should_allocate_from_space() {
 128     _should_allocate_from_space = true;
 129   }
 130 
 131   // Tenuring
 132   void adjust_desired_tenuring_threshold();
 133 
 134   // Spaces
 135   EdenSpace*       _eden_space;
 136   ContiguousSpace* _from_space;
 137   ContiguousSpace* _to_space;
 138 
 139   STWGCTimer* _gc_timer;
 140 
 141   enum SomeProtectedConstants {
 142     // Generations are GenGrain-aligned and have size that are multiples of
 143     // GenGrain.
 144     MinFreeScratchWords = 100
 145   };
 146 
 147   // Return the size of a survivor space if this generation were of size
 148   // gen_size.
 149   size_t compute_survivor_size(size_t gen_size, size_t alignment) const {
 150     size_t n = gen_size / (SurvivorRatio + 2);
 151     return n > alignment ? align_size_down(n, alignment) : alignment;
 152   }
 153 
 154  public:  // was "protected" but caused compile error on win32
 155   class IsAliveClosure: public BoolObjectClosure {


 197     DefNewGeneration* _gen;
 198     FastScanClosure* _scan_cur_or_nonheap;
 199     FastScanClosure* _scan_older;
 200   public:
 201     FastEvacuateFollowersClosure(GenCollectedHeap* gch, int level,
 202                                  DefNewGeneration* gen,
 203                                  FastScanClosure* cur,
 204                                  FastScanClosure* older);
 205     void do_void();
 206   };
 207 
 208  public:
 209   DefNewGeneration(ReservedSpace rs, size_t initial_byte_size, int level,
 210                    const char* policy="Copy");
 211 
 212   virtual void ref_processor_init();
 213 
 214   virtual Generation::Name kind() { return Generation::DefNew; }
 215 
 216   // Accessing spaces
 217   EdenSpace*       eden() const           { return _eden_space; }
 218   ContiguousSpace* from() const           { return _from_space;  }
 219   ContiguousSpace* to()   const           { return _to_space;    }
 220 
 221   virtual CompactibleSpace* first_compaction_space() const;
 222 
 223   // Space enquiries
 224   size_t capacity() const;
 225   size_t used() const;
 226   size_t free() const;
 227   size_t max_capacity() const;
 228   size_t capacity_before_gc() const;
 229   size_t unsafe_max_alloc_nogc() const;
 230   size_t contiguous_available() const;
 231 
 232   size_t max_eden_size() const              { return _max_eden_size; }
 233   size_t max_survivor_size() const          { return _max_survivor_size; }
 234 
 235   bool supports_inline_contig_alloc() const { return true; }
 236   HeapWord** top_addr() const;
 237   HeapWord** end_addr() const;


 265     size_t overflow_limit    = (size_t)1 << (BitsPerSize_t - LogHeapWordSize);
 266 
 267     const bool non_zero      = word_size > 0;
 268     const bool overflows     = word_size >= overflow_limit;
 269     const bool check_too_big = _pretenure_size_threshold_words > 0;
 270     const bool not_too_big   = word_size < _pretenure_size_threshold_words;
 271     const bool size_ok       = is_tlab || !check_too_big || not_too_big;
 272 
 273     bool result = !overflows &&
 274                   non_zero   &&
 275                   size_ok;
 276 
 277     return result;
 278   }
 279 
 280   HeapWord* allocate(size_t word_size, bool is_tlab);
 281   HeapWord* allocate_from_space(size_t word_size);
 282 
 283   HeapWord* par_allocate(size_t word_size, bool is_tlab);
 284 
 285   // Prologue & Epilogue
 286   virtual void gc_prologue(bool full);
 287   virtual void gc_epilogue(bool full);
 288 
 289   // Save the tops for eden, from, and to
 290   virtual void record_spaces_top();
 291 
 292   // Doesn't require additional work during GC prologue and epilogue
 293   virtual bool performs_in_place_marking() const { return false; }
 294 
 295   // Accessing marks
 296   void save_marks();
 297   void reset_saved_marks();
 298   bool no_allocs_since_save_marks();
 299 
 300   // Need to declare the full complement of closures, whether we'll
 301   // override them or not, or get message from the compiler:
 302   //   oop_since_save_marks_iterate_nv hides virtual function...
 303 #define DefNew_SINCE_SAVE_MARKS_DECL(OopClosureType, nv_suffix) \
 304   void oop_since_save_marks_iterate##nv_suffix(OopClosureType* cl);
 305 
 306   ALL_SINCE_SAVE_MARKS_CLOSURES(DefNew_SINCE_SAVE_MARKS_DECL)




  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_MEMORY_DEFNEWGENERATION_HPP
  26 #define SHARE_VM_MEMORY_DEFNEWGENERATION_HPP
  27 
  28 #include "gc_implementation/shared/ageTable.hpp"
  29 #include "gc_implementation/shared/cSpaceCounters.hpp"
  30 #include "gc_implementation/shared/generationCounters.hpp"
  31 #include "gc_implementation/shared/copyFailedInfo.hpp"
  32 #include "memory/generation.inline.hpp"
  33 #include "utilities/stack.hpp"
  34 

  35 class ContiguousSpace;
  36 class ScanClosure;
  37 class STWGCTimer;
  38 
  39 // DefNewGeneration is a young generation containing eden, from- and
  40 // to-space.
  41 
  42 class DefNewGeneration: public Generation {
  43   friend class VMStructs;
  44 
  45 protected:
  46   Generation* _next_gen;
  47   uint        _tenuring_threshold;   // Tenuring threshold for next collection.
  48   ageTable    _age_table;
  49   // Size of object to pretenure in words; command line provides bytes
  50   size_t      _pretenure_size_threshold_words;
  51 
  52   ageTable*   age_table() { return &_age_table; }
  53 
  54   // Initialize state to optimistically assume no promotion failure will


 114   // sizing information
 115   size_t               _max_eden_size;
 116   size_t               _max_survivor_size;
 117 
 118   // Allocation support
 119   bool _should_allocate_from_space;
 120   bool should_allocate_from_space() const {
 121     return _should_allocate_from_space;
 122   }
 123   void clear_should_allocate_from_space() {
 124     _should_allocate_from_space = false;
 125   }
 126   void set_should_allocate_from_space() {
 127     _should_allocate_from_space = true;
 128   }
 129 
 130   // Tenuring
 131   void adjust_desired_tenuring_threshold();
 132 
 133   // Spaces
 134   ContiguousSpace* _eden_space;
 135   ContiguousSpace* _from_space;
 136   ContiguousSpace* _to_space;
 137 
 138   STWGCTimer* _gc_timer;
 139 
 140   enum SomeProtectedConstants {
 141     // Generations are GenGrain-aligned and have size that are multiples of
 142     // GenGrain.
 143     MinFreeScratchWords = 100
 144   };
 145 
 146   // Return the size of a survivor space if this generation were of size
 147   // gen_size.
 148   size_t compute_survivor_size(size_t gen_size, size_t alignment) const {
 149     size_t n = gen_size / (SurvivorRatio + 2);
 150     return n > alignment ? align_size_down(n, alignment) : alignment;
 151   }
 152 
 153  public:  // was "protected" but caused compile error on win32
 154   class IsAliveClosure: public BoolObjectClosure {


 196     DefNewGeneration* _gen;
 197     FastScanClosure* _scan_cur_or_nonheap;
 198     FastScanClosure* _scan_older;
 199   public:
 200     FastEvacuateFollowersClosure(GenCollectedHeap* gch, int level,
 201                                  DefNewGeneration* gen,
 202                                  FastScanClosure* cur,
 203                                  FastScanClosure* older);
 204     void do_void();
 205   };
 206 
 207  public:
 208   DefNewGeneration(ReservedSpace rs, size_t initial_byte_size, int level,
 209                    const char* policy="Copy");
 210 
 211   virtual void ref_processor_init();
 212 
 213   virtual Generation::Name kind() { return Generation::DefNew; }
 214 
 215   // Accessing spaces
 216   ContiguousSpace* eden() const           { return _eden_space; }
 217   ContiguousSpace* from() const           { return _from_space; }
 218   ContiguousSpace* to()   const           { return _to_space;   }
 219 
 220   virtual CompactibleSpace* first_compaction_space() const;
 221 
 222   // Space enquiries
 223   size_t capacity() const;
 224   size_t used() const;
 225   size_t free() const;
 226   size_t max_capacity() const;
 227   size_t capacity_before_gc() const;
 228   size_t unsafe_max_alloc_nogc() const;
 229   size_t contiguous_available() const;
 230 
 231   size_t max_eden_size() const              { return _max_eden_size; }
 232   size_t max_survivor_size() const          { return _max_survivor_size; }
 233 
 234   bool supports_inline_contig_alloc() const { return true; }
 235   HeapWord** top_addr() const;
 236   HeapWord** end_addr() const;


 264     size_t overflow_limit    = (size_t)1 << (BitsPerSize_t - LogHeapWordSize);
 265 
 266     const bool non_zero      = word_size > 0;
 267     const bool overflows     = word_size >= overflow_limit;
 268     const bool check_too_big = _pretenure_size_threshold_words > 0;
 269     const bool not_too_big   = word_size < _pretenure_size_threshold_words;
 270     const bool size_ok       = is_tlab || !check_too_big || not_too_big;
 271 
 272     bool result = !overflows &&
 273                   non_zero   &&
 274                   size_ok;
 275 
 276     return result;
 277   }
 278 
 279   HeapWord* allocate(size_t word_size, bool is_tlab);
 280   HeapWord* allocate_from_space(size_t word_size);
 281 
 282   HeapWord* par_allocate(size_t word_size, bool is_tlab);
 283 


 284   virtual void gc_epilogue(bool full);
 285 
 286   // Save the tops for eden, from, and to
 287   virtual void record_spaces_top();
 288 
 289   // Doesn't require additional work during GC prologue and epilogue
 290   virtual bool performs_in_place_marking() const { return false; }
 291 
 292   // Accessing marks
 293   void save_marks();
 294   void reset_saved_marks();
 295   bool no_allocs_since_save_marks();
 296 
 297   // Need to declare the full complement of closures, whether we'll
 298   // override them or not, or get message from the compiler:
 299   //   oop_since_save_marks_iterate_nv hides virtual function...
 300 #define DefNew_SINCE_SAVE_MARKS_DECL(OopClosureType, nv_suffix) \
 301   void oop_since_save_marks_iterate##nv_suffix(OopClosureType* cl);
 302 
 303   ALL_SINCE_SAVE_MARKS_CLOSURES(DefNew_SINCE_SAVE_MARKS_DECL)


< prev index next >