src/hotspot/share/opto/matcher.cpp
changeset 50525 767cdb97f103
parent 48309 1a0499fd252e
child 51333 f6641fcf7b7e
--- a/src/hotspot/share/opto/matcher.cpp	Tue Jun 12 07:52:30 2018 -0700
+++ b/src/hotspot/share/opto/matcher.cpp	Tue Jun 12 17:40:28 2018 +0200
@@ -41,6 +41,9 @@
 #include "runtime/os.hpp"
 #include "runtime/sharedRuntime.hpp"
 #include "utilities/align.hpp"
+#if INCLUDE_ZGC
+#include "gc/z/zBarrierSetRuntime.hpp"
+#endif // INCLUDE_ZGC
 
 OptoReg::Name OptoReg::c_frame_pointer;
 
@@ -2062,6 +2065,7 @@
       mstack.set_state(Post_Visit);
       set_visited(n);   // Flag as visited now
       bool mem_op = false;
+      int mem_addr_idx = MemNode::Address;
 
       switch( nop ) {  // Handle some opcodes special
       case Op_Phi:             // Treat Phis as shared roots
@@ -2150,6 +2154,17 @@
       case Op_SafePoint:
         mem_op = true;
         break;
+#if INCLUDE_ZGC
+      case Op_CallLeaf:
+        if (UseZGC) {
+          if (n->as_Call()->entry_point() == ZBarrierSetRuntime::load_barrier_on_oop_field_preloaded_addr() ||
+              n->as_Call()->entry_point() == ZBarrierSetRuntime::load_barrier_on_weak_oop_field_preloaded_addr()) {
+            mem_op = true;
+            mem_addr_idx = TypeFunc::Parms+1;
+          }
+          break;
+        }
+#endif
       default:
         if( n->is_Store() ) {
           // Do match stores, despite no ideal reg
@@ -2199,7 +2214,7 @@
 #endif
 
         // Clone addressing expressions as they are "free" in memory access instructions
-        if (mem_op && i == MemNode::Address && mop == Op_AddP &&
+        if (mem_op && i == mem_addr_idx && mop == Op_AddP &&
             // When there are other uses besides address expressions
             // put it on stack and mark as shared.
             !is_visited(m)) {