From 69daedfd2316815f63d7f3c6ba79d2bb77b427ec Mon Sep 17 00:00:00 2001 From: Zhengyu Gu Date: Wed, 12 May 2021 12:34:55 +0000 Subject: [PATCH] 8266845: Shenandoah: Simplify SBS::load_reference_barrier implementation Reviewed-by: shade --- .../share/gc/shenandoah/shenandoahBarrierSet.inline.hpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/hotspot/share/gc/shenandoah/shenandoahBarrierSet.inline.hpp b/src/hotspot/share/gc/shenandoah/shenandoahBarrierSet.inline.hpp index cc8c8ce5f77..b15542ac3fb 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahBarrierSet.inline.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahBarrierSet.inline.hpp @@ -100,9 +100,12 @@ inline oop ShenandoahBarrierSet::load_reference_barrier(oop obj) { template inline oop ShenandoahBarrierSet::load_reference_barrier(oop obj, T* load_addr) { + if (obj == NULL) { + return NULL; + } // Prevent resurrection of unreachable phantom (i.e. weak-native) references. - if (HasDecorator::value && obj != NULL && + if (HasDecorator::value && _heap->is_concurrent_weak_root_in_progress() && !_heap->marking_context()->is_marked(obj)) { return NULL; @@ -110,14 +113,14 @@ inline oop ShenandoahBarrierSet::load_reference_barrier(oop obj, T* load_addr) { // Prevent resurrection of unreachable weak references. if ((HasDecorator::value || HasDecorator::value) && - obj != NULL && _heap->is_concurrent_weak_root_in_progress() && + _heap->is_concurrent_weak_root_in_progress() && !_heap->marking_context()->is_marked_strong(obj)) { return NULL; } // Prevent resurrection of unreachable objects that are visited during // concurrent class-unloading. - if (HasDecorator::value && obj != NULL && + if (HasDecorator::value && _heap->is_evacuation_in_progress() && !_heap->marking_context()->is_marked(obj)) { return obj;