# HG changeset patch # User Doug Simon # Date 1426285673 -3600 # Node ID 93b74f0db076f5d1144349f16ca6d916a6adc2e9 # Parent 5e27aa02bb92e379da5ba61830993754947de793 don't treat Truffle method inlining substitutions as graph builder replacements diff -r 5e27aa02bb92 -r 93b74f0db076 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotInlineInvokePlugin.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotInlineInvokePlugin.java Fri Mar 13 23:15:18 2015 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotInlineInvokePlugin.java Fri Mar 13 23:27:53 2015 +0100 @@ -49,19 +49,19 @@ ResolvedJavaMethod subst = replacements.getMethodSubstitutionMethod(method); if (subst != null) { // Forced inlining of intrinsics - return new InlineInfo(subst, true); + return new InlineInfo(subst, true, true); } if (b.parsingReplacement()) { assert nodeIntrinsification.getIntrinsic(method) == null && method.getAnnotation(Word.Operation.class) == null && method.getAnnotation(HotSpotOperation.class) == null && !nodeIntrinsification.isFoldable(method) : format("%s should have been handled by %s", method.format("%H.%n(%p)"), DefaultGenericInvocationPlugin.class.getName()); // Force inlining when parsing replacements - return new InlineInfo(method, true); + return new InlineInfo(method, true, true); } else { assert nodeIntrinsification.getIntrinsic(method) == null : String.format("@%s method %s must only be called from within a replacement%n%s", NodeIntrinsic.class.getSimpleName(), method.format("%h.%n"), b); if (InlineDuringParsing.getValue() && method.hasBytecodes() && method.getCode().length <= TrivialInliningSize.getValue() && b.getDepth() < InlineDuringParsingMaxDepth.getValue()) { - return new InlineInfo(method, false); + return new InlineInfo(method, false, false); } } return null; diff -r 5e27aa02bb92 -r 93b74f0db076 graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderContext.java --- a/graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderContext.java Fri Mar 13 23:15:18 2015 +0100 +++ b/graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderContext.java Fri Mar 13 23:27:53 2015 +0100 @@ -36,7 +36,9 @@ /** * Information about a snippet or method substitution currently being processed by the graph - * builder. + * builder. When in the scope of a replacement, the graph builder does not check the value kinds + * flowing through the JVM state since replacements can employ non-Java kinds to represent + * values such as raw machine words and pointers. */ public interface Replacement { diff -r 5e27aa02bb92 -r 93b74f0db076 graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java --- a/graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java Fri Mar 13 23:15:18 2015 +0100 +++ b/graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java Fri Mar 13 23:27:53 2015 +0100 @@ -1219,8 +1219,9 @@ return false; } } else { - if (context == null && !inlinedMethod.equals(targetMethod)) { - if (inlineInfo.adoptBeforeCallFrameState) { + if (context == null && inlineInfo.isReplacement) { + assert !inlinedMethod.equals(targetMethod); + if (inlineInfo.isIntrinsic) { context = new IntrinsicContext(targetMethod, inlinedMethod, args, bci); } else { context = new ReplacementContext(targetMethod, inlinedMethod); diff -r 5e27aa02bb92 -r 93b74f0db076 graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPlugin.java --- a/graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPlugin.java Fri Mar 13 23:15:18 2015 +0100 +++ b/graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPlugin.java Fri Mar 13 23:27:53 2015 +0100 @@ -75,22 +75,29 @@ public static class InlineInfo { /** - * The method to be inlined. If this is not equal to the {@code method} argument passed - * to {@link InlineInvokePlugin#getClass()}, the graph builder context interprets it as - * a {@linkplain GraphBuilderContext.Replacement replacement}. + * The method to be inlined. */ public final ResolvedJavaMethod methodToInline; /** + * Specifies if {@link #methodToInline} is to be considered a + * {@linkplain GraphBuilderContext.Replacement replacement} for the {@code method} + * passed to {@link InlineInvokePlugin#getInlineInfo}. + */ + public final boolean isReplacement; + + /** * Specifies if {@link #methodToInline} is an intrinsic for the original method. If so, * any {@link StateSplit} node created in the (recursive) inlining scope will be given a * frame state that restarts the interpreter just before the intrinsified invocation. */ - public final boolean adoptBeforeCallFrameState; + public final boolean isIntrinsic; - public InlineInfo(ResolvedJavaMethod methodToInline, boolean adoptBeforeCallFrameState) { + public InlineInfo(ResolvedJavaMethod methodToInline, boolean isReplacement, boolean isIntrinsic) { this.methodToInline = methodToInline; - this.adoptBeforeCallFrameState = adoptBeforeCallFrameState; + this.isIntrinsic = isIntrinsic; + this.isReplacement = isReplacement; + assert !isIntrinsic || isReplacement : "cannot be an intrinsic without also being a replacement"; } } @@ -211,7 +218,7 @@ if (ALLOW_INVOCATION_PLUGIN_TO_DO_INLINING) { ResolvedJavaMethod subst = plugin.getSubstitute(); if (subst != null) { - return ((BytecodeParser) b).inline(null, targetMethod, new InlineInfo(subst, false), args); + return ((BytecodeParser) b).inline(null, targetMethod, new InlineInfo(subst, true, false), args); } } if (args.length == 0) { diff -r 5e27aa02bb92 -r 93b74f0db076 graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/PartialEvaluator.java --- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/PartialEvaluator.java Fri Mar 13 23:15:18 2015 +0100 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/PartialEvaluator.java Fri Mar 13 23:27:53 2015 +0100 @@ -204,6 +204,7 @@ if (replacements != null && (replacements.getMethodSubstitutionMethod(original) != null || replacements.getMacroSubstitution(original) != null)) { return null; } + assert !builder.parsingReplacement(); if (original.equals(callSiteProxyMethod)) { ValueNode arg1 = arguments[0]; if (!arg1.isConstant()) { @@ -221,10 +222,10 @@ if (decision != null && decision.isInline()) { inlining.push(decision); builder.getAssumptions().record(new AssumptionValidAssumption((OptimizedAssumption) decision.getTarget().getNodeRewritingAssumption())); - return new InlineInfo(callInlinedMethod, false); + return new InlineInfo(callInlinedMethod, false, false); } } - return new InlineInfo(original, false); + return new InlineInfo(original, false, false); } public void postInline(ResolvedJavaMethod inlinedTargetMethod) {