--- old/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp 2020-02-21 11:14:38.956175512 +0100 +++ new/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp 2020-02-21 11:14:38.700171228 +0100 @@ -53,6 +53,7 @@ #include "gc/shenandoah/shenandoahMetrics.hpp" #include "gc/shenandoah/shenandoahMonitoringSupport.hpp" #include "gc/shenandoah/shenandoahNormalMode.hpp" +#include "gc/shenandoah/shenandoahObjectMarker.hpp" #include "gc/shenandoah/shenandoahOopClosures.inline.hpp" #include "gc/shenandoah/shenandoahPacer.inline.hpp" #include "gc/shenandoah/shenandoahParallelCleaning.inline.hpp" @@ -1276,6 +1277,24 @@ // No-op. } +ObjectMarker* ShenandoahHeap::object_marker() { + return new ShenandoahObjectMarker(this, &_aux_bit_map); +} + +bool ShenandoahHeap::commit_aux_bitmap() { + 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 false; + } + return true; +} + +void ShenandoahHeap::uncommit_aux_bit_map() { + 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"); + } +} + /* * Iterates objects in the heap. This is public API, used for, e.g., heap dumping. * @@ -1293,10 +1312,7 @@ */ void ShenandoahHeap::object_iterate(ObjectClosure* cl) { assert(SafepointSynchronize::is_at_safepoint(), "safe iteration is only available during safepoints"); - 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; - } + if (!commit_aux_bitmap()) return; // Reset bitmap _aux_bit_map.clear(); @@ -1325,9 +1341,7 @@ assert(oop_stack.is_empty(), "should be empty"); - 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"); - } + uncommit_aux_bit_map(); } // Keep alive an object that was loaded with AS_NO_KEEPALIVE.