8231198: Shenandoah: heap walking should visit all roots most of the time
Reviewed-by: zgu, rkennke
--- 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);