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

Print this page
rev 4802 : imported patch optimize-nmethod-scanning
rev 4803 : imported patch thomas-comments-2


  35 #include "utilities/macros.hpp"
  36 
  37 #if INCLUDE_ALL_GCS
  38 
  39 // A HeapRegion is the smallest piece of a G1CollectedHeap that
  40 // can be collected independently.
  41 
  42 // NOTE: Although a HeapRegion is a Space, its
  43 // Space::initDirtyCardClosure method must not be called.
  44 // The problem is that the existence of this method breaks
  45 // the independence of barrier sets from remembered sets.
  46 // The solution is to remove this method from the definition
  47 // of a Space.
  48 
  49 class CompactibleSpace;
  50 class ContiguousSpace;
  51 class HeapRegionRemSet;
  52 class HeapRegionRemSetIterator;
  53 class HeapRegion;
  54 class HeapRegionSetBase;

  55 
  56 #define HR_FORMAT "%u:(%s)["PTR_FORMAT","PTR_FORMAT","PTR_FORMAT"]"
  57 #define HR_FORMAT_PARAMS(_hr_) \
  58                 (_hr_)->hrs_index(), \
  59                 (_hr_)->is_survivor() ? "S" : (_hr_)->is_young() ? "E" : \
  60                 (_hr_)->startsHumongous() ? "HS" : \
  61                 (_hr_)->continuesHumongous() ? "HC" : \
  62                 !(_hr_)->is_empty() ? "O" : "F", \
  63                 (_hr_)->bottom(), (_hr_)->top(), (_hr_)->end()
  64 
  65 // sentinel value for hrs_index
  66 #define G1_NULL_HRS_INDEX ((uint) -1)
  67 
  68 // A dirty card to oop closure for heap regions. It
  69 // knows how to get the G1 heap and how to use the bitmap
  70 // in the concurrent marker used by G1 to filter remembered
  71 // sets.
  72 
  73 class HeapRegionDCTOC : public ContiguousSpaceDCTOC {
  74 public:


 354                                       ~((1 << (size_t) LogOfHRGrainBytes) - 1);
 355   }
 356 
 357   // It sets up the heap region size (GrainBytes / GrainWords), as
 358   // well as other related fields that are based on the heap region
 359   // size (LogOfHRGrainBytes / LogOfHRGrainWords /
 360   // CardsPerRegion). All those fields are considered constant
 361   // throughout the JVM's execution, therefore they should only be set
 362   // up once during initialization time.
 363   static void setup_heap_region_size(uintx min_heap_size);
 364 
 365   enum ClaimValues {
 366     InitialClaimValue          = 0,
 367     FinalCountClaimValue       = 1,
 368     NoteEndClaimValue          = 2,
 369     ScrubRemSetClaimValue      = 3,
 370     ParVerifyClaimValue        = 4,
 371     RebuildRSClaimValue        = 5,
 372     ParEvacFailureClaimValue   = 6,
 373     AggregateCountClaimValue   = 7,
 374     VerifyCountClaimValue      = 8

 375   };
 376 
 377   inline HeapWord* par_allocate_no_bot_updates(size_t word_size) {
 378     assert(is_young(), "we can only skip BOT updates on young regions");
 379     return ContiguousSpace::par_allocate(word_size);
 380   }
 381   inline HeapWord* allocate_no_bot_updates(size_t word_size) {
 382     assert(is_young(), "we can only skip BOT updates on young regions");
 383     return ContiguousSpace::allocate(word_size);
 384   }
 385 
 386   // If this region is a member of a HeapRegionSeq, the index in that
 387   // sequence, otherwise -1.
 388   uint hrs_index() const { return _hrs_index; }
 389 
 390   // The number of bytes marked live in the region in the last marking phase.
 391   size_t marked_bytes()    { return _prev_marked_bytes; }
 392   size_t live_bytes() {
 393     return (top() - prev_top_at_mark_start()) * HeapWordSize + marked_bytes();
 394   }


 779   void set_recorded_rs_length(size_t rs_length) {
 780     _recorded_rs_length = rs_length;
 781   }
 782 
 783   void set_predicted_elapsed_time_ms(double ms) {
 784     _predicted_elapsed_time_ms = ms;
 785   }
 786 
 787   void set_predicted_bytes_to_copy(size_t bytes) {
 788     _predicted_bytes_to_copy = bytes;
 789   }
 790 
 791 #define HeapRegion_OOP_SINCE_SAVE_MARKS_DECL(OopClosureType, nv_suffix)  \
 792   virtual void oop_since_save_marks_iterate##nv_suffix(OopClosureType* cl);
 793   SPECIALIZED_SINCE_SAVE_MARKS_CLOSURES(HeapRegion_OOP_SINCE_SAVE_MARKS_DECL)
 794 
 795   virtual CompactibleSpace* next_compaction_space() const;
 796 
 797   virtual void reset_after_compaction();
 798 



















 799   void print() const;
 800   void print_on(outputStream* st) const;
 801 
 802   // vo == UsePrevMarking  -> use "prev" marking information,
 803   // vo == UseNextMarking -> use "next" marking information
 804   // vo == UseMarkWord    -> use the mark word in the object header
 805   //
 806   // NOTE: Only the "prev" marking information is guaranteed to be
 807   // consistent most of the time, so most calls to this should use
 808   // vo == UsePrevMarking.
 809   // Currently, there is only one case where this is called with
 810   // vo == UseNextMarking, which is to verify the "next" marking
 811   // information at the end of remark.
 812   // Currently there is only one place where this is called with
 813   // vo == UseMarkWord, which is to verify the marking during a
 814   // full GC.
 815   void verify(VerifyOption vo, bool *failures) const;
 816 
 817   // Override; it uses the "prev" marking information
 818   virtual void verify() const;




  35 #include "utilities/macros.hpp"
  36 
  37 #if INCLUDE_ALL_GCS
  38 
  39 // A HeapRegion is the smallest piece of a G1CollectedHeap that
  40 // can be collected independently.
  41 
  42 // NOTE: Although a HeapRegion is a Space, its
  43 // Space::initDirtyCardClosure method must not be called.
  44 // The problem is that the existence of this method breaks
  45 // the independence of barrier sets from remembered sets.
  46 // The solution is to remove this method from the definition
  47 // of a Space.
  48 
  49 class CompactibleSpace;
  50 class ContiguousSpace;
  51 class HeapRegionRemSet;
  52 class HeapRegionRemSetIterator;
  53 class HeapRegion;
  54 class HeapRegionSetBase;
  55 class nmethod;
  56 
  57 #define HR_FORMAT "%u:(%s)["PTR_FORMAT","PTR_FORMAT","PTR_FORMAT"]"
  58 #define HR_FORMAT_PARAMS(_hr_) \
  59                 (_hr_)->hrs_index(), \
  60                 (_hr_)->is_survivor() ? "S" : (_hr_)->is_young() ? "E" : \
  61                 (_hr_)->startsHumongous() ? "HS" : \
  62                 (_hr_)->continuesHumongous() ? "HC" : \
  63                 !(_hr_)->is_empty() ? "O" : "F", \
  64                 (_hr_)->bottom(), (_hr_)->top(), (_hr_)->end()
  65 
  66 // sentinel value for hrs_index
  67 #define G1_NULL_HRS_INDEX ((uint) -1)
  68 
  69 // A dirty card to oop closure for heap regions. It
  70 // knows how to get the G1 heap and how to use the bitmap
  71 // in the concurrent marker used by G1 to filter remembered
  72 // sets.
  73 
  74 class HeapRegionDCTOC : public ContiguousSpaceDCTOC {
  75 public:


 355                                       ~((1 << (size_t) LogOfHRGrainBytes) - 1);
 356   }
 357 
 358   // It sets up the heap region size (GrainBytes / GrainWords), as
 359   // well as other related fields that are based on the heap region
 360   // size (LogOfHRGrainBytes / LogOfHRGrainWords /
 361   // CardsPerRegion). All those fields are considered constant
 362   // throughout the JVM's execution, therefore they should only be set
 363   // up once during initialization time.
 364   static void setup_heap_region_size(uintx min_heap_size);
 365 
 366   enum ClaimValues {
 367     InitialClaimValue          = 0,
 368     FinalCountClaimValue       = 1,
 369     NoteEndClaimValue          = 2,
 370     ScrubRemSetClaimValue      = 3,
 371     ParVerifyClaimValue        = 4,
 372     RebuildRSClaimValue        = 5,
 373     ParEvacFailureClaimValue   = 6,
 374     AggregateCountClaimValue   = 7,
 375     VerifyCountClaimValue      = 8,
 376     ParMarkRootClaimValue      = 9
 377   };
 378 
 379   inline HeapWord* par_allocate_no_bot_updates(size_t word_size) {
 380     assert(is_young(), "we can only skip BOT updates on young regions");
 381     return ContiguousSpace::par_allocate(word_size);
 382   }
 383   inline HeapWord* allocate_no_bot_updates(size_t word_size) {
 384     assert(is_young(), "we can only skip BOT updates on young regions");
 385     return ContiguousSpace::allocate(word_size);
 386   }
 387 
 388   // If this region is a member of a HeapRegionSeq, the index in that
 389   // sequence, otherwise -1.
 390   uint hrs_index() const { return _hrs_index; }
 391 
 392   // The number of bytes marked live in the region in the last marking phase.
 393   size_t marked_bytes()    { return _prev_marked_bytes; }
 394   size_t live_bytes() {
 395     return (top() - prev_top_at_mark_start()) * HeapWordSize + marked_bytes();
 396   }


 781   void set_recorded_rs_length(size_t rs_length) {
 782     _recorded_rs_length = rs_length;
 783   }
 784 
 785   void set_predicted_elapsed_time_ms(double ms) {
 786     _predicted_elapsed_time_ms = ms;
 787   }
 788 
 789   void set_predicted_bytes_to_copy(size_t bytes) {
 790     _predicted_bytes_to_copy = bytes;
 791   }
 792 
 793 #define HeapRegion_OOP_SINCE_SAVE_MARKS_DECL(OopClosureType, nv_suffix)  \
 794   virtual void oop_since_save_marks_iterate##nv_suffix(OopClosureType* cl);
 795   SPECIALIZED_SINCE_SAVE_MARKS_CLOSURES(HeapRegion_OOP_SINCE_SAVE_MARKS_DECL)
 796 
 797   virtual CompactibleSpace* next_compaction_space() const;
 798 
 799   virtual void reset_after_compaction();
 800 
 801   // Routines for managing a list of code roots (attached to the
 802   // this region's RSet) that point into this heap region.
 803   void add_strong_code_root(nmethod* nm);
 804   void remove_strong_code_root(nmethod* nm);
 805 
 806   // During a collection, migrate the successfully evacuated
 807   // strong code roots that referenced into this region to the
 808   // new regions that they now point into. Unsuccessfully
 809   // evacuated code roots are not migrated.
 810   void migrate_strong_code_roots();
 811 
 812   // Applies blk->do_code_blob() to each of the entries in
 813   // the strong code roots list for this region
 814   void strong_code_roots_do(CodeBlobClosure* blk) const;
 815 
 816   // Verify that the entries on the strong code root list for this
 817   // region are live and include at least one pointer into this region.
 818   void verify_strong_code_roots(VerifyOption vo, bool* failures) const;
 819 
 820   void print() const;
 821   void print_on(outputStream* st) const;
 822 
 823   // vo == UsePrevMarking  -> use "prev" marking information,
 824   // vo == UseNextMarking -> use "next" marking information
 825   // vo == UseMarkWord    -> use the mark word in the object header
 826   //
 827   // NOTE: Only the "prev" marking information is guaranteed to be
 828   // consistent most of the time, so most calls to this should use
 829   // vo == UsePrevMarking.
 830   // Currently, there is only one case where this is called with
 831   // vo == UseNextMarking, which is to verify the "next" marking
 832   // information at the end of remark.
 833   // Currently there is only one place where this is called with
 834   // vo == UseMarkWord, which is to verify the marking during a
 835   // full GC.
 836   void verify(VerifyOption vo, bool *failures) const;
 837 
 838   // Override; it uses the "prev" marking information
 839   virtual void verify() const;