hotspot/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.nodes/src/org/graalvm/compiler/nodes/graphbuilderconf/GraphBuilderContext.java
changeset 46344 694c102fd8ed
parent 43972 1ade39b8381b
child 46371 0337d0617e7b
--- a/hotspot/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.nodes/src/org/graalvm/compiler/nodes/graphbuilderconf/GraphBuilderContext.java	Mon Dec 12 16:16:27 2016 +0300
+++ b/hotspot/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.nodes/src/org/graalvm/compiler/nodes/graphbuilderconf/GraphBuilderContext.java	Wed Mar 22 13:42:45 2017 -0700
@@ -22,16 +22,19 @@
  */
 package org.graalvm.compiler.nodes.graphbuilderconf;
 
-import static org.graalvm.compiler.core.common.type.StampFactory.objectNonNull;
 import static jdk.vm.ci.meta.DeoptimizationAction.InvalidateReprofile;
 import static jdk.vm.ci.meta.DeoptimizationReason.NullCheckException;
+import static org.graalvm.compiler.core.common.type.StampFactory.objectNonNull;
 
 import org.graalvm.compiler.bytecode.Bytecode;
 import org.graalvm.compiler.bytecode.BytecodeProvider;
+import org.graalvm.compiler.core.common.type.AbstractPointerStamp;
 import org.graalvm.compiler.core.common.type.ObjectStamp;
 import org.graalvm.compiler.core.common.type.Stamp;
 import org.graalvm.compiler.core.common.type.StampFactory;
 import org.graalvm.compiler.core.common.type.StampPair;
+import org.graalvm.compiler.nodes.CallTargetNode;
+import org.graalvm.compiler.nodes.ConstantNode;
 import org.graalvm.compiler.nodes.CallTargetNode.InvokeKind;
 import org.graalvm.compiler.nodes.FixedGuardNode;
 import org.graalvm.compiler.nodes.LogicNode;
@@ -43,6 +46,8 @@
 
 import jdk.vm.ci.code.BailoutException;
 import jdk.vm.ci.meta.Assumptions;
+import jdk.vm.ci.meta.DeoptimizationAction;
+import jdk.vm.ci.meta.DeoptimizationReason;
 import jdk.vm.ci.meta.JavaKind;
 import jdk.vm.ci.meta.JavaType;
 import jdk.vm.ci.meta.ResolvedJavaMethod;
@@ -87,6 +92,18 @@
         return equivalentValue;
     }
 
+    default ValueNode addNonNullCast(ValueNode value) {
+        AbstractPointerStamp valueStamp = (AbstractPointerStamp) value.stamp();
+        if (valueStamp.nonNull()) {
+            return value;
+        } else {
+            LogicNode isNull = add(IsNullNode.create(value));
+            FixedGuardNode fixedGuard = add(new FixedGuardNode(isNull, DeoptimizationReason.NullCheckException, DeoptimizationAction.None, true));
+            Stamp newStamp = valueStamp.improveWith(StampFactory.objectNonNull());
+            return add(new PiNode(value, newStamp, fixedGuard));
+        }
+    }
+
     /**
      * Adds a node with a non-void kind to the graph, pushes it to the stack. If the returned node
      * is a {@link StateSplit} with a null {@linkplain StateSplit#stateAfter() frame state}, the
@@ -121,6 +138,8 @@
      */
     void handleReplacedInvoke(InvokeKind invokeKind, ResolvedJavaMethod targetMethod, ValueNode[] args, boolean forceInlineEverything);
 
+    void handleReplacedInvoke(CallTargetNode callTarget, JavaKind resultType);
+
     /**
      * Intrinsifies an invocation of a given method by inlining the bytecodes of a given
      * substitution method.
@@ -217,16 +236,20 @@
 
     BailoutException bailout(String string);
 
+    default ValueNode nullCheckedValue(ValueNode value) {
+        return nullCheckedValue(value, InvalidateReprofile);
+    }
+
     /**
      * Gets a version of a given value that has a {@linkplain StampTool#isPointerNonNull(ValueNode)
      * non-null} stamp.
      */
-    default ValueNode nullCheckedValue(ValueNode value) {
+    default ValueNode nullCheckedValue(ValueNode value, DeoptimizationAction action) {
         if (!StampTool.isPointerNonNull(value.stamp())) {
             LogicNode condition = getGraph().unique(IsNullNode.create(value));
             ObjectStamp receiverStamp = (ObjectStamp) value.stamp();
             Stamp stamp = receiverStamp.join(objectNonNull());
-            FixedGuardNode fixedGuard = append(new FixedGuardNode(condition, NullCheckException, InvalidateReprofile, true));
+            FixedGuardNode fixedGuard = append(new FixedGuardNode(condition, NullCheckException, action, true));
             PiNode nonNullReceiver = getGraph().unique(new PiNode(value, stamp, fixedGuard));
             // TODO: Propogating the non-null into the frame state would
             // remove subsequent null-checks on the same value. However,
@@ -237,4 +260,9 @@
         }
         return value;
     }
+
+    @SuppressWarnings("unused")
+    default void notifyReplacedCall(ResolvedJavaMethod targetMethod, ConstantNode node) {
+
+    }
 }