src/hotspot/share/opto/phaseX.cpp
changeset 51485 0c7040d1d1ca
parent 51333 f6641fcf7b7e
child 51706 be8fe2a352be
--- a/src/hotspot/share/opto/phaseX.cpp	Wed Aug 22 13:01:26 2018 +0200
+++ b/src/hotspot/share/opto/phaseX.cpp	Wed Aug 22 13:06:33 2018 +0200
@@ -1639,14 +1639,24 @@
     }
     // Loading the java mirror from a Klass requires two loads and the type
     // of the mirror load depends on the type of 'n'. See LoadNode::Value().
-    // If the code pattern requires a barrier for
-    //   mirror = ((OopHandle)mirror)->resolve();
-    // this won't match.
+    //   LoadBarrier?(LoadP(LoadP(AddP(foo:Klass, #java_mirror))))
+    BarrierSetC2* bs = BarrierSet::barrier_set()->barrier_set_c2();
+    bool has_load_barriers = bs->has_load_barriers();
+
     if (use_op == Op_LoadP && use->bottom_type()->isa_rawptr()) {
       for (DUIterator_Fast i2max, i2 = use->fast_outs(i2max); i2 < i2max; i2++) {
         Node* u = use->fast_out(i2);
         const Type* ut = u->bottom_type();
         if (u->Opcode() == Op_LoadP && ut->isa_instptr()) {
+          if (has_load_barriers) {
+            // Search for load barriers behind the load
+            for (DUIterator_Fast i3max, i3 = u->fast_outs(i3max); i3 < i3max; i3++) {
+              Node* b = u->fast_out(i3);
+              if (bs->is_gc_barrier_node(b)) {
+                _worklist.push(b);
+              }
+            }
+          }
           _worklist.push(u);
         }
       }
@@ -1788,14 +1798,23 @@
         }
         // Loading the java mirror from a Klass requires two loads and the type
         // of the mirror load depends on the type of 'n'. See LoadNode::Value().
-        // If the code pattern requires a barrier for
-        //   mirror = ((OopHandle)mirror)->resolve();
-        // this won't match.
+        BarrierSetC2* bs = BarrierSet::barrier_set()->barrier_set_c2();
+        bool has_load_barriers = bs->has_load_barriers();
+
         if (m_op == Op_LoadP && m->bottom_type()->isa_rawptr()) {
           for (DUIterator_Fast i2max, i2 = m->fast_outs(i2max); i2 < i2max; i2++) {
             Node* u = m->fast_out(i2);
             const Type* ut = u->bottom_type();
             if (u->Opcode() == Op_LoadP && ut->isa_instptr() && ut != type(u)) {
+              if (has_load_barriers) {
+                // Search for load barriers behind the load
+                for (DUIterator_Fast i3max, i3 = u->fast_outs(i3max); i3 < i3max; i3++) {
+                  Node* b = u->fast_out(i3);
+                  if (bs->is_gc_barrier_node(b)) {
+                    _worklist.push(b);
+                  }
+                }
+              }
               worklist.push(u);
             }
           }