< prev index next >
src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp
Print this page
rev 54037 : 8220350: Refactor ShenandoahHeap::initialize
Reviewed-by: XXX
rev 54038 : 8220153: Shenandoah does not work with TransparentHugePages properly
Reviewed-by: XXX
rev 54039 : 8220162: Shenandoah should not commit HugeTLBFS memory
Reviewed-by: XXX
@@ -171,17 +171,20 @@
//
ReservedSpace heap_rs = Universe::reserve_heap(max_byte_size, heap_alignment);
initialize_reserved_region((HeapWord*)heap_rs.base(), (HeapWord*) (heap_rs.base() + heap_rs.size()));
_heap_region = MemRegion((HeapWord*)heap_rs.base(), heap_rs.size() / HeapWordSize);
+ _heap_region_special = heap_rs.special();
assert((((size_t) base()) & ShenandoahHeapRegion::region_size_bytes_mask()) == 0,
"Misaligned heap: " PTR_FORMAT, p2i(base()));
ReservedSpace sh_rs = heap_rs.first_part(max_byte_size);
+ if (!_heap_region_special) {
os::commit_memory_or_exit(sh_rs.base(), _initial_size, heap_alignment, false,
"Cannot commit heap memory");
+ }
//
// Reserve and commit memory for bitmap(s)
//
@@ -212,33 +215,39 @@
_bitmap_bytes_per_slice, bitmap_page_size);
ReservedSpace bitmap(_bitmap_size, bitmap_page_size);
MemTracker::record_virtual_memory_type(bitmap.base(), mtGC);
_bitmap_region = MemRegion((HeapWord*) bitmap.base(), bitmap.size() / HeapWordSize);
+ _bitmap_region_special = bitmap.special();
size_t bitmap_init_commit = _bitmap_bytes_per_slice *
align_up(num_committed_regions, _bitmap_regions_per_slice) / _bitmap_regions_per_slice;
bitmap_init_commit = MIN2(_bitmap_size, bitmap_init_commit);
- os::commit_memory_or_exit((char *)_bitmap_region.start(), bitmap_init_commit, bitmap_page_size, false,
+ if (!_bitmap_region_special) {
+ os::commit_memory_or_exit((char *) _bitmap_region.start(), bitmap_init_commit, bitmap_page_size, false,
"Cannot commit bitmap memory");
+ }
_marking_context = new ShenandoahMarkingContext(_heap_region, _bitmap_region, _num_regions);
if (ShenandoahVerify) {
ReservedSpace verify_bitmap(_bitmap_size, bitmap_page_size);
+ if (!verify_bitmap.special()) {
os::commit_memory_or_exit(verify_bitmap.base(), verify_bitmap.size(), bitmap_page_size, false,
"Cannot commit verification bitmap memory");
+ }
MemTracker::record_virtual_memory_type(verify_bitmap.base(), mtGC);
MemRegion verify_bitmap_region = MemRegion((HeapWord *) verify_bitmap.base(), verify_bitmap.size() / HeapWordSize);
_verification_bit_map.initialize(_heap_region, verify_bitmap_region);
_verifier = new ShenandoahVerifier(this, &_verification_bit_map);
}
// Reserve aux bitmap for use in object_iterate(). We don't commit it here.
ReservedSpace aux_bitmap(_bitmap_size, bitmap_page_size);
MemTracker::record_virtual_memory_type(aux_bitmap.base(), mtGC);
_aux_bitmap_region = MemRegion((HeapWord*) aux_bitmap.base(), aux_bitmap.size() / HeapWordSize);
+ _aux_bitmap_region_special = aux_bitmap.special();
_aux_bit_map.initialize(_heap_region, _aux_bitmap_region);
//
// Create regions and region sets
//
@@ -405,10 +414,11 @@
_committed(0),
_bytes_allocated_since_gc_start(0),
_max_workers(MAX2(ConcGCThreads, ParallelGCThreads)),
_workers(NULL),
_safepoint_workers(NULL),
+ _heap_region_special(false),
_num_regions(0),
_regions(NULL),
_update_refs_iterator(this),
_control_thread(NULL),
_shenandoah_policy(policy),
@@ -430,10 +440,12 @@
_ref_processor(NULL),
_marking_context(NULL),
_bitmap_size(0),
_bitmap_regions_per_slice(0),
_bitmap_bytes_per_slice(0),
+ _bitmap_region_special(false),
+ _aux_bitmap_region_special(false),
_liveness_cache(NULL),
_collection_set(NULL)
{
log_info(gc, init)("GC threads: " UINT32_FORMAT " parallel, " UINT32_FORMAT " concurrent", ParallelGCThreads, ConcGCThreads);
log_info(gc, init)("Reference processing: %s", ParallelRefProcEnabled ? "parallel" : "serial");
@@ -1315,11 +1327,11 @@
* objects as we mark+traverse through the heap, starting from GC roots. JVMTI IterateThroughHeap
* is allowed to report dead objects, but is not required to do so.
*/
void ShenandoahHeap::object_iterate(ObjectClosure* cl) {
assert(SafepointSynchronize::is_at_safepoint(), "safe iteration is only available during safepoints");
- if (!os::commit_memory((char*)_aux_bitmap_region.start(), _aux_bitmap_region.byte_size(), false)) {
+ if (!_aux_bitmap_region_special && !os::commit_memory((char*)_aux_bitmap_region.start(), _aux_bitmap_region.byte_size(), false)) {
log_warning(gc)("Could not commit native memory for auxiliary marking bitmap for heap iteration");
return;
}
// Reset bitmap
@@ -1342,11 +1354,11 @@
obj->oop_iterate(&oops);
}
assert(oop_stack.is_empty(), "should be empty");
- if (!os::uncommit_memory((char*)_aux_bitmap_region.start(), _aux_bitmap_region.byte_size())) {
+ if (!_aux_bitmap_region_special && !os::uncommit_memory((char*)_aux_bitmap_region.start(), _aux_bitmap_region.byte_size())) {
log_warning(gc)("Could not uncommit native memory for auxiliary marking bitmap for heap iteration");
}
}
void ShenandoahHeap::safe_object_iterate(ObjectClosure* cl) {
@@ -2269,10 +2281,15 @@
}
bool ShenandoahHeap::commit_bitmap_slice(ShenandoahHeapRegion* r) {
assert_heaplock_owned_by_current_thread();
+ // Bitmaps in special regions do not need commits
+ if (_bitmap_region_special) {
+ return true;
+ }
+
if (is_bitmap_slice_committed(r, true)) {
// Some other region from the group is already committed, meaning the bitmap
// slice is already committed, we exit right away.
return true;
}
@@ -2288,10 +2305,15 @@
}
bool ShenandoahHeap::uncommit_bitmap_slice(ShenandoahHeapRegion *r) {
assert_heaplock_owned_by_current_thread();
+ // Bitmaps in special regions do not need uncommits
+ if (_bitmap_region_special) {
+ return true;
+ }
+
if (is_bitmap_slice_committed(r, true)) {
// Some other region from the group is still committed, meaning the bitmap
// slice is should stay committed, exit right away.
return true;
}
< prev index next >