< prev index next >

src/hotspot/share/gc/g1/g1BlockOffsetTable.hpp

Print this page
rev 55196 : 8225716: G1 GC: Undefined behaviour in G1BlockOffsetTablePart::block_at_or_preceding
Reviewed-by: duke


  48 
  49 private:
  50   // The reserved region covered by the table.
  51   MemRegion _reserved;
  52 
  53   // Array for keeping offsets for retrieving object start fast given an
  54   // address.
  55   u_char* _offset_array;          // byte array keeping backwards offsets
  56 
  57   void check_offset(size_t offset, const char* msg) const {
  58     assert(offset <= BOTConstants::N_words,
  59            "%s - offset: " SIZE_FORMAT ", N_words: %u",
  60            msg, offset, BOTConstants::N_words);
  61   }
  62 
  63   // Bounds checking accessors:
  64   // For performance these have to devolve to array accesses in product builds.
  65   inline u_char offset_array(size_t index) const;
  66 
  67   void set_offset_array_raw(size_t index, u_char offset) {
  68     _offset_array[index] = offset;
  69   }
  70 
  71   inline void set_offset_array(size_t index, u_char offset);
  72 
  73   inline void set_offset_array(size_t index, HeapWord* high, HeapWord* low);
  74 
  75   inline void set_offset_array(size_t left, size_t right, u_char offset);
  76 
  77   bool is_card_boundary(HeapWord* p) const;
  78 
  79   void check_index(size_t index, const char* msg) const NOT_DEBUG_RETURN;
  80 
  81 public:
  82 
  83   // Return the number of slots needed for an offset array
  84   // that covers mem_region_words words.
  85   static size_t compute_size(size_t mem_region_words) {
  86     size_t number_of_slots = (mem_region_words / BOTConstants::N_words);
  87     return ReservedSpace::allocation_align_size_up(number_of_slots);
  88   }




  48 
  49 private:
  50   // The reserved region covered by the table.
  51   MemRegion _reserved;
  52 
  53   // Array for keeping offsets for retrieving object start fast given an
  54   // address.
  55   u_char* _offset_array;          // byte array keeping backwards offsets
  56 
  57   void check_offset(size_t offset, const char* msg) const {
  58     assert(offset <= BOTConstants::N_words,
  59            "%s - offset: " SIZE_FORMAT ", N_words: %u",
  60            msg, offset, BOTConstants::N_words);
  61   }
  62 
  63   // Bounds checking accessors:
  64   // For performance these have to devolve to array accesses in product builds.
  65   inline u_char offset_array(size_t index) const;
  66 
  67   void set_offset_array_raw(size_t index, u_char offset) {
  68     Atomic::store(offset, &_offset_array[index]);
  69   }
  70 
  71   inline void set_offset_array(size_t index, u_char offset);
  72 
  73   inline void set_offset_array(size_t index, HeapWord* high, HeapWord* low);
  74 
  75   inline void set_offset_array(size_t left, size_t right, u_char offset);
  76 
  77   bool is_card_boundary(HeapWord* p) const;
  78 
  79   void check_index(size_t index, const char* msg) const NOT_DEBUG_RETURN;
  80 
  81 public:
  82 
  83   // Return the number of slots needed for an offset array
  84   // that covers mem_region_words words.
  85   static size_t compute_size(size_t mem_region_words) {
  86     size_t number_of_slots = (mem_region_words / BOTConstants::N_words);
  87     return ReservedSpace::allocation_align_size_up(number_of_slots);
  88   }


< prev index next >