< prev index next >

src/share/vm/prims/unsafe.cpp

Print this page

        

@@ -25,10 +25,11 @@
 #include "precompiled.hpp"
 #include "classfile/vmSymbols.hpp"
 #include "utilities/macros.hpp"
 #if INCLUDE_ALL_GCS
 #include "gc_implementation/g1/g1SATBCardTableModRefBS.hpp"
+#include "gc_implementation/shenandoah/shenandoahBarrierSet.inline.hpp"
 #endif // INCLUDE_ALL_GCS
 #include "memory/allocation.inline.hpp"
 #include "prims/jni.h"
 #include "prims/jvm.h"
 #include "runtime/globals.hpp"

@@ -194,11 +195,10 @@
     v = oopDesc::decode_heap_oop(n);                                \
   } else {                            \
     v = *(oop*)index_oop_from_field_offset_long(p, offset);                 \
   }
 
-
 // Get/SetObject must be special-cased, since it works with handles.
 
 // We could be accessing the referent field in a reference
 // object. If G1 is enabled then we need to register non-null
 // referent with the SATB barrier.

@@ -216,11 +216,11 @@
 }
 #endif
 
 static void ensure_satb_referent_alive(oop o, jlong offset, oop v) {
 #if INCLUDE_ALL_GCS
-  if (UseG1GC && v != NULL && is_java_lang_ref_Reference_access(o, offset)) {
+  if ((UseG1GC || (UseShenandoahGC && ShenandoahKeepAliveBarrier)) && v != NULL && is_java_lang_ref_Reference_access(o, offset)) {
     G1SATBCardTableModRefBS::enqueue(v);
   }
 #endif
 }
 

@@ -228,10 +228,16 @@
 UNSAFE_ENTRY(jobject, Unsafe_GetObject140(JNIEnv *env, jobject unsafe, jobject obj, jint offset))
   UnsafeWrapper("Unsafe_GetObject");
   if (obj == NULL)  THROW_0(vmSymbols::java_lang_NullPointerException());
   GET_OOP_FIELD(obj, offset, v)
 
+#if INCLUDE_ALL_GCS
+  if (UseShenandoahGC) {
+    v = ShenandoahBarrierSet::barrier_set()->load_reference_barrier(v);
+  }
+#endif
+
   ensure_satb_referent_alive(p, offset, v);
 
   return JNIHandles::make_local(env, v);
 UNSAFE_END
 

@@ -264,10 +270,16 @@
 // That is, it should be in the range [0, MAX_OBJECT_SIZE].
 UNSAFE_ENTRY(jobject, Unsafe_GetObject(JNIEnv *env, jobject unsafe, jobject obj, jlong offset))
   UnsafeWrapper("Unsafe_GetObject");
   GET_OOP_FIELD(obj, offset, v)
 
+#if INCLUDE_ALL_GCS
+  if (UseShenandoahGC) {
+    v = ShenandoahBarrierSet::barrier_set()->load_reference_barrier(v);
+  }
+#endif
+
   ensure_satb_referent_alive(p, offset, v);
 
   return JNIHandles::make_local(env, v);
 UNSAFE_END
 

@@ -292,10 +304,16 @@
     (void)const_cast<oop&>(v = oopDesc::decode_heap_oop(n));
   } else {
     (void)const_cast<oop&>(v = *(volatile oop*) addr);
   }
 
+#if INCLUDE_ALL_GCS
+  if (UseShenandoahGC) {
+    (void)const_cast<oop&>(v = ShenandoahBarrierSet::barrier_set()->load_reference_barrier(v));
+  }
+#endif
+
   ensure_satb_referent_alive(p, offset, v);
 
   OrderAccess::acquire();
   return JNIHandles::make_local(env, v);
 UNSAFE_END
< prev index next >