35 #include "runtime/java.hpp"
36 #include "runtime/mutexLocker.hpp"
37 #include "runtime/os.hpp"
38 #include "runtime/safepoint.hpp"
39
40 size_t ShenandoahHeapRegion::RegionCount = 0;
41 size_t ShenandoahHeapRegion::RegionSizeBytes = 0;
42 size_t ShenandoahHeapRegion::RegionSizeWords = 0;
43 size_t ShenandoahHeapRegion::RegionSizeBytesShift = 0;
44 size_t ShenandoahHeapRegion::RegionSizeWordsShift = 0;
45 size_t ShenandoahHeapRegion::RegionSizeBytesMask = 0;
46 size_t ShenandoahHeapRegion::RegionSizeWordsMask = 0;
47 size_t ShenandoahHeapRegion::HumongousThresholdBytes = 0;
48 size_t ShenandoahHeapRegion::HumongousThresholdWords = 0;
49 size_t ShenandoahHeapRegion::MaxTLABSizeBytes = 0;
50 size_t ShenandoahHeapRegion::MaxTLABSizeWords = 0;
51
52 ShenandoahHeapRegion::ShenandoahHeapRegion(ShenandoahHeap* heap, HeapWord* start,
53 size_t size_words, size_t index, bool committed) :
54 _heap(heap),
55 _pacer(ShenandoahPacing ? heap->pacer() : NULL),
56 _reserved(MemRegion(start, size_words)),
57 _region_number(index),
58 _new_top(NULL),
59 _critical_pins(0),
60 _empty_time(os::elapsedTime()),
61 _state(committed ? _empty_committed : _empty_uncommitted),
62 _tlab_allocs(0),
63 _gclab_allocs(0),
64 _shared_allocs(0),
65 _live_data(0) {
66
67 ContiguousSpace::initialize(_reserved, true, committed);
68 }
69
70 size_t ShenandoahHeapRegion::region_number() const {
71 return _region_number;
72 }
73
74 void ShenandoahHeapRegion::report_illegal_transition(const char *method) {
75 ResourceMark rm;
595 //
596 // The whole thing would be mitigated if Elastic TLABs were enabled, but there
597 // is no support in this JDK.
598 //
599 guarantee(MaxTLABSizeBytes == 0, "we should only set it once");
600 MaxTLABSizeBytes = MIN2(RegionSizeBytes / 8, HumongousThresholdBytes);
601 assert (MaxTLABSizeBytes > MinTLABSize, "should be larger");
602
603 guarantee(MaxTLABSizeWords == 0, "we should only set it once");
604 MaxTLABSizeWords = MaxTLABSizeBytes / HeapWordSize;
605
606 log_info(gc, init)("Regions: " SIZE_FORMAT " x " SIZE_FORMAT "%s",
607 RegionCount, byte_size_in_proper_unit(RegionSizeBytes), proper_unit_for_byte_size(RegionSizeBytes));
608 log_info(gc, init)("Humongous object threshold: " SIZE_FORMAT "%s",
609 byte_size_in_proper_unit(HumongousThresholdBytes), proper_unit_for_byte_size(HumongousThresholdBytes));
610 log_info(gc, init)("Max TLAB size: " SIZE_FORMAT "%s",
611 byte_size_in_proper_unit(MaxTLABSizeBytes), proper_unit_for_byte_size(MaxTLABSizeBytes));
612 }
613
614 void ShenandoahHeapRegion::do_commit() {
615 if (!os::commit_memory((char *) _reserved.start(), _reserved.byte_size(), false)) {
616 report_java_out_of_memory("Unable to commit region");
617 }
618 if (!_heap->commit_bitmap_slice(this)) {
619 report_java_out_of_memory("Unable to commit bitmaps for region");
620 }
621 _heap->increase_committed(ShenandoahHeapRegion::region_size_bytes());
622 }
623
624 void ShenandoahHeapRegion::do_uncommit() {
625 if (!os::uncommit_memory((char *) _reserved.start(), _reserved.byte_size())) {
626 report_java_out_of_memory("Unable to uncommit region");
627 }
628 if (!_heap->uncommit_bitmap_slice(this)) {
629 report_java_out_of_memory("Unable to uncommit bitmaps for region");
630 }
631 _heap->decrease_committed(ShenandoahHeapRegion::region_size_bytes());
632 }
|
35 #include "runtime/java.hpp"
36 #include "runtime/mutexLocker.hpp"
37 #include "runtime/os.hpp"
38 #include "runtime/safepoint.hpp"
39
40 size_t ShenandoahHeapRegion::RegionCount = 0;
41 size_t ShenandoahHeapRegion::RegionSizeBytes = 0;
42 size_t ShenandoahHeapRegion::RegionSizeWords = 0;
43 size_t ShenandoahHeapRegion::RegionSizeBytesShift = 0;
44 size_t ShenandoahHeapRegion::RegionSizeWordsShift = 0;
45 size_t ShenandoahHeapRegion::RegionSizeBytesMask = 0;
46 size_t ShenandoahHeapRegion::RegionSizeWordsMask = 0;
47 size_t ShenandoahHeapRegion::HumongousThresholdBytes = 0;
48 size_t ShenandoahHeapRegion::HumongousThresholdWords = 0;
49 size_t ShenandoahHeapRegion::MaxTLABSizeBytes = 0;
50 size_t ShenandoahHeapRegion::MaxTLABSizeWords = 0;
51
52 ShenandoahHeapRegion::ShenandoahHeapRegion(ShenandoahHeap* heap, HeapWord* start,
53 size_t size_words, size_t index, bool committed) :
54 _heap(heap),
55 _reserved(MemRegion(start, size_words)),
56 _region_number(index),
57 _new_top(NULL),
58 _critical_pins(0),
59 _empty_time(os::elapsedTime()),
60 _state(committed ? _empty_committed : _empty_uncommitted),
61 _tlab_allocs(0),
62 _gclab_allocs(0),
63 _shared_allocs(0),
64 _live_data(0) {
65
66 ContiguousSpace::initialize(_reserved, true, committed);
67 }
68
69 size_t ShenandoahHeapRegion::region_number() const {
70 return _region_number;
71 }
72
73 void ShenandoahHeapRegion::report_illegal_transition(const char *method) {
74 ResourceMark rm;
594 //
595 // The whole thing would be mitigated if Elastic TLABs were enabled, but there
596 // is no support in this JDK.
597 //
598 guarantee(MaxTLABSizeBytes == 0, "we should only set it once");
599 MaxTLABSizeBytes = MIN2(RegionSizeBytes / 8, HumongousThresholdBytes);
600 assert (MaxTLABSizeBytes > MinTLABSize, "should be larger");
601
602 guarantee(MaxTLABSizeWords == 0, "we should only set it once");
603 MaxTLABSizeWords = MaxTLABSizeBytes / HeapWordSize;
604
605 log_info(gc, init)("Regions: " SIZE_FORMAT " x " SIZE_FORMAT "%s",
606 RegionCount, byte_size_in_proper_unit(RegionSizeBytes), proper_unit_for_byte_size(RegionSizeBytes));
607 log_info(gc, init)("Humongous object threshold: " SIZE_FORMAT "%s",
608 byte_size_in_proper_unit(HumongousThresholdBytes), proper_unit_for_byte_size(HumongousThresholdBytes));
609 log_info(gc, init)("Max TLAB size: " SIZE_FORMAT "%s",
610 byte_size_in_proper_unit(MaxTLABSizeBytes), proper_unit_for_byte_size(MaxTLABSizeBytes));
611 }
612
613 void ShenandoahHeapRegion::do_commit() {
614 if (!_heap->is_heap_region_special() && !os::commit_memory((char *) _reserved.start(), _reserved.byte_size(), false)) {
615 report_java_out_of_memory("Unable to commit region");
616 }
617 if (!_heap->commit_bitmap_slice(this)) {
618 report_java_out_of_memory("Unable to commit bitmaps for region");
619 }
620 _heap->increase_committed(ShenandoahHeapRegion::region_size_bytes());
621 }
622
623 void ShenandoahHeapRegion::do_uncommit() {
624 if (!_heap->is_heap_region_special() && !os::uncommit_memory((char *) _reserved.start(), _reserved.byte_size())) {
625 report_java_out_of_memory("Unable to uncommit region");
626 }
627 if (!_heap->uncommit_bitmap_slice(this)) {
628 report_java_out_of_memory("Unable to uncommit bitmaps for region");
629 }
630 _heap->decrease_committed(ShenandoahHeapRegion::region_size_bytes());
631 }
|