# HG changeset patch # User Christian Haeubl # Date 1329179301 28800 # Node ID d8d865b9de30281bad79d369f91b580ee4081d2d # Parent c148bec9398a16036a7960e82038907a006ef959 added assertion to ensure that methods are only inlined if they cannot be intrinsified diff -r c148bec9398a -r d8d865b9de30 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/IntrinsificationPhase.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/IntrinsificationPhase.java Mon Feb 13 15:39:20 2012 -0800 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/IntrinsificationPhase.java Mon Feb 13 16:28:21 2012 -0800 @@ -47,22 +47,31 @@ } } - public static void tryIntrinsify(Invoke invoke, GraalRuntime runtime) { + public static boolean canIntrinsify(Invoke invoke, RiResolvedMethod target, GraalRuntime runtime) { + return getIntrinsicGraph(invoke, target, runtime) != null; + } + + private static void tryIntrinsify(Invoke invoke, GraalRuntime runtime) { RiResolvedMethod target = invoke.callTarget().targetMethod(); if (target != null) { tryIntrinsify(invoke, target, runtime); } } - public static void tryIntrinsify(Invoke invoke, RiResolvedMethod target, GraalRuntime runtime) { + private static void tryIntrinsify(Invoke invoke, RiResolvedMethod target, GraalRuntime runtime) { + StructuredGraph intrinsicGraph = getIntrinsicGraph(invoke, target, runtime); + if (intrinsicGraph != null) { + Debug.log(" > Intrinsify %s", target); + InliningUtil.inline(invoke, intrinsicGraph, true); + } + } + + private static StructuredGraph getIntrinsicGraph(Invoke invoke, RiResolvedMethod target, GraalRuntime runtime) { StructuredGraph intrinsicGraph = (StructuredGraph) target.compilerStorage().get(Graph.class); if (intrinsicGraph == null) { // TODO (ph) remove once all intrinsics are available via RiMethod intrinsicGraph = runtime.intrinsicGraph(invoke.stateAfter().method(), invoke.bci(), target, invoke.callTarget().arguments()); } - if (intrinsicGraph != null) { - Debug.log(" > Intrinsify %s", target); - InliningUtil.inline(invoke, intrinsicGraph, true); - } + return intrinsicGraph; } } diff -r c148bec9398a -r d8d865b9de30 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/util/InliningUtil.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/util/InliningUtil.java Mon Feb 13 15:39:20 2012 -0800 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/util/InliningUtil.java Mon Feb 13 16:28:21 2012 -0800 @@ -29,6 +29,7 @@ import com.oracle.max.cri.ci.*; import com.oracle.max.cri.ri.*; import com.oracle.max.graal.compiler.*; +import com.oracle.max.graal.compiler.phases.*; import com.oracle.max.graal.cri.*; import com.oracle.max.graal.debug.*; import com.oracle.max.graal.graph.*; @@ -126,6 +127,7 @@ @Override public void inline(StructuredGraph compilerGraph, GraalRuntime runtime, final InliningCallback callback) { StructuredGraph graph = getGraph(concrete, callback); + assert !IntrinsificationPhase.canIntrinsify(invoke, concrete, runtime); InliningUtil.inline(invoke, graph, true); } @@ -179,6 +181,7 @@ Debug.log("inlining 1 method using 1 type check"); StructuredGraph calleeGraph = getGraph(concrete, callback); + assert !IntrinsificationPhase.canIntrinsify(invoke, concrete, runtime); InliningUtil.inline(invoke, calleeGraph, false); } @@ -234,9 +237,9 @@ // receiver null check must be the first node InliningUtil.receiverNullCheck(invoke); if (numberOfMethods > 1 || shouldFallbackToInvoke()) { - inlineMultipleMethods(graph, callback, numberOfMethods, hasReturnValue); + inlineMultipleMethods(graph, runtime, callback, numberOfMethods, hasReturnValue); } else { - inlineSingleMethod(graph, callback); + inlineSingleMethod(graph, runtime, callback); } Debug.log("inlining %d methods with %d type checks and falling back to %s if violated", numberOfMethods, types.length, shouldFallbackToInvoke() ? "invocation" : "deoptimization"); @@ -246,7 +249,7 @@ return notRecordedTypeProbability > 0; } - private void inlineMultipleMethods(StructuredGraph graph, InliningCallback callback, int numberOfMethods, boolean hasReturnValue) { + private void inlineMultipleMethods(StructuredGraph graph, GraalRuntime runtime, InliningCallback callback, int numberOfMethods, boolean hasReturnValue) { FixedNode continuation = invoke.next(); // setup merge and phi nodes for results and exceptions @@ -315,12 +318,14 @@ for (int i = 0; i < calleeEntryNodes.length; i++) { BeginNode node = calleeEntryNodes[i]; Invoke invokeForInlining = (Invoke) node.next(); - StructuredGraph calleeGraph = getGraph(concretes.get(i), callback); + RiResolvedMethod concrete = concretes.get(i); + StructuredGraph calleeGraph = getGraph(concrete, callback); + assert !IntrinsificationPhase.canIntrinsify(invokeForInlining, concrete, runtime); InliningUtil.inline(invokeForInlining, calleeGraph, false); } } - private void inlineSingleMethod(StructuredGraph graph, InliningCallback callback) { + private void inlineSingleMethod(StructuredGraph graph, GraalRuntime runtime, InliningCallback callback) { assert concretes.size() == 1 && types.length > 1 && !shouldFallbackToInvoke() && notRecordedTypeProbability == 0; MergeNode calleeEntryNode = graph.add(new MergeNode()); @@ -335,7 +340,9 @@ pred.setNext(dispatchOnType); calleeEntryNode.setNext(invoke.node()); - StructuredGraph calleeGraph = getGraph(concretes.get(0), callback); + RiResolvedMethod concrete = concretes.get(0); + StructuredGraph calleeGraph = getGraph(concrete, callback); + assert !IntrinsificationPhase.canIntrinsify(invoke, concrete, runtime); InliningUtil.inline(invoke, calleeGraph, false); } diff -r c148bec9398a -r d8d865b9de30 graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/java/IsTypeNode.java --- a/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/java/IsTypeNode.java Mon Feb 13 15:39:20 2012 -0800 +++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/java/IsTypeNode.java Mon Feb 13 16:28:21 2012 -0800 @@ -26,7 +26,6 @@ import com.oracle.max.cri.ci.*; import com.oracle.max.cri.ri.*; -import com.oracle.max.graal.debug.*; import com.oracle.max.graal.nodes.*; import com.oracle.max.graal.nodes.extended.*; import com.oracle.max.graal.nodes.spi.*;