< prev index next >

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

Print this page
rev 55322 : 8225550: Shenandoah: Prevent SH::object_iterate() call's side-effects


1262  *
1263  * For all those reasons, we implement object iteration as a single marking traversal, reporting
1264  * objects as we mark+traverse through the heap, starting from GC roots. JVMTI IterateThroughHeap
1265  * is allowed to report dead objects, but is not required to do so.
1266  */
1267 void ShenandoahHeap::object_iterate(ObjectClosure* cl) {
1268   assert(SafepointSynchronize::is_at_safepoint(), "safe iteration is only available during safepoints");
1269   if (!_aux_bitmap_region_special && !os::commit_memory((char*)_aux_bitmap_region.start(), _aux_bitmap_region.byte_size(), false)) {
1270     log_warning(gc)("Could not commit native memory for auxiliary marking bitmap for heap iteration");
1271     return;
1272   }
1273 
1274   // Reset bitmap
1275   _aux_bit_map.clear();
1276 
1277   Stack<oop,mtGC> oop_stack;
1278 
1279   // First, we process all GC roots. This populates the work stack with initial objects.
1280   ShenandoahAllRootScanner rp(1, ShenandoahPhaseTimings::_num_phases);
1281   ObjectIterateScanRootClosure oops(&_aux_bit_map, &oop_stack);




1282   rp.roots_do_unchecked(&oops);

1283 
1284   // Work through the oop stack to traverse heap.
1285   while (! oop_stack.is_empty()) {
1286     oop obj = oop_stack.pop();
1287     assert(oopDesc::is_oop(obj), "must be a valid oop");
1288     cl->do_object(obj);
1289     obj->oop_iterate(&oops);
1290   }
1291 
1292   assert(oop_stack.is_empty(), "should be empty");
1293 
1294   if (!_aux_bitmap_region_special && !os::uncommit_memory((char*)_aux_bitmap_region.start(), _aux_bitmap_region.byte_size())) {
1295     log_warning(gc)("Could not uncommit native memory for auxiliary marking bitmap for heap iteration");
1296   }
1297 }
1298 
1299 void ShenandoahHeap::safe_object_iterate(ObjectClosure* cl) {
1300   assert(SafepointSynchronize::is_at_safepoint(), "safe iteration is only available during safepoints");
1301   object_iterate(cl);
1302 }




1262  *
1263  * For all those reasons, we implement object iteration as a single marking traversal, reporting
1264  * objects as we mark+traverse through the heap, starting from GC roots. JVMTI IterateThroughHeap
1265  * is allowed to report dead objects, but is not required to do so.
1266  */
1267 void ShenandoahHeap::object_iterate(ObjectClosure* cl) {
1268   assert(SafepointSynchronize::is_at_safepoint(), "safe iteration is only available during safepoints");
1269   if (!_aux_bitmap_region_special && !os::commit_memory((char*)_aux_bitmap_region.start(), _aux_bitmap_region.byte_size(), false)) {
1270     log_warning(gc)("Could not commit native memory for auxiliary marking bitmap for heap iteration");
1271     return;
1272   }
1273 
1274   // Reset bitmap
1275   _aux_bit_map.clear();
1276 
1277   Stack<oop,mtGC> oop_stack;
1278 
1279   // First, we process all GC roots. This populates the work stack with initial objects.
1280   ShenandoahAllRootScanner rp(1, ShenandoahPhaseTimings::_num_phases);
1281   ObjectIterateScanRootClosure oops(&_aux_bit_map, &oop_stack);
1282 
1283   if (unload_classes()) {
1284     rp.strong_roots_do_unchecked(&oops);
1285   } else {
1286     rp.roots_do_unchecked(&oops);
1287   }
1288 
1289   // Work through the oop stack to traverse heap.
1290   while (! oop_stack.is_empty()) {
1291     oop obj = oop_stack.pop();
1292     assert(oopDesc::is_oop(obj), "must be a valid oop");
1293     cl->do_object(obj);
1294     obj->oop_iterate(&oops);
1295   }
1296 
1297   assert(oop_stack.is_empty(), "should be empty");
1298 
1299   if (!_aux_bitmap_region_special && !os::uncommit_memory((char*)_aux_bitmap_region.start(), _aux_bitmap_region.byte_size())) {
1300     log_warning(gc)("Could not uncommit native memory for auxiliary marking bitmap for heap iteration");
1301   }
1302 }
1303 
1304 void ShenandoahHeap::safe_object_iterate(ObjectClosure* cl) {
1305   assert(SafepointSynchronize::is_at_safepoint(), "safe iteration is only available during safepoints");
1306   object_iterate(cl);
1307 }


< prev index next >