111
112 // Set the element of the given array at the given index to the
113 // given value. Assume the index is valid. This is a convenience
114 // method that does sanity checking on the index.
115 void set_by_index(idx_t index, T value) {
116 verify_index(index);
117 this->base()[index] = value;
118 }
119
120 // The raw biased base pointer.
121 T* biased_base() const { return (T*)G1BiasedMappedArrayBase::_biased_base; }
122
123 // Return the element of the given array that covers the given word in the
124 // heap. Assumes the index is valid.
125 T get_by_address(HeapWord* value) const {
126 idx_t biased_index = ((uintptr_t)value) >> this->shift_by();
127 this->verify_biased_index(biased_index);
128 return biased_base()[biased_index];
129 }
130
131 // Return as a uint the index of the element of the given array that
132 // covers the given word in the heap.
133 uint get_index_by_address(HeapWord* value) const {
134 idx_t biased_index = ((uintptr_t)value) >> this->shift_by();
135 this->verify_biased_index(biased_index);
136 return (uint)biased_index - (uint)_bias;
137 }
138
139 // Set the value of the array entry that corresponds to the given array.
140 void set_by_address(HeapWord * address, T value) {
141 idx_t biased_index = ((uintptr_t)address) >> this->shift_by();
142 this->verify_biased_index(biased_index);
143 biased_base()[biased_index] = value;
144 }
145
146 protected:
147 // Returns the address of the element the given address maps to
148 T* address_mapped_to(HeapWord* address) {
149 idx_t biased_index = ((uintptr_t)address) >> this->shift_by();
150 this->verify_biased_index_inclusive_end(biased_index);
151 return biased_base() + biased_index;
152 }
153
154 public:
155 // Return the smallest address (inclusive) in the heap that this array covers.
156 HeapWord* bottom_address_mapped() const {
157 return (HeapWord*) ((uintptr_t)this->bias() << this->shift_by());
158 }
159
160 // Return the highest address (exclusive) in the heap that this array covers.
161 HeapWord* end_address_mapped() const {
162 return (HeapWord*) ((uintptr_t)(this->bias() + this->length()) << this->shift_by());
163 }
|
111
112 // Set the element of the given array at the given index to the
113 // given value. Assume the index is valid. This is a convenience
114 // method that does sanity checking on the index.
115 void set_by_index(idx_t index, T value) {
116 verify_index(index);
117 this->base()[index] = value;
118 }
119
120 // The raw biased base pointer.
121 T* biased_base() const { return (T*)G1BiasedMappedArrayBase::_biased_base; }
122
123 // Return the element of the given array that covers the given word in the
124 // heap. Assumes the index is valid.
125 T get_by_address(HeapWord* value) const {
126 idx_t biased_index = ((uintptr_t)value) >> this->shift_by();
127 this->verify_biased_index(biased_index);
128 return biased_base()[biased_index];
129 }
130
131 // Return the index of the element of the given array that covers the given
132 // word in the heap.
133 idx_t get_index_by_address(HeapWord* value) const {
134 idx_t biased_index = ((uintptr_t)value) >> this->shift_by();
135 this->verify_biased_index(biased_index);
136 return biased_index - _bias;
137 }
138
139 // Set the value of the array entry that corresponds to the given array.
140 void set_by_address(HeapWord * address, T value) {
141 idx_t biased_index = ((uintptr_t)address) >> this->shift_by();
142 this->verify_biased_index(biased_index);
143 biased_base()[biased_index] = value;
144 }
145
146 // Set the value of all array entries that correspond to addresses
147 // in the specified MemRegion.
148 void set_by_address(MemRegion range, T value) {
149 idx_t biased_start = ((uintptr_t)range.start()) >> this->shift_by();
150 idx_t biased_last = ((uintptr_t)range.last()) >> this->shift_by();
151 this->verify_biased_index(biased_start);
152 this->verify_biased_index(biased_last);
153 for (idx_t i = biased_start; i <= biased_last; i++) {
154 biased_base()[i] = value;
155 }
156 }
157
158 protected:
159 // Returns the address of the element the given address maps to
160 T* address_mapped_to(HeapWord* address) {
161 idx_t biased_index = ((uintptr_t)address) >> this->shift_by();
162 this->verify_biased_index_inclusive_end(biased_index);
163 return biased_base() + biased_index;
164 }
165
166 public:
167 // Return the smallest address (inclusive) in the heap that this array covers.
168 HeapWord* bottom_address_mapped() const {
169 return (HeapWord*) ((uintptr_t)this->bias() << this->shift_by());
170 }
171
172 // Return the highest address (exclusive) in the heap that this array covers.
173 HeapWord* end_address_mapped() const {
174 return (HeapWord*) ((uintptr_t)(this->bias() + this->length()) << this->shift_by());
175 }
|