8231198: Shenandoah: heap walking should visit all roots most of the time
authorshade
Thu, 19 Sep 2019 20:26:52 +0200
changeset 58232 de9d23469c68
parent 58231 13e041be4e5c
child 58233 89033e6641ed
8231198: Shenandoah: heap walking should visit all roots most of the time Reviewed-by: zgu, rkennke
src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp
--- a/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp	Thu Sep 19 20:26:51 2019 +0200
+++ b/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp	Thu Sep 19 20:26:52 2019 +0200
@@ -1296,7 +1296,10 @@
   ShenandoahHeapIterationRootScanner rp;
   ObjectIterateScanRootClosure oops(&_aux_bit_map, &oop_stack);
 
-  if (unload_classes()) {
+  // If we are unloading classes right now, we should not touch weak roots,
+  // on the off-chance we would evacuate them and make them live accidentally.
+  // In other cases, we have to scan all roots.
+  if (is_evacuation_in_progress() && unload_classes()) {
     rp.strong_roots_do(&oops);
   } else {
     rp.roots_do(&oops);