< prev index next >

src/share/vm/gc/g1/heapRegion.hpp

Print this page
rev 13284 : imported patch 8184346-cleanup-g1cmbitmap
rev 13286 : imported patch 8184346-erikd-mgerdin-review


  39 // can be collected independently.
  40 
  41 // NOTE: Although a HeapRegion is a Space, its
  42 // Space::initDirtyCardClosure method must not be called.
  43 // The problem is that the existence of this method breaks
  44 // the independence of barrier sets from remembered sets.
  45 // The solution is to remove this method from the definition
  46 // of a Space.
  47 
  48 // Each heap region is self contained. top() and end() can never
  49 // be set beyond the end of the region. For humongous objects,
  50 // the first region is a StartsHumongous region. If the humongous
  51 // object is larger than a heap region, the following regions will
  52 // be of type ContinuesHumongous. In this case the top() of the
  53 // StartHumongous region and all ContinuesHumongous regions except
  54 // the last will point to their own end. The last ContinuesHumongous
  55 // region may have top() equal the end of object if there isn't
  56 // room for filler objects to pad out to the end of the region.
  57 
  58 class G1CollectedHeap;
  59 class G1CMBitMapRO;
  60 class HeapRegionRemSet;
  61 class HeapRegionRemSetIterator;
  62 class HeapRegion;
  63 class HeapRegionSetBase;
  64 class nmethod;
  65 
  66 #define HR_FORMAT "%u:(%s)[" PTR_FORMAT "," PTR_FORMAT "," PTR_FORMAT "]"
  67 #define HR_FORMAT_PARAMS(_hr_) \
  68                 (_hr_)->hrm_index(), \
  69                 (_hr_)->get_short_type_str(), \
  70                 p2i((_hr_)->bottom()), p2i((_hr_)->top()), p2i((_hr_)->end())
  71 
  72 // sentinel value for hrm_index
  73 #define G1_NO_HRM_INDEX ((uint) -1)
  74 
  75 // The complicating factor is that BlockOffsetTable diverged
  76 // significantly, and we need functionality that is only in the G1 version.
  77 // So I copied that code, which led to an alternate G1 version of
  78 // OffsetTableContigSpace.  If the two versions of BlockOffsetTable could
  79 // be reconciled, then G1OffsetTableContigSpace could go away.


 208   // See comments for CompactibleSpace for more information.
 209   inline HeapWord* scan_limit() const {
 210     return top();
 211   }
 212 
 213   inline bool scanned_block_is_obj(const HeapWord* addr) const {
 214     return true; // Always true, since scan_limit is top
 215   }
 216 
 217   inline size_t scanned_block_size(const HeapWord* addr) const {
 218     return HeapRegion::block_size(addr); // Avoid virtual call
 219   }
 220 
 221   void report_region_type_change(G1HeapRegionTraceType::Type to);
 222 
 223   // Returns whether the given object address refers to a dead object, and either the
 224   // size of the object (if live) or the size of the block (if dead) in size.
 225   // May
 226   // - only called with obj < top()
 227   // - not called on humongous objects or archive regions
 228   inline bool is_obj_dead_with_size(const oop obj, G1CMBitMapRO* prev_bitmap, size_t* size) const;
 229 
 230  protected:
 231   // The index of this region in the heap region sequence.
 232   uint  _hrm_index;
 233 
 234   AllocationContext_t _allocation_context;
 235 
 236   HeapRegionType _type;
 237 
 238   // For a humongous region, region in which it starts.
 239   HeapRegion* _humongous_start_region;
 240 
 241   // True iff an attempt to evacuate an object in the region failed.
 242   bool _evacuation_failed;
 243 
 244   // Fields used by the HeapRegionSetBase class and subclasses.
 245   HeapRegion* _next;
 246   HeapRegion* _prev;
 247 #ifdef ASSERT
 248   HeapRegionSetBase* _containing_set;


 284 
 285   // The RSet length that was added to the total value
 286   // for the collection set.
 287   size_t _recorded_rs_length;
 288 
 289   // The predicted elapsed time that was added to total value
 290   // for the collection set.
 291   double _predicted_elapsed_time_ms;
 292 
 293   // Iterate over the references in a humongous objects and apply the given closure
 294   // to them.
 295   // Humongous objects are allocated directly in the old-gen. So we need special
 296   // handling for concurrent processing encountering an in-progress allocation.
 297   template <class Closure, bool is_gc_active>
 298   inline bool do_oops_on_card_in_humongous(MemRegion mr,
 299                                            Closure* cl,
 300                                            G1CollectedHeap* g1h);
 301 
 302   // Returns the block size of the given (dead, potentially having its class unloaded) object
 303   // starting at p extending to at most the prev TAMS using the given mark bitmap.
 304   inline size_t block_size_using_bitmap(const HeapWord* p, const G1CMBitMapRO* prev_bitmap) const;
 305  public:
 306   HeapRegion(uint hrm_index,
 307              G1BlockOffsetTable* bot,
 308              MemRegion mr);
 309 
 310   // Initializing the HeapRegion not only resets the data structure, but also
 311   // resets the BOT for that heap region.
 312   // The default values for clear_space means that we will do the clearing if
 313   // there's clearing to be done ourselves. We also always mangle the space.
 314   virtual void initialize(MemRegion mr, bool clear_space = false, bool mangle_space = SpaceDecorator::Mangle);
 315 
 316   static int    LogOfHRGrainBytes;
 317   static int    LogOfHRGrainWords;
 318 
 319   static size_t GrainBytes;
 320   static size_t GrainWords;
 321   static size_t CardsPerRegion;
 322 
 323   static size_t align_up_to_region_byte_size(size_t sz) {
 324     return (sz + (size_t) GrainBytes - 1) &


 332     assert(p != NULL, "p can't be NULL");
 333     assert(obj != NULL, "obj can't be NULL");
 334     return (((uintptr_t) p ^ cast_from_oop<uintptr_t>(obj)) >> LogOfHRGrainBytes) == 0;
 335   }
 336 
 337   static size_t max_region_size();
 338   static size_t min_region_size_in_words();
 339 
 340   // It sets up the heap region size (GrainBytes / GrainWords), as
 341   // well as other related fields that are based on the heap region
 342   // size (LogOfHRGrainBytes / LogOfHRGrainWords /
 343   // CardsPerRegion). All those fields are considered constant
 344   // throughout the JVM's execution, therefore they should only be set
 345   // up once during initialization time.
 346   static void setup_heap_region_size(size_t initial_heap_size, size_t max_heap_size);
 347 
 348   // All allocated blocks are occupied by objects in a HeapRegion
 349   bool block_is_obj(const HeapWord* p) const;
 350 
 351   // Returns whether the given object is dead based on TAMS and bitmap.
 352   bool is_obj_dead(const oop obj, const G1CMBitMapRO* prev_bitmap) const;
 353 
 354   // Returns the object size for all valid block starts
 355   // and the amount of unallocated words if called on top()
 356   size_t block_size(const HeapWord* p) const;
 357 
 358   // Override for scan_and_forward support.
 359   void prepare_for_compaction(CompactPoint* cp);
 360 
 361   inline HeapWord* par_allocate_no_bot_updates(size_t min_word_size, size_t desired_word_size, size_t* word_size);
 362   inline HeapWord* allocate_no_bot_updates(size_t word_size);
 363   inline HeapWord* allocate_no_bot_updates(size_t min_word_size, size_t desired_word_size, size_t* actual_size);
 364 
 365   // If this region is a member of a HeapRegionManager, the index in that
 366   // sequence, otherwise -1.
 367   uint hrm_index() const { return _hrm_index; }
 368 
 369   // The number of bytes marked live in the region in the last marking phase.
 370   size_t marked_bytes()    { return _prev_marked_bytes; }
 371   size_t live_bytes() {
 372     return (top() - prev_top_at_mark_start()) * HeapWordSize + marked_bytes();




  39 // can be collected independently.
  40 
  41 // NOTE: Although a HeapRegion is a Space, its
  42 // Space::initDirtyCardClosure method must not be called.
  43 // The problem is that the existence of this method breaks
  44 // the independence of barrier sets from remembered sets.
  45 // The solution is to remove this method from the definition
  46 // of a Space.
  47 
  48 // Each heap region is self contained. top() and end() can never
  49 // be set beyond the end of the region. For humongous objects,
  50 // the first region is a StartsHumongous region. If the humongous
  51 // object is larger than a heap region, the following regions will
  52 // be of type ContinuesHumongous. In this case the top() of the
  53 // StartHumongous region and all ContinuesHumongous regions except
  54 // the last will point to their own end. The last ContinuesHumongous
  55 // region may have top() equal the end of object if there isn't
  56 // room for filler objects to pad out to the end of the region.
  57 
  58 class G1CollectedHeap;
  59 class G1CMBitMap;
  60 class HeapRegionRemSet;
  61 class HeapRegionRemSetIterator;
  62 class HeapRegion;
  63 class HeapRegionSetBase;
  64 class nmethod;
  65 
  66 #define HR_FORMAT "%u:(%s)[" PTR_FORMAT "," PTR_FORMAT "," PTR_FORMAT "]"
  67 #define HR_FORMAT_PARAMS(_hr_) \
  68                 (_hr_)->hrm_index(), \
  69                 (_hr_)->get_short_type_str(), \
  70                 p2i((_hr_)->bottom()), p2i((_hr_)->top()), p2i((_hr_)->end())
  71 
  72 // sentinel value for hrm_index
  73 #define G1_NO_HRM_INDEX ((uint) -1)
  74 
  75 // The complicating factor is that BlockOffsetTable diverged
  76 // significantly, and we need functionality that is only in the G1 version.
  77 // So I copied that code, which led to an alternate G1 version of
  78 // OffsetTableContigSpace.  If the two versions of BlockOffsetTable could
  79 // be reconciled, then G1OffsetTableContigSpace could go away.


 208   // See comments for CompactibleSpace for more information.
 209   inline HeapWord* scan_limit() const {
 210     return top();
 211   }
 212 
 213   inline bool scanned_block_is_obj(const HeapWord* addr) const {
 214     return true; // Always true, since scan_limit is top
 215   }
 216 
 217   inline size_t scanned_block_size(const HeapWord* addr) const {
 218     return HeapRegion::block_size(addr); // Avoid virtual call
 219   }
 220 
 221   void report_region_type_change(G1HeapRegionTraceType::Type to);
 222 
 223   // Returns whether the given object address refers to a dead object, and either the
 224   // size of the object (if live) or the size of the block (if dead) in size.
 225   // May
 226   // - only called with obj < top()
 227   // - not called on humongous objects or archive regions
 228   inline bool is_obj_dead_with_size(const oop obj, const G1CMBitMap* const prev_bitmap, size_t* size) const;
 229 
 230  protected:
 231   // The index of this region in the heap region sequence.
 232   uint  _hrm_index;
 233 
 234   AllocationContext_t _allocation_context;
 235 
 236   HeapRegionType _type;
 237 
 238   // For a humongous region, region in which it starts.
 239   HeapRegion* _humongous_start_region;
 240 
 241   // True iff an attempt to evacuate an object in the region failed.
 242   bool _evacuation_failed;
 243 
 244   // Fields used by the HeapRegionSetBase class and subclasses.
 245   HeapRegion* _next;
 246   HeapRegion* _prev;
 247 #ifdef ASSERT
 248   HeapRegionSetBase* _containing_set;


 284 
 285   // The RSet length that was added to the total value
 286   // for the collection set.
 287   size_t _recorded_rs_length;
 288 
 289   // The predicted elapsed time that was added to total value
 290   // for the collection set.
 291   double _predicted_elapsed_time_ms;
 292 
 293   // Iterate over the references in a humongous objects and apply the given closure
 294   // to them.
 295   // Humongous objects are allocated directly in the old-gen. So we need special
 296   // handling for concurrent processing encountering an in-progress allocation.
 297   template <class Closure, bool is_gc_active>
 298   inline bool do_oops_on_card_in_humongous(MemRegion mr,
 299                                            Closure* cl,
 300                                            G1CollectedHeap* g1h);
 301 
 302   // Returns the block size of the given (dead, potentially having its class unloaded) object
 303   // starting at p extending to at most the prev TAMS using the given mark bitmap.
 304   inline size_t block_size_using_bitmap(const HeapWord* p, const G1CMBitMap* const prev_bitmap) const;
 305  public:
 306   HeapRegion(uint hrm_index,
 307              G1BlockOffsetTable* bot,
 308              MemRegion mr);
 309 
 310   // Initializing the HeapRegion not only resets the data structure, but also
 311   // resets the BOT for that heap region.
 312   // The default values for clear_space means that we will do the clearing if
 313   // there's clearing to be done ourselves. We also always mangle the space.
 314   virtual void initialize(MemRegion mr, bool clear_space = false, bool mangle_space = SpaceDecorator::Mangle);
 315 
 316   static int    LogOfHRGrainBytes;
 317   static int    LogOfHRGrainWords;
 318 
 319   static size_t GrainBytes;
 320   static size_t GrainWords;
 321   static size_t CardsPerRegion;
 322 
 323   static size_t align_up_to_region_byte_size(size_t sz) {
 324     return (sz + (size_t) GrainBytes - 1) &


 332     assert(p != NULL, "p can't be NULL");
 333     assert(obj != NULL, "obj can't be NULL");
 334     return (((uintptr_t) p ^ cast_from_oop<uintptr_t>(obj)) >> LogOfHRGrainBytes) == 0;
 335   }
 336 
 337   static size_t max_region_size();
 338   static size_t min_region_size_in_words();
 339 
 340   // It sets up the heap region size (GrainBytes / GrainWords), as
 341   // well as other related fields that are based on the heap region
 342   // size (LogOfHRGrainBytes / LogOfHRGrainWords /
 343   // CardsPerRegion). All those fields are considered constant
 344   // throughout the JVM's execution, therefore they should only be set
 345   // up once during initialization time.
 346   static void setup_heap_region_size(size_t initial_heap_size, size_t max_heap_size);
 347 
 348   // All allocated blocks are occupied by objects in a HeapRegion
 349   bool block_is_obj(const HeapWord* p) const;
 350 
 351   // Returns whether the given object is dead based on TAMS and bitmap.
 352   bool is_obj_dead(const oop obj, const G1CMBitMap* const prev_bitmap) const;
 353 
 354   // Returns the object size for all valid block starts
 355   // and the amount of unallocated words if called on top()
 356   size_t block_size(const HeapWord* p) const;
 357 
 358   // Override for scan_and_forward support.
 359   void prepare_for_compaction(CompactPoint* cp);
 360 
 361   inline HeapWord* par_allocate_no_bot_updates(size_t min_word_size, size_t desired_word_size, size_t* word_size);
 362   inline HeapWord* allocate_no_bot_updates(size_t word_size);
 363   inline HeapWord* allocate_no_bot_updates(size_t min_word_size, size_t desired_word_size, size_t* actual_size);
 364 
 365   // If this region is a member of a HeapRegionManager, the index in that
 366   // sequence, otherwise -1.
 367   uint hrm_index() const { return _hrm_index; }
 368 
 369   // The number of bytes marked live in the region in the last marking phase.
 370   size_t marked_bytes()    { return _prev_marked_bytes; }
 371   size_t live_bytes() {
 372     return (top() - prev_top_at_mark_start()) * HeapWordSize + marked_bytes();


< prev index next >