# HG changeset patch # User zgu # Date 1560203756 14400 # Mon Jun 10 17:55:56 2019 -0400 # Node ID 919d5e618fd0949721e35ba2044155ea79ed6b24 # Parent 218f5a414379e7bb9ee2e742dad7ac07f6ebcadc 8225483: Shenandoah: Enhance native access barrier diff --git a/src/hotspot/share/gc/shenandoah/shenandoahBarrierSet.hpp b/src/hotspot/share/gc/shenandoah/shenandoahBarrierSet.hpp --- a/src/hotspot/share/gc/shenandoah/shenandoahBarrierSet.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahBarrierSet.hpp @@ -177,6 +177,11 @@ template static oop oop_load_not_in_heap(T* addr); +#ifdef ASSERT + // Used for catching bad stores + template + static void oop_store_not_in_heap(T* addr, oop value); +#endif template static oop oop_atomic_cmpxchg_not_in_heap(oop new_value, T* addr, oop compare_value); diff --git a/src/hotspot/share/gc/shenandoah/shenandoahBarrierSet.inline.hpp b/src/hotspot/share/gc/shenandoah/shenandoahBarrierSet.inline.hpp --- a/src/hotspot/share/gc/shenandoah/shenandoahBarrierSet.inline.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahBarrierSet.inline.hpp @@ -25,6 +25,7 @@ #define SHARE_GC_SHENANDOAH_SHENANDOAHBARRIERSET_INLINE_HPP #include "gc/shared/barrierSet.hpp" +#include "gc/shenandoah/shenandoahAsserts.hpp" #include "gc/shenandoah/shenandoahBarrierSet.hpp" #include "gc/shenandoah/shenandoahForwarding.inline.hpp" #include "gc/shenandoah/shenandoahHeap.inline.hpp" @@ -65,7 +66,17 @@ template inline oop ShenandoahBarrierSet::AccessBarrier::oop_load_not_in_heap(T* addr) { oop value = Raw::oop_load_not_in_heap(addr); - value = ShenandoahBarrierSet::barrier_set()->load_reference_barrier(value); + if (CompressedOops::is_null(value)) return value; + + ShenandoahHeap* const heap = ShenandoahHeap::heap(); + if (heap->is_evacuation_in_progress()) { + ShenandoahMarkingContext* const marking_context = heap->complete_marking_context(); + if (!marking_context->is_marked(value)) { + return NULL; + } + } + + value = ShenandoahBarrierSet::barrier_set()->load_reference_barrier_not_null(value); keep_alive_if_weak(decorators, value); return value; } @@ -81,6 +92,17 @@ Raw::oop_store_in_heap(addr, value); } +#ifdef ASSERT +template +template +inline void ShenandoahBarrierSet::AccessBarrier::oop_store_not_in_heap(T* addr, oop value) { + ShenandoahHeap* const heap = ShenandoahHeap::heap(); + shenandoah_assert_marked_if(NULL, value, !CompressedOops::is_null(value) && heap->is_evacuation_in_progress()); + + Raw::oop_store(addr, value); +} +#endif + template inline void ShenandoahBarrierSet::AccessBarrier::oop_store_in_heap_at(oop base, ptrdiff_t offset, oop value) { oop_store_in_heap(AccessInternal::oop_field_addr(base, offset), value);