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;
670 if (!_heap->uncommit_bitmap_slice(this)) {
671 report_java_out_of_memory("Unable to uncommit bitmaps for region");
672 }
673 _heap->decrease_committed(ShenandoahHeapRegion::region_size_bytes());
674 }
675
676 void ShenandoahHeapRegion::set_state(RegionState to) {
677 EventShenandoahHeapRegionStateChange evt;
678 if (evt.should_commit()){
679 evt.set_index((unsigned)region_number());
680 evt.set_start((uintptr_t)bottom());
681 evt.set_used(used());
682 evt.set_from(_state);
683 evt.set_to(to);
684 evt.commit();
685 }
686 _state = to;
687 }
688
689 void ShenandoahHeapRegion::record_pin() {
690 Atomic::add((size_t)1, &_critical_pins);
691 }
692
693 void ShenandoahHeapRegion::record_unpin() {
694 assert(pin_count() > 0, "Region " SIZE_FORMAT " should have non-zero pins", region_number());
695 Atomic::sub((size_t)1, &_critical_pins);
696 }
697
698 size_t ShenandoahHeapRegion::pin_count() const {
699 return Atomic::load(&_critical_pins);
700 }
|
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(&_live_data, (size_t)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;
670 if (!_heap->uncommit_bitmap_slice(this)) {
671 report_java_out_of_memory("Unable to uncommit bitmaps for region");
672 }
673 _heap->decrease_committed(ShenandoahHeapRegion::region_size_bytes());
674 }
675
676 void ShenandoahHeapRegion::set_state(RegionState to) {
677 EventShenandoahHeapRegionStateChange evt;
678 if (evt.should_commit()){
679 evt.set_index((unsigned)region_number());
680 evt.set_start((uintptr_t)bottom());
681 evt.set_used(used());
682 evt.set_from(_state);
683 evt.set_to(to);
684 evt.commit();
685 }
686 _state = to;
687 }
688
689 void ShenandoahHeapRegion::record_pin() {
690 Atomic::add(&_critical_pins, (size_t)1);
691 }
692
693 void ShenandoahHeapRegion::record_unpin() {
694 assert(pin_count() > 0, "Region " SIZE_FORMAT " should have non-zero pins", region_number());
695 Atomic::sub(&_critical_pins, (size_t)1);
696 }
697
698 size_t ShenandoahHeapRegion::pin_count() const {
699 return Atomic::load(&_critical_pins);
700 }
|