< prev index next >

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

Print this page
rev 58079 : 8238633: JVMTI heap walk should consult GC for marking oops

@@ -51,10 +51,11 @@
 #include "gc/shenandoah/shenandoahMarkingContext.inline.hpp"
 #include "gc/shenandoah/shenandoahMemoryPool.hpp"
 #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"
 #include "gc/shenandoah/shenandoahPassiveMode.hpp"
 #include "gc/shenandoah/shenandoahRootProcessor.inline.hpp"

@@ -1274,10 +1275,28 @@
  */
 void ShenandoahHeap::ensure_parsability(bool retire_tlabs) {
   // 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.
  *
  * We cannot safely iterate objects by doing a linear scan at random points in time. Linear
  * scanning needs to deal with dead objects, which may have dead Klass* pointers (e.g.

@@ -1291,14 +1310,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 (!_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();
 
   Stack<oop,mtGC> oop_stack;

@@ -1323,13 +1339,11 @@
     obj->oop_iterate(&oops);
   }
 
   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.
 void ShenandoahHeap::keep_alive(oop obj) {
   if (is_concurrent_mark_in_progress()) {
< prev index next >