174 bool is_humongous_continuation() const { return _state == _humongous_cont; }
175
176 // Participation in logical groups:
177 bool is_empty() const { return is_empty_committed() || is_empty_uncommitted(); }
178 bool is_active() const { return !is_empty() && !is_trash(); }
179 bool is_trash() const { return _state == _trash; }
180 bool is_humongous_start() const { return _state == _humongous_start || _state == _pinned_humongous_start; }
181 bool is_humongous() const { return is_humongous_start() || is_humongous_continuation(); }
182 bool is_committed() const { return !is_empty_uncommitted(); }
183 bool is_cset() const { return _state == _cset || _state == _pinned_cset; }
184 bool is_pinned() const { return _state == _pinned || _state == _pinned_cset || _state == _pinned_humongous_start; }
185
186 // Macro-properties:
187 bool is_alloc_allowed() const { return is_empty() || is_regular() || _state == _pinned; }
188 bool is_move_allowed() const { return is_regular() || _state == _cset || (ShenandoahHumongousMoves && _state == _humongous_start); }
189
190 RegionState state() const { return _state; }
191 int state_ordinal() const { return region_state_to_ordinal(_state); }
192
193 private:
194 static size_t RegionSizeBytes;
195 static size_t RegionSizeWords;
196 static size_t RegionSizeBytesShift;
197 static size_t RegionSizeWordsShift;
198 static size_t RegionSizeBytesMask;
199 static size_t RegionSizeWordsMask;
200 static size_t HumongousThresholdBytes;
201 static size_t HumongousThresholdWords;
202 static size_t MaxTLABSizeBytes;
203
204 private:
205 ShenandoahHeap* _heap;
206 size_t _region_number;
207 volatile jint _live_data;
208 MemRegion _reserved;
209
210 size_t _tlab_allocs;
211 size_t _gclab_allocs;
212 size_t _shared_allocs;
213
214 HeapWord* _new_top;
215
216 size_t _critical_pins;
217
218 RegionState _state;
219 double _empty_time;
220
221 ShenandoahPacer* _pacer;
222
223 public:
224 ShenandoahHeapRegion(ShenandoahHeap* heap, HeapWord* start, size_t size_words, size_t index, bool committed);
225
226 static void setup_heap_region_size(size_t initial_heap_size, size_t max_heap_size);
227
228 double empty_time() {
229 return _empty_time;
230 }
231
232 inline static size_t required_regions(size_t bytes) {
233 return (bytes + ShenandoahHeapRegion::region_size_bytes() - 1) >> ShenandoahHeapRegion::region_size_bytes_shift();
234 }
235
236 inline static size_t region_size_bytes() {
237 return ShenandoahHeapRegion::RegionSizeBytes;
238 }
239
240 inline static size_t region_size_words() {
241 return ShenandoahHeapRegion::RegionSizeWords;
242 }
243
244 inline static size_t region_size_bytes_shift() {
245 return ShenandoahHeapRegion::RegionSizeBytesShift;
246 }
247
248 inline static size_t region_size_words_shift() {
249 return ShenandoahHeapRegion::RegionSizeWordsShift;
250 }
251
252 inline static size_t region_size_bytes_mask() {
253 return ShenandoahHeapRegion::RegionSizeBytesMask;
254 }
255
274 assert (ShenandoahHeapRegion::RegionSizeBytesShift <= (size_t)max_jint, "sanity");
275 return (jint)ShenandoahHeapRegion::RegionSizeBytesShift;
276 }
277
278 // Convert to jint with sanity checking
279 inline static jint region_size_words_shift_jint() {
280 assert (ShenandoahHeapRegion::RegionSizeWordsShift <= (size_t)max_jint, "sanity");
281 return (jint)ShenandoahHeapRegion::RegionSizeWordsShift;
282 }
283
284 inline static size_t humongous_threshold_bytes() {
285 return ShenandoahHeapRegion::HumongousThresholdBytes;
286 }
287
288 inline static size_t humongous_threshold_words() {
289 return ShenandoahHeapRegion::HumongousThresholdWords;
290 }
291
292 inline static size_t max_tlab_size_bytes() {
293 return ShenandoahHeapRegion::MaxTLABSizeBytes;
294 }
295
296 size_t region_number() const;
297
298 // Allocation (return NULL if full)
299 inline HeapWord* allocate(size_t word_size, ShenandoahHeap::AllocType type);
300 HeapWord* allocate(size_t word_size) {
301 // ContiguousSpace wants us to have this method. But it is an error to call this with Shenandoah.
302 ShouldNotCallThis();
303 return NULL;
304 }
305
306 // Roll back the previous allocation of an object with specified size.
307 // Returns TRUE when successful, FALSE if not successful or not supported.
308 bool rollback_allocation(uint size);
309
310 void clear_live_data();
311 void set_live_data(size_t s);
312
313 // Increase live data for newly allocated region
|
174 bool is_humongous_continuation() const { return _state == _humongous_cont; }
175
176 // Participation in logical groups:
177 bool is_empty() const { return is_empty_committed() || is_empty_uncommitted(); }
178 bool is_active() const { return !is_empty() && !is_trash(); }
179 bool is_trash() const { return _state == _trash; }
180 bool is_humongous_start() const { return _state == _humongous_start || _state == _pinned_humongous_start; }
181 bool is_humongous() const { return is_humongous_start() || is_humongous_continuation(); }
182 bool is_committed() const { return !is_empty_uncommitted(); }
183 bool is_cset() const { return _state == _cset || _state == _pinned_cset; }
184 bool is_pinned() const { return _state == _pinned || _state == _pinned_cset || _state == _pinned_humongous_start; }
185
186 // Macro-properties:
187 bool is_alloc_allowed() const { return is_empty() || is_regular() || _state == _pinned; }
188 bool is_move_allowed() const { return is_regular() || _state == _cset || (ShenandoahHumongousMoves && _state == _humongous_start); }
189
190 RegionState state() const { return _state; }
191 int state_ordinal() const { return region_state_to_ordinal(_state); }
192
193 private:
194 static size_t RegionCount;
195 static size_t RegionSizeBytes;
196 static size_t RegionSizeWords;
197 static size_t RegionSizeBytesShift;
198 static size_t RegionSizeWordsShift;
199 static size_t RegionSizeBytesMask;
200 static size_t RegionSizeWordsMask;
201 static size_t HumongousThresholdBytes;
202 static size_t HumongousThresholdWords;
203 static size_t MaxTLABSizeBytes;
204 static size_t MaxTLABSizeWords;
205
206 private:
207 ShenandoahHeap* _heap;
208 size_t _region_number;
209 volatile jint _live_data;
210 MemRegion _reserved;
211
212 size_t _tlab_allocs;
213 size_t _gclab_allocs;
214 size_t _shared_allocs;
215
216 HeapWord* _new_top;
217
218 size_t _critical_pins;
219
220 RegionState _state;
221 double _empty_time;
222
223 ShenandoahPacer* _pacer;
224
225 public:
226 ShenandoahHeapRegion(ShenandoahHeap* heap, HeapWord* start, size_t size_words, size_t index, bool committed);
227
228 static void setup_sizes(size_t initial_heap_size, size_t max_heap_size);
229
230 double empty_time() {
231 return _empty_time;
232 }
233
234 inline static size_t required_regions(size_t bytes) {
235 return (bytes + ShenandoahHeapRegion::region_size_bytes() - 1) >> ShenandoahHeapRegion::region_size_bytes_shift();
236 }
237
238 inline static size_t region_count() {
239 return ShenandoahHeapRegion::RegionCount;
240 }
241
242 inline static size_t region_size_bytes() {
243 return ShenandoahHeapRegion::RegionSizeBytes;
244 }
245
246 inline static size_t region_size_words() {
247 return ShenandoahHeapRegion::RegionSizeWords;
248 }
249
250 inline static size_t region_size_bytes_shift() {
251 return ShenandoahHeapRegion::RegionSizeBytesShift;
252 }
253
254 inline static size_t region_size_words_shift() {
255 return ShenandoahHeapRegion::RegionSizeWordsShift;
256 }
257
258 inline static size_t region_size_bytes_mask() {
259 return ShenandoahHeapRegion::RegionSizeBytesMask;
260 }
261
280 assert (ShenandoahHeapRegion::RegionSizeBytesShift <= (size_t)max_jint, "sanity");
281 return (jint)ShenandoahHeapRegion::RegionSizeBytesShift;
282 }
283
284 // Convert to jint with sanity checking
285 inline static jint region_size_words_shift_jint() {
286 assert (ShenandoahHeapRegion::RegionSizeWordsShift <= (size_t)max_jint, "sanity");
287 return (jint)ShenandoahHeapRegion::RegionSizeWordsShift;
288 }
289
290 inline static size_t humongous_threshold_bytes() {
291 return ShenandoahHeapRegion::HumongousThresholdBytes;
292 }
293
294 inline static size_t humongous_threshold_words() {
295 return ShenandoahHeapRegion::HumongousThresholdWords;
296 }
297
298 inline static size_t max_tlab_size_bytes() {
299 return ShenandoahHeapRegion::MaxTLABSizeBytes;
300 }
301
302 inline static size_t max_tlab_size_words() {
303 return ShenandoahHeapRegion::MaxTLABSizeWords;
304 }
305
306 size_t region_number() const;
307
308 // Allocation (return NULL if full)
309 inline HeapWord* allocate(size_t word_size, ShenandoahHeap::AllocType type);
310 HeapWord* allocate(size_t word_size) {
311 // ContiguousSpace wants us to have this method. But it is an error to call this with Shenandoah.
312 ShouldNotCallThis();
313 return NULL;
314 }
315
316 // Roll back the previous allocation of an object with specified size.
317 // Returns TRUE when successful, FALSE if not successful or not supported.
318 bool rollback_allocation(uint size);
319
320 void clear_live_data();
321 void set_live_data(size_t s);
322
323 // Increase live data for newly allocated region
|