src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.replacements/src/org/graalvm/compiler/replacements/ConstantBindingParameterPlugin.java
changeset 55509 d58442b8abc1
parent 52910 583fd71c47d6
child 58299 6df94ce3ab2f
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.replacements/src/org/graalvm/compiler/replacements/ConstantBindingParameterPlugin.java	Thu Jun 27 03:10:52 2019 +0200
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.replacements/src/org/graalvm/compiler/replacements/ConstantBindingParameterPlugin.java	Thu Jun 27 03:33:44 2019 +0200
@@ -55,26 +55,28 @@
 
     @Override
     public FloatingNode interceptParameter(GraphBuilderTool b, int index, StampPair stamp) {
-        Object arg = constantArgs[index];
-        if (arg != null) {
-            ConstantNode constantNode;
-            if (arg instanceof ConstantNode) {
-                ConstantNode otherCon = (ConstantNode) arg;
-                if (otherCon.graph() != b.getGraph()) {
-                    /*
-                     * This is a node from another graph, so copy over extra state into a new
-                     * ConstantNode.
-                     */
-                    constantNode = ConstantNode.forConstant(stamp.getTrustedStamp(), otherCon.getValue(), otherCon.getStableDimension(), otherCon.isDefaultStable(), metaAccess);
+        if (index < constantArgs.length) {
+            Object arg = constantArgs[index];
+            if (arg != null) {
+                ConstantNode constantNode;
+                if (arg instanceof ConstantNode) {
+                    ConstantNode otherCon = (ConstantNode) arg;
+                    if (otherCon.graph() != b.getGraph()) {
+                        /*
+                         * This is a node from another graph, so copy over extra state into a new
+                         * ConstantNode.
+                         */
+                        constantNode = ConstantNode.forConstant(stamp.getTrustedStamp(), otherCon.getValue(), otherCon.getStableDimension(), otherCon.isDefaultStable(), metaAccess);
+                    } else {
+                        constantNode = otherCon;
+                    }
+                } else if (arg instanceof Constant) {
+                    constantNode = ConstantNode.forConstant(stamp.getTrustedStamp(), (Constant) arg, metaAccess);
                 } else {
-                    constantNode = otherCon;
+                    constantNode = ConstantNode.forConstant(snippetReflection.forBoxed(stamp.getTrustedStamp().getStackKind(), arg), metaAccess);
                 }
-            } else if (arg instanceof Constant) {
-                constantNode = ConstantNode.forConstant(stamp.getTrustedStamp(), (Constant) arg, metaAccess);
-            } else {
-                constantNode = ConstantNode.forConstant(snippetReflection.forBoxed(stamp.getTrustedStamp().getStackKind(), arg), metaAccess);
+                return constantNode;
             }
-            return constantNode;
         }
         return null;
     }