< prev index next >

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

Print this page

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



814   heap->increase_committed(ShenandoahHeapRegion::region_size_bytes());
815 }
816 
817 void ShenandoahHeapRegion::do_uncommit() {
818   ShenandoahHeap* heap = ShenandoahHeap::heap();
819   if (!heap->is_heap_region_special() && !os::uncommit_memory((char *) bottom(), RegionSizeBytes)) {
820     report_java_out_of_memory("Unable to uncommit region");




821   }
822   if (!heap->uncommit_bitmap_slice(this)) {
823     report_java_out_of_memory("Unable to uncommit bitmaps for region");
824   }
825   heap->decrease_committed(ShenandoahHeapRegion::region_size_bytes());
826 }
827 
828 void ShenandoahHeapRegion::set_state(RegionState to) {
829   EventShenandoahHeapRegionStateChange evt;
830   if (evt.should_commit()){
831     evt.set_index((unsigned) index());
832     evt.set_start((uintptr_t)bottom());
833     evt.set_used(used());
834     evt.set_from(state());
835     evt.set_to(to);
836     evt.commit();
837   }
838   Atomic::store(&_state, to);
839 }
840 
841 void ShenandoahHeapRegion::record_pin() {
842   Atomic::add(&_critical_pins, (size_t)1);
843 }

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