# HG changeset patch # User Thomas Wuerthinger # Date 1421846940 -3600 # Node ID 13e43d2a413e20d53794a6590d5557d9bc38345f # Parent 4af661af76fd0f02fe464d7c5d72a8ac00d5f7d7 Initialize frame state builder created for parse time inlining correctly. diff -r 4af661af76fd -r 13e43d2a413e graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/GraalOptions.java --- a/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/GraalOptions.java Wed Jan 21 13:10:52 2015 +0100 +++ b/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/GraalOptions.java Wed Jan 21 14:29:00 2015 +0100 @@ -63,6 +63,9 @@ @Option(help = "Inlines trivial methods during parsing of the bytecodes.", type = OptionType.Expert) public static final StableOptionValue InlineDuringParsing = new StableOptionValue<>(false); + @Option(help = "Maximum depth when inlining during parsing.", type = OptionType.Debug) + public static final StableOptionValue InlineDuringParsingMaxDepth = new StableOptionValue<>(10); + @Option(help = "Inlining is explored up to this number of nodes in the graph for each call site.", type = OptionType.Expert) public static final OptionValue MaximumInliningSize = new OptionValue<>(300); diff -r 4af661af76fd -r 13e43d2a413e graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotSuitesProvider.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotSuitesProvider.java Wed Jan 21 13:10:52 2015 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotSuitesProvider.java Wed Jan 21 14:29:00 2015 +0100 @@ -84,6 +84,7 @@ protected PhaseSuite createGraphBuilderSuite() { PhaseSuite suite = new PhaseSuite<>(); GraphBuilderConfiguration config = GraphBuilderConfiguration.getDefault(); + config.setInlineTrivial(true); suite.appendPhase(new GraphBuilderPhase(config)); return suite; } diff -r 4af661af76fd -r 13e43d2a413e graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderConfiguration.java --- a/graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderConfiguration.java Wed Jan 21 13:10:52 2015 +0100 +++ b/graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderConfiguration.java Wed Jan 21 14:29:00 2015 +0100 @@ -36,6 +36,7 @@ private final ResolvedJavaType[] skippedExceptionTypes; private final DebugInfoMode debugInfoMode; private final boolean doLivenessAnalysis; + private boolean inlineTrivial; public static enum DebugInfoMode { SafePointsOnly, @@ -130,4 +131,12 @@ public boolean unresolvedIsError() { return eagerResolving; } + + public boolean shouldInlineTrivial() { + return inlineTrivial; + } + + public void setInlineTrivial(boolean inlineTrivial) { + this.inlineTrivial = inlineTrivial; + } } diff -r 4af661af76fd -r 13e43d2a413e 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 Wed Jan 21 13:10:52 2015 +0100 +++ b/graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java Wed Jan 21 14:29:00 2015 +0100 @@ -717,8 +717,14 @@ } if (GraalOptions.InlineDuringParsing.getValue() && invokeKind.isDirect() && targetMethod.canBeInlined() && targetMethod.hasBytecodes()) { - if (targetMethod.getCode().length <= GraalOptions.TrivialInliningSize.getValue()) { - System.out.println("could inline trivial: " + targetMethod); + if (targetMethod.getCode().length <= GraalOptions.TrivialInliningSize.getValue() && currentDepth < GraalOptions.InlineDuringParsingMaxDepth.getValue() && + graphBuilderConfig.shouldInlineTrivial()) { + BytecodeParser parser = new BytecodeParser(metaAccess, targetMethod, graphBuilderConfig, optimisticOpts, StructuredGraph.INVOCATION_ENTRY_BCI); + HIRFrameStateBuilder startFrameState = new HIRFrameStateBuilder(targetMethod, currentGraph); + System.out.println(args + ", " + args.length + ", " + targetMethod); + startFrameState.initializeFromArgumentsArray(args); + System.out.println("try inline trivial: " + targetMethod); + parser.build(currentDepth + 1, this.lastInstr, startFrameState); } } diff -r 4af661af76fd -r 13e43d2a413e graal/com.oracle.graal.java/src/com/oracle/graal/java/HIRFrameStateBuilder.java --- a/graal/com.oracle.graal.java/src/com/oracle/graal/java/HIRFrameStateBuilder.java Wed Jan 21 13:10:52 2015 +0100 +++ b/graal/com.oracle.graal.java/src/com/oracle/graal/java/HIRFrameStateBuilder.java Wed Jan 21 14:29:00 2015 +0100 @@ -46,7 +46,7 @@ /** * Creates a new frame state builder for the given method and the given target graph. - * + * * @param method the method whose frame is simulated * @param graph the target graph of Graal nodes created by the builder */ @@ -59,6 +59,25 @@ this.graph = graph; } + public final void initializeFromArgumentsArray(ValueNode[] arguments) { + + int javaIndex = 0; + int index = 0; + if (!method.isStatic()) { + // set the receiver + storeLocal(javaIndex, arguments[index]); + javaIndex = 1; + index = 1; + } + Signature sig = method.getSignature(); + int max = sig.getParameterCount(false); + for (int i = 0; i < max; i++) { + storeLocal(javaIndex, arguments[index]); + javaIndex += arguments[index].getKind().getSlotCount(); + index++; + } + } + public final void initializeForMethodStart(boolean eagerResolve) { int javaIndex = 0;