8208582: Introduce native oop barriers in C1 for OopHandle
authoreosterlund
Wed, 15 Aug 2018 09:51:57 +0200
changeset 51408 59269a19f108
parent 51407 910f7b56592f
child 51409 c86627b0bcce
8208582: Introduce native oop barriers in C1 for OopHandle Reviewed-by: coleenp, kvn
src/hotspot/share/c1/c1_LIRGenerator.cpp
src/hotspot/share/c1/c1_LIRGenerator.hpp
src/hotspot/share/gc/shared/c1/barrierSetC1.cpp
src/hotspot/share/gc/shared/c1/barrierSetC1.hpp
--- a/src/hotspot/share/c1/c1_LIRGenerator.cpp	Tue Aug 14 18:16:47 2018 -0700
+++ b/src/hotspot/share/c1/c1_LIRGenerator.cpp	Wed Aug 15 09:51:57 2018 +0200
@@ -1285,9 +1285,10 @@
   // FIXME T_ADDRESS should actually be T_METADATA but it can't because the
   // meaning of these two is mixed up (see JDK-8026837).
   __ move(new LIR_Address(rcvr.result(), oopDesc::klass_offset_in_bytes(), T_ADDRESS), temp, info);
-  __ move_wide(new LIR_Address(temp, in_bytes(Klass::java_mirror_offset()), T_ADDRESS), result);
+  __ move_wide(new LIR_Address(temp, in_bytes(Klass::java_mirror_offset()), T_ADDRESS), temp);
   // mirror = ((OopHandle)mirror)->resolve();
-  __ move_wide(new LIR_Address(result, T_OBJECT), result);
+  access_load(IN_NATIVE, T_OBJECT,
+              LIR_OprFact::address(new LIR_Address(temp, T_OBJECT)), result);
 }
 
 // java.lang.Class::isPrimitive()
@@ -1623,6 +1624,18 @@
   }
 }
 
+void LIRGenerator::access_load(DecoratorSet decorators, BasicType type,
+                               LIR_Opr addr, LIR_Opr result) {
+  decorators |= C1_READ_ACCESS;
+  LIRAccess access(this, decorators, LIR_OprFact::illegalOpr, LIR_OprFact::illegalOpr, type);
+  access.set_resolved_addr(addr);
+  if (access.is_raw()) {
+    _barrier_set->BarrierSetC1::load(access, result);
+  } else {
+    _barrier_set->load(access, result);
+  }
+}
+
 void LIRGenerator::access_store_at(DecoratorSet decorators, BasicType type,
                                    LIRItem& base, LIR_Opr offset, LIR_Opr value,
                                    CodeEmitInfo* patch_info, CodeEmitInfo* store_emit_info) {
--- a/src/hotspot/share/c1/c1_LIRGenerator.hpp	Tue Aug 14 18:16:47 2018 -0700
+++ b/src/hotspot/share/c1/c1_LIRGenerator.hpp	Wed Aug 15 09:51:57 2018 +0200
@@ -288,6 +288,9 @@
                       LIRItem& base, LIR_Opr offset, LIR_Opr result,
                       CodeEmitInfo* patch_info = NULL, CodeEmitInfo* load_emit_info = NULL);
 
+  void access_load(DecoratorSet decorators, BasicType type,
+                   LIR_Opr addr, LIR_Opr result);
+
   LIR_Opr access_atomic_cmpxchg_at(DecoratorSet decorators, BasicType type,
                                    LIRItem& base, LIRItem& offset, LIRItem& cmp_value, LIRItem& new_value);
 
--- a/src/hotspot/share/gc/shared/c1/barrierSetC1.cpp	Tue Aug 14 18:16:47 2018 -0700
+++ b/src/hotspot/share/gc/shared/c1/barrierSetC1.cpp	Wed Aug 15 09:51:57 2018 +0200
@@ -90,6 +90,13 @@
   load_at_resolved(access, result);
 }
 
+void BarrierSetC1::load(LIRAccess& access, LIR_Opr result) {
+  DecoratorSet decorators = access.decorators();
+  bool in_heap = (decorators & IN_HEAP) != 0;
+  assert(!in_heap, "consider using load_at");
+  load_at_resolved(access, result);
+}
+
 LIR_Opr BarrierSetC1::atomic_cmpxchg_at(LIRAccess& access, LIRItem& cmp_value, LIRItem& new_value) {
   DecoratorSet decorators = access.decorators();
   bool in_heap = (decorators & IN_HEAP) != 0;
@@ -159,13 +166,16 @@
   bool is_volatile = (((decorators & MO_SEQ_CST) != 0) || AlwaysAtomicAccesses) && os::is_MP();
   bool needs_patching = (decorators & C1_NEEDS_PATCHING) != 0;
   bool mask_boolean = (decorators & C1_MASK_BOOLEAN) != 0;
+  bool in_native = (decorators & IN_NATIVE) != 0;
 
   if (support_IRIW_for_not_multiple_copy_atomic_cpu && is_volatile) {
     __ membar();
   }
 
   LIR_PatchCode patch_code = needs_patching ? lir_patch_normal : lir_patch_none;
-  if (is_volatile && !needs_patching) {
+  if (in_native) {
+    __ move_wide(access.resolved_addr()->as_address_ptr(), result);
+  } else if (is_volatile && !needs_patching) {
     gen->volatile_field_load(access.resolved_addr()->as_address_ptr(), result, access.access_emit_info());
   } else {
     __ load(access.resolved_addr()->as_address_ptr(), result, access.access_emit_info(), patch_code);
--- a/src/hotspot/share/gc/shared/c1/barrierSetC1.hpp	Tue Aug 14 18:16:47 2018 -0700
+++ b/src/hotspot/share/gc/shared/c1/barrierSetC1.hpp	Wed Aug 15 09:51:57 2018 +0200
@@ -127,6 +127,7 @@
 public:
   virtual void store_at(LIRAccess& access, LIR_Opr value);
   virtual void load_at(LIRAccess& access, LIR_Opr result);
+  virtual void load(LIRAccess& access, LIR_Opr result);
 
   virtual LIR_Opr atomic_cmpxchg_at(LIRAccess& access, LIRItem& cmp_value, LIRItem& new_value);