< prev index next >

src/hotspot/share/gc/shenandoah/shenandoahHeapRegion.cpp

Print this page

775 
776   guarantee(RegionSizeBytesMask == 0, "we should only set it once");
777   RegionSizeBytesMask = RegionSizeBytes - 1;
778 
779   guarantee(RegionCount == 0, "we should only set it once");
780   RegionCount = align_up(max_heap_size, RegionSizeBytes) / RegionSizeBytes;
781   guarantee(RegionCount >= MIN_NUM_REGIONS, "Should have at least minimum regions");
782 
783   guarantee(MaxTLABSizeWords == 0, "we should only set it once");
784   MaxTLABSizeWords = align_down(RegionSizeWords, MinObjAlignment);
785 
786   guarantee(MaxTLABSizeBytes == 0, "we should only set it once");
787   MaxTLABSizeBytes = MaxTLABSizeWords * HeapWordSize;
788   assert (MaxTLABSizeBytes > MinTLABSize, "should be larger");
789 
790   return max_heap_size;
791 }
792 
793 void ShenandoahHeapRegion::do_commit() {
794   ShenandoahHeap* heap = ShenandoahHeap::heap();
795   if (!heap->is_heap_region_special() && !os::commit_memory((char *) bottom(), RegionSizeBytes, false)) {
796     report_java_out_of_memory("Unable to commit region");
797   }
798   if (!heap->commit_bitmap_slice(this)) {
799     report_java_out_of_memory("Unable to commit bitmaps for region");
800   }
801   if (AlwaysPreTouch) {
802     os::pretouch_memory(bottom(), end(), heap->pretouch_heap_page_size());
803   }



804   heap->increase_committed(ShenandoahHeapRegion::region_size_bytes());
805 }
806 
807 void ShenandoahHeapRegion::do_uncommit() {
808   ShenandoahHeap* heap = ShenandoahHeap::heap();
809   if (!heap->is_heap_region_special() && !os::uncommit_memory((char *) bottom(), RegionSizeBytes)) {
810     report_java_out_of_memory("Unable to uncommit region");




811   }
812   if (!heap->uncommit_bitmap_slice(this)) {
813     report_java_out_of_memory("Unable to uncommit bitmaps for region");
814   }
815   heap->decrease_committed(ShenandoahHeapRegion::region_size_bytes());
816 }
817 
818 void ShenandoahHeapRegion::set_state(RegionState to) {
819   EventShenandoahHeapRegionStateChange evt;
820   if (evt.should_commit()){
821     evt.set_index((unsigned) index());
822     evt.set_start((uintptr_t)bottom());
823     evt.set_used(used());
824     evt.set_from(state());
825     evt.set_to(to);
826     evt.commit();
827   }
828   Atomic::store(&_state, to);
829 }
830 
831 void ShenandoahHeapRegion::record_pin() {
832   Atomic::add(&_critical_pins, (size_t)1);
833 }

775 
776   guarantee(RegionSizeBytesMask == 0, "we should only set it once");
777   RegionSizeBytesMask = RegionSizeBytes - 1;
778 
779   guarantee(RegionCount == 0, "we should only set it once");
780   RegionCount = align_up(max_heap_size, RegionSizeBytes) / RegionSizeBytes;
781   guarantee(RegionCount >= MIN_NUM_REGIONS, "Should have at least minimum regions");
782 
783   guarantee(MaxTLABSizeWords == 0, "we should only set it once");
784   MaxTLABSizeWords = align_down(RegionSizeWords, MinObjAlignment);
785 
786   guarantee(MaxTLABSizeBytes == 0, "we should only set it once");
787   MaxTLABSizeBytes = MaxTLABSizeWords * HeapWordSize;
788   assert (MaxTLABSizeBytes > MinTLABSize, "should be larger");
789 
790   return max_heap_size;
791 }
792 
793 void ShenandoahHeapRegion::do_commit() {
794   ShenandoahHeap* heap = ShenandoahHeap::heap();
795   if (!heap->is_heap_region_special()) {
796     os::commit_memory_or_exit((char*) bottom(), RegionSizeBytes, false, "Unable to commit region");
797   }
798   if (!heap->is_bitmap_region_special()) {
799     heap->commit_bitmap_slice(this);
800   }
801   if (AlwaysPreTouch) {
802     os::pretouch_memory(bottom(), end(), heap->pretouch_heap_page_size());
803   }
804   if (ZapUnusedHeapArea) {
805     SpaceMangler::mangle_region(MemRegion(bottom(), end()));
806   }
807   heap->increase_committed(ShenandoahHeapRegion::region_size_bytes());
808 }
809 
810 void ShenandoahHeapRegion::do_uncommit() {
811   ShenandoahHeap* heap = ShenandoahHeap::heap();
812   if (!heap->is_heap_region_special()) {
813     bool success = os::uncommit_memory((char *) bottom(), RegionSizeBytes);
814     if (!success) {
815       log_warning(gc)("Region uncommit failed: " PTR_FORMAT " (%zu bytes)", p2i(bottom()), RegionSizeBytes);
816       assert(false, "Region uncommit should always succeed");
817     }
818   }
819   if (!heap->is_bitmap_region_special()) {
820     heap->uncommit_bitmap_slice(this);
821   }
822   heap->decrease_committed(ShenandoahHeapRegion::region_size_bytes());
823 }
824 
825 void ShenandoahHeapRegion::set_state(RegionState to) {
826   EventShenandoahHeapRegionStateChange evt;
827   if (evt.should_commit()){
828     evt.set_index((unsigned) index());
829     evt.set_start((uintptr_t)bottom());
830     evt.set_used(used());
831     evt.set_from(state());
832     evt.set_to(to);
833     evt.commit();
834   }
835   Atomic::store(&_state, to);
836 }
837 
838 void ShenandoahHeapRegion::record_pin() {
839   Atomic::add(&_critical_pins, (size_t)1);
840 }
< prev index next >