8225483: Shenandoah: Enhance native access barrier
authorzgu
Mon, 15 Jul 2019 11:23:05 -0400
changeset 55681 7b671e6b0d5b
parent 55680 cd48f8f260c8
child 55682 70fab3a8ff02
8225483: Shenandoah: Enhance native access barrier Reviewed-by: rkennke
src/hotspot/share/gc/shenandoah/shenandoahBarrierSet.cpp
src/hotspot/share/gc/shenandoah/shenandoahBarrierSet.hpp
src/hotspot/share/gc/shenandoah/shenandoahBarrierSet.inline.hpp
--- a/src/hotspot/share/gc/shenandoah/shenandoahBarrierSet.cpp	Mon Jul 15 10:21:33 2019 +0800
+++ b/src/hotspot/share/gc/shenandoah/shenandoahBarrierSet.cpp	Mon Jul 15 11:23:05 2019 -0400
@@ -360,5 +360,14 @@
 }
 
 oop ShenandoahBarrierSet::oop_load_from_native_barrier(oop obj) {
-  return load_reference_barrier(obj);
+  if (CompressedOops::is_null(obj)) {
+    return NULL;
+  }
+
+  if (_heap->is_evacuation_in_progress() &&
+      !_heap->complete_marking_context()->is_marked(obj)) {
+    return NULL;
+  }
+
+  return load_reference_barrier_not_null(obj);
 }
--- a/src/hotspot/share/gc/shenandoah/shenandoahBarrierSet.hpp	Mon Jul 15 10:21:33 2019 +0800
+++ b/src/hotspot/share/gc/shenandoah/shenandoahBarrierSet.hpp	Mon Jul 15 11:23:05 2019 -0400
@@ -179,6 +179,10 @@
     template <typename T>
     static oop oop_load_not_in_heap(T* addr);
 
+    // Used for catching bad stores
+    template <typename T>
+    static void oop_store_not_in_heap(T* addr, oop value);
+
     template <typename T>
     static oop oop_atomic_cmpxchg_not_in_heap(oop new_value, T* addr, oop compare_value);
 
--- a/src/hotspot/share/gc/shenandoah/shenandoahBarrierSet.inline.hpp	Mon Jul 15 10:21:33 2019 +0800
+++ b/src/hotspot/share/gc/shenandoah/shenandoahBarrierSet.inline.hpp	Mon Jul 15 11:23:05 2019 -0400
@@ -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"
@@ -88,6 +89,13 @@
 
 template <DecoratorSet decorators, typename BarrierSetT>
 template <typename T>
+inline void ShenandoahBarrierSet::AccessBarrier<decorators, BarrierSetT>::oop_store_not_in_heap(T* addr, oop value) {
+  shenandoah_assert_marked_if(NULL, value, !CompressedOops::is_null(value) && ShenandoahHeap::heap()->is_evacuation_in_progress());
+  Raw::oop_store(addr, value);
+}
+
+template <DecoratorSet decorators, typename BarrierSetT>
+template <typename T>
 inline oop ShenandoahBarrierSet::AccessBarrier<decorators, BarrierSetT>::oop_atomic_cmpxchg_not_in_heap(oop new_value, T* addr, oop compare_value) {
   oop res;
   oop expected = compare_value;