8188785: CCP sets invalid type for java mirror load
authorthartmann
Wed, 25 Oct 2017 08:37:41 +0200
changeset 47693 1630ba56759d
parent 47692 0d2d80c0d425
child 47694 214c5a0bdea3
8188785: CCP sets invalid type for java mirror load Summary: Added special case for java mirror load to propagate correct type information. Reviewed-by: kvn
src/hotspot/share/opto/phaseX.cpp
--- a/src/hotspot/share/opto/phaseX.cpp	Mon Oct 23 21:49:48 2017 -0700
+++ b/src/hotspot/share/opto/phaseX.cpp	Wed Oct 25 08:37:41 2017 +0200
@@ -1625,6 +1625,17 @@
       Node* imem = use->as_Initialize()->proj_out(TypeFunc::Memory);
       if (imem != NULL)  add_users_to_worklist0(imem);
     }
+    // Loading the java mirror from a klass oop requires two loads and the type
+    // of the mirror load depends on the type of 'n'. See LoadNode::Value().
+    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()) {
+          _worklist.push(u);
+        }
+      }
+    }
   }
 }
 
@@ -1760,6 +1771,17 @@
             worklist.push(phi);
           }
         }
+        // Loading the java mirror from a klass oop requires two loads and the type
+        // of the mirror load depends on the type of 'n'. See LoadNode::Value().
+        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)) {
+              worklist.push(u);
+            }
+          }
+        }
       }
     }
   }