< prev index next >

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

Print this page




  62   // Value is always pointer-size aligned.
  63   size_t _capacity_in_bytes;
  64 
  65   static const size_t _element_size = sizeof(void*);
  66 
  67   // Get the capacity, in bytes.  The capacity must have been set.
  68   size_t capacity_in_bytes() const {
  69     assert(_capacity_in_bytes > 0, "capacity not set");
  70     return _capacity_in_bytes;
  71   }
  72 
  73   void set_capacity(size_t entries) {
  74     size_t byte_capacity = index_to_byte_index(entries);
  75     assert(_capacity_in_bytes == 0 || _capacity_in_bytes == byte_capacity,
  76            "changing capacity " SIZE_FORMAT " -> " SIZE_FORMAT,
  77            _capacity_in_bytes, byte_capacity);
  78     _capacity_in_bytes = byte_capacity;
  79   }
  80 
  81   static size_t byte_index_to_index(size_t ind) {
  82     assert(is_size_aligned(ind, _element_size), "precondition");
  83     return ind / _element_size;
  84   }
  85 
  86   static size_t index_to_byte_index(size_t ind) {
  87     return ind * _element_size;
  88   }
  89 
  90 protected:
  91   // The buffer.
  92   void** _buf;
  93 
  94   size_t index() const {
  95     return byte_index_to_index(_index);
  96   }
  97 
  98   void set_index(size_t new_index) {
  99     size_t byte_index = index_to_byte_index(new_index);
 100     assert(byte_index <= capacity_in_bytes(), "precondition");
 101     _index = byte_index;
 102   }




  62   // Value is always pointer-size aligned.
  63   size_t _capacity_in_bytes;
  64 
  65   static const size_t _element_size = sizeof(void*);
  66 
  67   // Get the capacity, in bytes.  The capacity must have been set.
  68   size_t capacity_in_bytes() const {
  69     assert(_capacity_in_bytes > 0, "capacity not set");
  70     return _capacity_in_bytes;
  71   }
  72 
  73   void set_capacity(size_t entries) {
  74     size_t byte_capacity = index_to_byte_index(entries);
  75     assert(_capacity_in_bytes == 0 || _capacity_in_bytes == byte_capacity,
  76            "changing capacity " SIZE_FORMAT " -> " SIZE_FORMAT,
  77            _capacity_in_bytes, byte_capacity);
  78     _capacity_in_bytes = byte_capacity;
  79   }
  80 
  81   static size_t byte_index_to_index(size_t ind) {
  82     assert(is_aligned(ind, _element_size), "precondition");
  83     return ind / _element_size;
  84   }
  85 
  86   static size_t index_to_byte_index(size_t ind) {
  87     return ind * _element_size;
  88   }
  89 
  90 protected:
  91   // The buffer.
  92   void** _buf;
  93 
  94   size_t index() const {
  95     return byte_index_to_index(_index);
  96   }
  97 
  98   void set_index(size_t new_index) {
  99     size_t byte_index = index_to_byte_index(new_index);
 100     assert(byte_index <= capacity_in_bytes(), "precondition");
 101     _index = byte_index;
 102   }


< prev index next >