8210885: Convert left over loads/stores to access api
authorroland
Tue, 18 Sep 2018 20:49:44 +0200
changeset 51880 ec4c3c287ca7
parent 51879 6ffa38b8da65
child 51881 69faed47bf35
child 51963 8f0f7f2ae20b
8210885: Convert left over loads/stores to access api Reviewed-by: thartmann, rkennke
src/hotspot/share/gc/shared/c2/barrierSetC2.cpp
src/hotspot/share/gc/shared/c2/barrierSetC2.hpp
src/hotspot/share/opto/graphKit.cpp
src/hotspot/share/opto/graphKit.hpp
src/hotspot/share/opto/library_call.cpp
src/hotspot/share/opto/parse2.cpp
src/hotspot/share/opto/parse3.cpp
src/hotspot/share/opto/parseHelper.cpp
src/hotspot/share/opto/stringopts.cpp
--- a/src/hotspot/share/gc/shared/c2/barrierSetC2.cpp	Wed Sep 12 11:13:09 2018 +0200
+++ b/src/hotspot/share/gc/shared/c2/barrierSetC2.cpp	Tue Sep 18 20:49:44 2018 +0200
@@ -310,7 +310,7 @@
 
 //--------------------------- atomic operations---------------------------------
 
-static void pin_atomic_op(C2AtomicAccess& access) {
+void BarrierSetC2::pin_atomic_op(C2AtomicAccess& access) const {
   if (!access.needs_pinning()) {
     return;
   }
--- a/src/hotspot/share/gc/shared/c2/barrierSetC2.hpp	Wed Sep 12 11:13:09 2018 +0200
+++ b/src/hotspot/share/gc/shared/c2/barrierSetC2.hpp	Tue Sep 18 20:49:44 2018 +0200
@@ -76,14 +76,12 @@
 
 // This class wraps a node and a pointer type.
 class C2AccessValuePtr: public C2AccessValue {
-  int _alias_idx;
 
 public:
   C2AccessValuePtr(Node* node, const TypePtr* type) :
     C2AccessValue(node, reinterpret_cast<const Type*>(type)) {}
 
   const TypePtr* type() const { return reinterpret_cast<const TypePtr*>(_type); }
-  int alias_idx() const       { return _alias_idx; }
 };
 
 // This class wraps a bunch of context parameters thare are passed around in the
@@ -175,6 +173,7 @@
                                                 Node* new_val, const Type* value_type) const;
   virtual Node* atomic_xchg_at_resolved(C2AtomicAccess& access, Node* new_val, const Type* val_type) const;
   virtual Node* atomic_add_at_resolved(C2AtomicAccess& access, Node* new_val, const Type* val_type) const;
+  void pin_atomic_op(C2AtomicAccess& access) const;
 
 public:
   // This is the entry-point for the backend to perform accesses through the Access API.
--- a/src/hotspot/share/opto/graphKit.cpp	Wed Sep 12 11:13:09 2018 +0200
+++ b/src/hotspot/share/opto/graphKit.cpp	Tue Sep 18 20:49:44 2018 +0200
@@ -605,7 +605,7 @@
 
       Node *adr = basic_plus_adr(ex_node, ex_node, offset);
       const TypeOopPtr* val_type = TypeOopPtr::make_from_klass(env()->String_klass());
-      Node *store = access_store_at(control(), ex_node, adr, adr_typ, null(), val_type, T_OBJECT, IN_HEAP);
+      Node *store = access_store_at(ex_node, adr, adr_typ, null(), val_type, T_OBJECT, IN_HEAP);
 
       add_exception_state(make_exception_state(ex_node));
       return;
@@ -1544,8 +1544,7 @@
   return st;
 }
 
-Node* GraphKit::access_store_at(Node* ctl,
-                                Node* obj,
+Node* GraphKit::access_store_at(Node* obj,
                                 Node* adr,
                                 const TypePtr* adr_type,
                                 Node* val,
@@ -1559,7 +1558,6 @@
     val = _gvn.makecon(TypePtr::NULL_PTR);
   }
 
-  set_control(ctl);
   if (stopped()) {
     return top(); // Dead path ?
   }
@@ -1612,8 +1610,7 @@
   }
 }
 
-Node* GraphKit::access_atomic_cmpxchg_val_at(Node* ctl,
-                                             Node* obj,
+Node* GraphKit::access_atomic_cmpxchg_val_at(Node* obj,
                                              Node* adr,
                                              const TypePtr* adr_type,
                                              int alias_idx,
@@ -1622,7 +1619,6 @@
                                              const Type* value_type,
                                              BasicType bt,
                                              DecoratorSet decorators) {
-  set_control(ctl);
   C2AccessValuePtr addr(adr, adr_type);
   C2AtomicAccess access(this, decorators | C2_READ_ACCESS | C2_WRITE_ACCESS,
                         bt, obj, addr, alias_idx);
@@ -1633,8 +1629,7 @@
   }
 }
 
-Node* GraphKit::access_atomic_cmpxchg_bool_at(Node* ctl,
-                                              Node* obj,
+Node* GraphKit::access_atomic_cmpxchg_bool_at(Node* obj,
                                               Node* adr,
                                               const TypePtr* adr_type,
                                               int alias_idx,
@@ -1643,7 +1638,6 @@
                                               const Type* value_type,
                                               BasicType bt,
                                               DecoratorSet decorators) {
-  set_control(ctl);
   C2AccessValuePtr addr(adr, adr_type);
   C2AtomicAccess access(this, decorators | C2_READ_ACCESS | C2_WRITE_ACCESS,
                         bt, obj, addr, alias_idx);
@@ -1654,8 +1648,7 @@
   }
 }
 
-Node* GraphKit::access_atomic_xchg_at(Node* ctl,
-                                      Node* obj,
+Node* GraphKit::access_atomic_xchg_at(Node* obj,
                                       Node* adr,
                                       const TypePtr* adr_type,
                                       int alias_idx,
@@ -1663,7 +1656,6 @@
                                       const Type* value_type,
                                       BasicType bt,
                                       DecoratorSet decorators) {
-  set_control(ctl);
   C2AccessValuePtr addr(adr, adr_type);
   C2AtomicAccess access(this, decorators | C2_READ_ACCESS | C2_WRITE_ACCESS,
                         bt, obj, addr, alias_idx);
@@ -1674,8 +1666,7 @@
   }
 }
 
-Node* GraphKit::access_atomic_add_at(Node* ctl,
-                                     Node* obj,
+Node* GraphKit::access_atomic_add_at(Node* obj,
                                      Node* adr,
                                      const TypePtr* adr_type,
                                      int alias_idx,
@@ -1683,7 +1674,6 @@
                                      const Type* value_type,
                                      BasicType bt,
                                      DecoratorSet decorators) {
-  set_control(ctl);
   C2AccessValuePtr addr(adr, adr_type);
   C2AtomicAccess access(this, decorators | C2_READ_ACCESS | C2_WRITE_ACCESS, bt, obj, addr, alias_idx);
   if (access.is_raw()) {
@@ -1693,8 +1683,7 @@
   }
 }
 
-void GraphKit::access_clone(Node* ctl, Node* src, Node* dst, Node* size, bool is_array) {
-  set_control(ctl);
+void GraphKit::access_clone(Node* src, Node* dst, Node* size, bool is_array) {
   return _barrier_set->clone(this, src, dst, size, is_array);
 }
 
@@ -3849,14 +3838,14 @@
   sync_kit(ideal);
 }
 
-Node* GraphKit::load_String_length(Node* ctrl, Node* str) {
-  Node* len = load_array_length(load_String_value(ctrl, str));
-  Node* coder = load_String_coder(ctrl, str);
+Node* GraphKit::load_String_length(Node* str, bool set_ctrl) {
+  Node* len = load_array_length(load_String_value(str, set_ctrl));
+  Node* coder = load_String_coder(str, set_ctrl);
   // Divide length by 2 if coder is UTF16
   return _gvn.transform(new RShiftINode(len, coder));
 }
 
-Node* GraphKit::load_String_value(Node* ctrl, Node* str) {
+Node* GraphKit::load_String_value(Node* str, bool set_ctrl) {
   int value_offset = java_lang_String::value_offset_in_bytes();
   const TypeInstPtr* string_type = TypeInstPtr::make(TypePtr::NotNull, C->env()->String_klass(),
                                                      false, NULL, 0);
@@ -3866,7 +3855,7 @@
                                                   ciTypeArrayKlass::make(T_BYTE), true, 0);
   Node* p = basic_plus_adr(str, str, value_offset);
   Node* load = access_load_at(str, p, value_field_type, value_type, T_OBJECT,
-                              IN_HEAP | C2_CONTROL_DEPENDENT_LOAD);
+                              IN_HEAP | (set_ctrl ? C2_CONTROL_DEPENDENT_LOAD : 0) | MO_UNORDERED);
   // String.value field is known to be @Stable.
   if (UseImplicitStableValues) {
     load = cast_array_to_stable(load, value_type);
@@ -3874,7 +3863,7 @@
   return load;
 }
 
-Node* GraphKit::load_String_coder(Node* ctrl, Node* str) {
+Node* GraphKit::load_String_coder(Node* str, bool set_ctrl) {
   if (!CompactStrings) {
     return intcon(java_lang_String::CODER_UTF16);
   }
@@ -3883,27 +3872,31 @@
                                                      false, NULL, 0);
   const TypePtr* coder_field_type = string_type->add_offset(coder_offset);
   int coder_field_idx = C->get_alias_index(coder_field_type);
-  return make_load(ctrl, basic_plus_adr(str, str, coder_offset),
-                   TypeInt::BYTE, T_BYTE, coder_field_idx, MemNode::unordered);
+
+  Node* p = basic_plus_adr(str, str, coder_offset);
+  Node* load = access_load_at(str, p, coder_field_type, TypeInt::BYTE, T_BYTE,
+                              IN_HEAP | (set_ctrl ? C2_CONTROL_DEPENDENT_LOAD : 0) | MO_UNORDERED);
+  return load;
 }
 
-void GraphKit::store_String_value(Node* ctrl, Node* str, Node* value) {
+void GraphKit::store_String_value(Node* str, Node* value) {
   int value_offset = java_lang_String::value_offset_in_bytes();
   const TypeInstPtr* string_type = TypeInstPtr::make(TypePtr::NotNull, C->env()->String_klass(),
                                                      false, NULL, 0);
   const TypePtr* value_field_type = string_type->add_offset(value_offset);
-  access_store_at(ctrl, str,  basic_plus_adr(str, value_offset), value_field_type,
-                  value, TypeAryPtr::BYTES, T_OBJECT, IN_HEAP);
+
+  access_store_at(str,  basic_plus_adr(str, value_offset), value_field_type,
+                  value, TypeAryPtr::BYTES, T_OBJECT, IN_HEAP | MO_UNORDERED);
 }
 
-void GraphKit::store_String_coder(Node* ctrl, Node* str, Node* value) {
+void GraphKit::store_String_coder(Node* str, Node* value) {
   int coder_offset = java_lang_String::coder_offset_in_bytes();
   const TypeInstPtr* string_type = TypeInstPtr::make(TypePtr::NotNull, C->env()->String_klass(),
                                                      false, NULL, 0);
   const TypePtr* coder_field_type = string_type->add_offset(coder_offset);
-  int coder_field_idx = C->get_alias_index(coder_field_type);
-  store_to_memory(ctrl, basic_plus_adr(str, coder_offset),
-                  value, T_BYTE, coder_field_idx, MemNode::unordered);
+
+  access_store_at(str, basic_plus_adr(str, coder_offset), coder_field_type,
+                  value, TypeInt::BYTE, T_BYTE, IN_HEAP | MO_UNORDERED);
 }
 
 // Capture src and dst memory state with a MergeMemNode
--- a/src/hotspot/share/opto/graphKit.hpp	Wed Sep 12 11:13:09 2018 +0200
+++ b/src/hotspot/share/opto/graphKit.hpp	Tue Sep 18 20:49:44 2018 +0200
@@ -572,8 +572,7 @@
 
   // Perform decorated accesses
 
-  Node* access_store_at(Node* ctl,
-                        Node* obj,   // containing obj
+  Node* access_store_at(Node* obj,   // containing obj
                         Node* adr,   // actual adress to store val at
                         const TypePtr* adr_type,
                         Node* val,
@@ -593,8 +592,7 @@
                     BasicType bt,
                     DecoratorSet decorators);
 
-  Node* access_atomic_cmpxchg_val_at(Node* ctl,
-                                     Node* obj,
+  Node* access_atomic_cmpxchg_val_at(Node* obj,
                                      Node* adr,
                                      const TypePtr* adr_type,
                                      int alias_idx,
@@ -604,8 +602,7 @@
                                      BasicType bt,
                                      DecoratorSet decorators);
 
-  Node* access_atomic_cmpxchg_bool_at(Node* ctl,
-                                      Node* obj,
+  Node* access_atomic_cmpxchg_bool_at(Node* obj,
                                       Node* adr,
                                       const TypePtr* adr_type,
                                       int alias_idx,
@@ -615,8 +612,7 @@
                                       BasicType bt,
                                       DecoratorSet decorators);
 
-  Node* access_atomic_xchg_at(Node* ctl,
-                              Node* obj,
+  Node* access_atomic_xchg_at(Node* obj,
                               Node* adr,
                               const TypePtr* adr_type,
                               int alias_idx,
@@ -625,8 +621,7 @@
                               BasicType bt,
                               DecoratorSet decorators);
 
-  Node* access_atomic_add_at(Node* ctl,
-                             Node* obj,
+  Node* access_atomic_add_at(Node* obj,
                              Node* adr,
                              const TypePtr* adr_type,
                              int alias_idx,
@@ -635,7 +630,7 @@
                              BasicType bt,
                              DecoratorSet decorators);
 
-  void access_clone(Node* ctl, Node* src, Node* dst, Node* size, bool is_array);
+  void access_clone(Node* src, Node* dst, Node* size, bool is_array);
 
   Node* access_resolve(Node* n, DecoratorSet decorators);
 
@@ -849,11 +844,11 @@
                   bool deoptimize_on_exception = false);
 
   // java.lang.String helpers
-  Node* load_String_length(Node* ctrl, Node* str);
-  Node* load_String_value(Node* ctrl, Node* str);
-  Node* load_String_coder(Node* ctrl, Node* str);
-  void store_String_value(Node* ctrl, Node* str, Node* value);
-  void store_String_coder(Node* ctrl, Node* str, Node* value);
+  Node* load_String_length(Node* str, bool set_ctrl);
+  Node* load_String_value(Node* str, bool set_ctrl);
+  Node* load_String_coder(Node* str, bool set_ctrl);
+  void store_String_value(Node* str, Node* value);
+  void store_String_coder(Node* str, Node* value);
   Node* capture_memory(const TypePtr* src_type, const TypePtr* dst_type);
   Node* compress_string(Node* src, const TypeAryPtr* src_type, Node* dst, Node* count);
   void inflate_string(Node* src, Node* dst, const TypeAryPtr* dst_type, Node* count);
--- a/src/hotspot/share/opto/library_call.cpp	Wed Sep 12 11:13:09 2018 +0200
+++ b/src/hotspot/share/opto/library_call.cpp	Tue Sep 18 20:49:44 2018 +0200
@@ -1758,11 +1758,9 @@
     return false;
   }
   if (is_store) {
-    (void) store_to_memory(control(), adr, ch, T_CHAR, TypeAryPtr::BYTES, MemNode::unordered,
-                           false, false, true /* mismatched */);
+    access_store_at(value, adr, TypeAryPtr::BYTES, ch, TypeInt::CHAR, T_CHAR, IN_HEAP | MO_UNORDERED | C2_MISMATCHED);
   } else {
-    ch = make_load(control(), adr, TypeInt::CHAR, T_CHAR, TypeAryPtr::BYTES, MemNode::unordered,
-                   LoadNode::DependsOnlyOnTest, false, false, true /* mismatched */);
+    ch = access_load_at(value, adr, TypeAryPtr::BYTES, TypeInt::CHAR, T_CHAR, IN_HEAP | MO_UNORDERED | C2_MISMATCHED | C2_CONTROL_DEPENDENT_LOAD);
     set_result(ch);
   }
   return true;
@@ -2512,7 +2510,7 @@
       val = ConvL2X(val);
       val = gvn().transform(new CastX2PNode(val));
     }
-    access_store_at(control(), heap_base_oop, adr, adr_type, val, value_type, type, decorators);
+    access_store_at(heap_base_oop, adr, adr_type, val, value_type, type, decorators);
   }
 
   return true;
@@ -2731,24 +2729,24 @@
   Node* result = NULL;
   switch (kind) {
     case LS_cmp_exchange: {
-      result = access_atomic_cmpxchg_val_at(control(), base, adr, adr_type, alias_idx,
+      result = access_atomic_cmpxchg_val_at(base, adr, adr_type, alias_idx,
                                             oldval, newval, value_type, type, decorators);
       break;
     }
     case LS_cmp_swap_weak:
       decorators |= C2_WEAK_CMPXCHG;
     case LS_cmp_swap: {
-      result = access_atomic_cmpxchg_bool_at(control(), base, adr, adr_type, alias_idx,
+      result = access_atomic_cmpxchg_bool_at(base, adr, adr_type, alias_idx,
                                              oldval, newval, value_type, type, decorators);
       break;
     }
     case LS_get_set: {
-      result = access_atomic_xchg_at(control(), base, adr, adr_type, alias_idx,
+      result = access_atomic_xchg_at(base, adr, adr_type, alias_idx,
                                      newval, value_type, type, decorators);
       break;
     }
     case LS_get_add: {
-      result = access_atomic_add_at(control(), base, adr, adr_type, alias_idx,
+      result = access_atomic_add_at(base, adr, adr_type, alias_idx,
                                     newval, value_type, type, decorators);
       break;
     }
@@ -4232,7 +4230,7 @@
   // TODO: generate fields copies for small objects instead.
   Node* size = _gvn.transform(obj_size);
 
-  access_clone(control(), obj, alloc_obj, size, is_array);
+  access_clone(obj, alloc_obj, size, is_array);
 
   // Do not let reads from the cloned object float above the arraycopy.
   if (alloc != NULL) {
--- a/src/hotspot/share/opto/parse2.cpp	Wed Sep 12 11:13:09 2018 +0200
+++ b/src/hotspot/share/opto/parse2.cpp	Tue Sep 18 20:49:44 2018 +0200
@@ -104,7 +104,7 @@
 
   const TypeAryPtr* adr_type = TypeAryPtr::get_array_body_type(bt);
 
-  access_store_at(control(), array, adr, adr_type, val, elemtype, bt, MO_UNORDERED | IN_HEAP | IS_ARRAY);
+  access_store_at(array, adr, adr_type, val, elemtype, bt, MO_UNORDERED | IN_HEAP | IS_ARRAY);
 }
 
 
--- a/src/hotspot/share/opto/parse3.cpp	Wed Sep 12 11:13:09 2018 +0200
+++ b/src/hotspot/share/opto/parse3.cpp	Tue Sep 18 20:49:44 2018 +0200
@@ -264,7 +264,7 @@
       field_type = Type::BOTTOM;
     }
   }
-  access_store_at(control(), obj, adr, adr_type, val, field_type, bt, decorators);
+  access_store_at(obj, adr, adr_type, val, field_type, bt, decorators);
 
   if (is_field) {
     // Remember we wrote a volatile field.
@@ -351,7 +351,7 @@
       Node*    elem   = expand_multianewarray(array_klass_1, &lengths[1], ndimensions-1, nargs);
       intptr_t offset = header + ((intptr_t)i << LogBytesPerHeapOop);
       Node*    eaddr  = basic_plus_adr(array, offset);
-      access_store_at(control(), array, eaddr, adr_type, elem, elemtype, T_OBJECT, IN_HEAP | IS_ARRAY);
+      access_store_at(array, eaddr, adr_type, elem, elemtype, T_OBJECT, IN_HEAP | IS_ARRAY);
     }
   }
   return array;
--- a/src/hotspot/share/opto/parseHelper.cpp	Wed Sep 12 11:13:09 2018 +0200
+++ b/src/hotspot/share/opto/parseHelper.cpp	Tue Sep 18 20:49:44 2018 +0200
@@ -437,9 +437,9 @@
   Node* adr_node = method_data_addressing(md, data, DataLayout::flags_offset());
 
   const TypePtr* adr_type = _gvn.type(adr_node)->is_ptr();
-  Node* flags = make_load(NULL, adr_node, TypeInt::BYTE, T_BYTE, adr_type, MemNode::unordered);
+  Node* flags = make_load(NULL, adr_node, TypeInt::INT, T_INT, adr_type, MemNode::unordered);
   Node* incr = _gvn.transform(new OrINode(flags, _gvn.intcon(flag_constant)));
-  store_to_memory(NULL, adr_node, incr, T_BYTE, adr_type, MemNode::unordered);
+  store_to_memory(NULL, adr_node, incr, T_INT, adr_type, MemNode::unordered);
 }
 
 //----------------------------profile_taken_branch-----------------------------
--- a/src/hotspot/share/opto/stringopts.cpp	Wed Sep 12 11:13:09 2018 +0200
+++ b/src/hotspot/share/opto/stringopts.cpp	Tue Sep 18 20:49:44 2018 +0200
@@ -1547,7 +1547,7 @@
 
 // Compress copy contents of the byte/char String str into dst_array starting at index start.
 Node* PhaseStringOpts::copy_string(GraphKit& kit, Node* str, Node* dst_array, Node* dst_coder, Node* start) {
-  Node* src_array = kit.load_String_value(kit.control(), str);
+  Node* src_array = kit.load_String_value(str, true);
   src_array = kit.access_resolve(src_array, ACCESS_READ);
 
   IdealKit ideal(&kit, true, true);
@@ -1580,7 +1580,7 @@
     // Non-constant source string
     if (CompactStrings) {
       // Emit runtime check for coder
-      Node* coder = kit.load_String_coder(__ ctrl(), str);
+      Node* coder = kit.load_String_coder(str, true);
       __ if_then(coder, BoolTest::eq, __ ConI(java_lang_String::CODER_LATIN1)); {
         // Source is Latin1
         copy_latin1_string(kit, ideal, src_array, count, dst_array, dst_coder, start);
@@ -1796,8 +1796,8 @@
           // replace the argument with the null checked version
           arg = null_string;
           sc->set_argument(argi, arg);
-          count = kit.load_String_length(kit.control(), arg);
-          arg_coder = kit.load_String_coder(kit.control(), arg);
+          count = kit.load_String_length(arg, true);
+          arg_coder = kit.load_String_coder(arg, true);
         } else if (!type->higher_equal(TypeInstPtr::NOTNULL)) {
           // s = s != null ? s : "null";
           // length = length + (s.count - s.offset);
@@ -1820,14 +1820,14 @@
           // replace the argument with the null checked version
           arg = phi;
           sc->set_argument(argi, arg);
-          count = kit.load_String_length(kit.control(), arg);
-          arg_coder = kit.load_String_coder(kit.control(), arg);
+          count = kit.load_String_length(arg, true);
+          arg_coder = kit.load_String_coder(arg, true);
         } else {
           // A corresponding nullcheck will be connected during IGVN MemNode::Ideal_common_DU_postCCP
           // kit.control might be a different test, that can be hoisted above the actual nullcheck
           // in case, that the control input is not null, Ideal_common_DU_postCCP will not look for a nullcheck.
-          count = kit.load_String_length(NULL, arg);
-          arg_coder = kit.load_String_coder(NULL, arg);
+          count = kit.load_String_length(arg, false);
+          arg_coder = kit.load_String_coder(arg, false);
         }
         if (arg->is_Con()) {
           // Constant string. Get constant coder and length.
@@ -1918,7 +1918,7 @@
          sc->mode(0) == StringConcat::StringNullCheckMode)) {
       // Handle the case when there is only a single String argument.
       // In this case, we can just pull the value from the String itself.
-      dst_array = kit.load_String_value(kit.control(), sc->argument(0));
+      dst_array = kit.load_String_value(sc->argument(0), true);
     } else {
       // Allocate destination byte array according to coder
       dst_array = allocate_byte_array(kit, NULL, __ LShiftI(length, coder));
@@ -1959,8 +1959,8 @@
     }
 
     // Initialize the string
-    kit.store_String_value(kit.control(), result, dst_array);
-    kit.store_String_coder(kit.control(), result, coder);
+    kit.store_String_value(result, dst_array);
+    kit.store_String_coder(result, coder);
 
     // The value field is final. Emit a barrier here to ensure that the effect
     // of the initialization is committed to memory before any code publishes