288 default:
289 report_illegal_transition("uncommiting");
290 }
291 }
292
293 void ShenandoahHeapRegion::make_committed_bypass() {
294 _heap->assert_heaplock_owned_by_current_thread();
295 assert (_heap->is_full_gc_in_progress(), "only for full GC");
296
297 switch (_state) {
298 case _empty_uncommitted:
299 do_commit();
300 set_state(_empty_committed);
301 return;
302 default:
303 report_illegal_transition("commit bypass");
304 }
305 }
306
307 void ShenandoahHeapRegion::clear_live_data() {
308 OrderAccess::release_store_fence<size_t>(&_live_data, 0);
309 }
310
311 void ShenandoahHeapRegion::reset_alloc_metadata() {
312 _tlab_allocs = 0;
313 _gclab_allocs = 0;
314 _shared_allocs = 0;
315 _seqnum_first_alloc_mutator = 0;
316 _seqnum_last_alloc_mutator = 0;
317 _seqnum_first_alloc_gc = 0;
318 _seqnum_last_alloc_gc = 0;
319 }
320
321 void ShenandoahHeapRegion::reset_alloc_metadata_to_shared() {
322 if (used() > 0) {
323 _tlab_allocs = 0;
324 _gclab_allocs = 0;
325 _shared_allocs = used() >> LogHeapWordSize;
326 uint64_t next = _alloc_seq_num.value++;
327 _seqnum_first_alloc_mutator = next;
328 _seqnum_last_alloc_mutator = next;
334 }
335
336 size_t ShenandoahHeapRegion::get_shared_allocs() const {
337 return _shared_allocs * HeapWordSize;
338 }
339
340 size_t ShenandoahHeapRegion::get_tlab_allocs() const {
341 return _tlab_allocs * HeapWordSize;
342 }
343
344 size_t ShenandoahHeapRegion::get_gclab_allocs() const {
345 return _gclab_allocs * HeapWordSize;
346 }
347
348 void ShenandoahHeapRegion::set_live_data(size_t s) {
349 assert(Thread::current()->is_VM_thread(), "by VM thread");
350 _live_data = (s >> LogHeapWordSize);
351 }
352
353 size_t ShenandoahHeapRegion::get_live_data_words() const {
354 return OrderAccess::load_acquire(&_live_data);
355 }
356
357 size_t ShenandoahHeapRegion::get_live_data_bytes() const {
358 return get_live_data_words() * HeapWordSize;
359 }
360
361 bool ShenandoahHeapRegion::has_live() const {
362 return get_live_data_words() != 0;
363 }
364
365 size_t ShenandoahHeapRegion::garbage() const {
366 assert(used() >= get_live_data_bytes(), "Live Data must be a subset of used() live: " SIZE_FORMAT " used: " SIZE_FORMAT,
367 get_live_data_bytes(), used());
368
369 size_t result = used() - get_live_data_bytes();
370 return result;
371 }
372
373 void ShenandoahHeapRegion::print_on(outputStream* st) const {
374 st->print("|");
|
288 default:
289 report_illegal_transition("uncommiting");
290 }
291 }
292
293 void ShenandoahHeapRegion::make_committed_bypass() {
294 _heap->assert_heaplock_owned_by_current_thread();
295 assert (_heap->is_full_gc_in_progress(), "only for full GC");
296
297 switch (_state) {
298 case _empty_uncommitted:
299 do_commit();
300 set_state(_empty_committed);
301 return;
302 default:
303 report_illegal_transition("commit bypass");
304 }
305 }
306
307 void ShenandoahHeapRegion::clear_live_data() {
308 Atomic::release_store_fence<size_t>(&_live_data, 0);
309 }
310
311 void ShenandoahHeapRegion::reset_alloc_metadata() {
312 _tlab_allocs = 0;
313 _gclab_allocs = 0;
314 _shared_allocs = 0;
315 _seqnum_first_alloc_mutator = 0;
316 _seqnum_last_alloc_mutator = 0;
317 _seqnum_first_alloc_gc = 0;
318 _seqnum_last_alloc_gc = 0;
319 }
320
321 void ShenandoahHeapRegion::reset_alloc_metadata_to_shared() {
322 if (used() > 0) {
323 _tlab_allocs = 0;
324 _gclab_allocs = 0;
325 _shared_allocs = used() >> LogHeapWordSize;
326 uint64_t next = _alloc_seq_num.value++;
327 _seqnum_first_alloc_mutator = next;
328 _seqnum_last_alloc_mutator = next;
334 }
335
336 size_t ShenandoahHeapRegion::get_shared_allocs() const {
337 return _shared_allocs * HeapWordSize;
338 }
339
340 size_t ShenandoahHeapRegion::get_tlab_allocs() const {
341 return _tlab_allocs * HeapWordSize;
342 }
343
344 size_t ShenandoahHeapRegion::get_gclab_allocs() const {
345 return _gclab_allocs * HeapWordSize;
346 }
347
348 void ShenandoahHeapRegion::set_live_data(size_t s) {
349 assert(Thread::current()->is_VM_thread(), "by VM thread");
350 _live_data = (s >> LogHeapWordSize);
351 }
352
353 size_t ShenandoahHeapRegion::get_live_data_words() const {
354 return Atomic::load_acquire(&_live_data);
355 }
356
357 size_t ShenandoahHeapRegion::get_live_data_bytes() const {
358 return get_live_data_words() * HeapWordSize;
359 }
360
361 bool ShenandoahHeapRegion::has_live() const {
362 return get_live_data_words() != 0;
363 }
364
365 size_t ShenandoahHeapRegion::garbage() const {
366 assert(used() >= get_live_data_bytes(), "Live Data must be a subset of used() live: " SIZE_FORMAT " used: " SIZE_FORMAT,
367 get_live_data_bytes(), used());
368
369 size_t result = used() - get_live_data_bytes();
370 return result;
371 }
372
373 void ShenandoahHeapRegion::print_on(outputStream* st) const {
374 st->print("|");
|