< prev index next >

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

Print this page
rev 56313 : 8231197: Shenandoah: JVMTI heap walking cleanup crashes with NULL forwardee
Reviewed-by: XXX
rev 56314 : 8231198: Shenandoah: heap walking should visit all roots most of the time
Reviewed-by: XXX


1279  * For all those reasons, we implement object iteration as a single marking traversal, reporting
1280  * objects as we mark+traverse through the heap, starting from GC roots. JVMTI IterateThroughHeap
1281  * is allowed to report dead objects, but is not required to do so.
1282  */
1283 void ShenandoahHeap::object_iterate(ObjectClosure* cl) {
1284   assert(SafepointSynchronize::is_at_safepoint(), "safe iteration is only available during safepoints");
1285   if (!_aux_bitmap_region_special && !os::commit_memory((char*)_aux_bitmap_region.start(), _aux_bitmap_region.byte_size(), false)) {
1286     log_warning(gc)("Could not commit native memory for auxiliary marking bitmap for heap iteration");
1287     return;
1288   }
1289 
1290   // Reset bitmap
1291   _aux_bit_map.clear();
1292 
1293   Stack<oop,mtGC> oop_stack;
1294 
1295   // First, we process GC roots according to current GC cycle. This populates the work stack with initial objects.
1296   ShenandoahHeapIterationRootScanner rp;
1297   ObjectIterateScanRootClosure oops(&_aux_bit_map, &oop_stack);
1298 
1299   if (unload_classes()) {



1300     rp.strong_roots_do(&oops);
1301   } else {
1302     rp.roots_do(&oops);
1303   }
1304 
1305   // Work through the oop stack to traverse heap.
1306   while (! oop_stack.is_empty()) {
1307     oop obj = oop_stack.pop();
1308     assert(oopDesc::is_oop(obj), "must be a valid oop");
1309     cl->do_object(obj);
1310     obj->oop_iterate(&oops);
1311   }
1312 
1313   assert(oop_stack.is_empty(), "should be empty");
1314 
1315   if (!_aux_bitmap_region_special && !os::uncommit_memory((char*)_aux_bitmap_region.start(), _aux_bitmap_region.byte_size())) {
1316     log_warning(gc)("Could not uncommit native memory for auxiliary marking bitmap for heap iteration");
1317   }
1318 }
1319 




1279  * For all those reasons, we implement object iteration as a single marking traversal, reporting
1280  * objects as we mark+traverse through the heap, starting from GC roots. JVMTI IterateThroughHeap
1281  * is allowed to report dead objects, but is not required to do so.
1282  */
1283 void ShenandoahHeap::object_iterate(ObjectClosure* cl) {
1284   assert(SafepointSynchronize::is_at_safepoint(), "safe iteration is only available during safepoints");
1285   if (!_aux_bitmap_region_special && !os::commit_memory((char*)_aux_bitmap_region.start(), _aux_bitmap_region.byte_size(), false)) {
1286     log_warning(gc)("Could not commit native memory for auxiliary marking bitmap for heap iteration");
1287     return;
1288   }
1289 
1290   // Reset bitmap
1291   _aux_bit_map.clear();
1292 
1293   Stack<oop,mtGC> oop_stack;
1294 
1295   // First, we process GC roots according to current GC cycle. This populates the work stack with initial objects.
1296   ShenandoahHeapIterationRootScanner rp;
1297   ObjectIterateScanRootClosure oops(&_aux_bit_map, &oop_stack);
1298 
1299   // If we are unloading classes right now, we should not touch weak roots,
1300   // on the off-chance we would evacuate them and make them live accidentally.
1301   // In other cases, we have to scan all roots.
1302   if (is_evacuation_in_progress() && unload_classes()) {
1303     rp.strong_roots_do(&oops);
1304   } else {
1305     rp.roots_do(&oops);
1306   }
1307 
1308   // Work through the oop stack to traverse heap.
1309   while (! oop_stack.is_empty()) {
1310     oop obj = oop_stack.pop();
1311     assert(oopDesc::is_oop(obj), "must be a valid oop");
1312     cl->do_object(obj);
1313     obj->oop_iterate(&oops);
1314   }
1315 
1316   assert(oop_stack.is_empty(), "should be empty");
1317 
1318   if (!_aux_bitmap_region_special && !os::uncommit_memory((char*)_aux_bitmap_region.start(), _aux_bitmap_region.byte_size())) {
1319     log_warning(gc)("Could not uncommit native memory for auxiliary marking bitmap for heap iteration");
1320   }
1321 }
1322 


< prev index next >