# HG changeset patch # User Thomas Wuerthinger # Date 1427652898 -7200 # Node ID 745e0fbcbdafaa0aeaddd5187df7eb6387370376 # Parent 171b650a46ee75ef54accbdf4e1359c565f4ca13 Remove iterative inlining phase. diff -r 171b650a46ee -r 745e0fbcbdaf 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 Sun Mar 29 18:59:59 2015 +0200 +++ b/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/GraalOptions.java Sun Mar 29 20:14:58 2015 +0200 @@ -51,9 +51,6 @@ @Option(help = "Maximum level of recursive inlining.", type = OptionType.Expert) public static final OptionValue MaximumRecursiveInlining = new OptionValue<>(5); - @Option(help = "", type = OptionType.Debug) - public static final OptionValue IterativeInlining = new OptionValue<>(false); - @Option(help = "Graphs with less than this number of nodes are trivial and therefore always inlined.", type = OptionType.Expert) public static final OptionValue TrivialInliningSize = new OptionValue<>(10); diff -r 171b650a46ee -r 745e0fbcbdaf graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/IterativeInliningTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/IterativeInliningTest.java Sun Mar 29 18:59:59 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,89 +0,0 @@ -/* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.oracle.graal.compiler.test.ea; - -import java.util.concurrent.*; - -import org.junit.*; - -import com.oracle.graal.compiler.test.*; -import com.oracle.graal.compiler.test.ea.EATestBase.TestClassInt; -import com.oracle.graal.nodes.*; -import com.oracle.graal.nodes.StructuredGraph.AllowAssumptions; -import com.oracle.graal.nodes.java.*; -import com.oracle.graal.phases.*; -import com.oracle.graal.phases.common.*; -import com.oracle.graal.phases.tiers.*; -import com.oracle.graal.virtual.phases.ea.*; - -public class IterativeInliningTest extends GraalCompilerTest { - - private StructuredGraph graph; - - public static class TestObject { - - public Callable callable; - - public TestObject(Callable callable) { - this.callable = callable; - } - } - - public static class TestInt extends TestClassInt implements Callable { - - public TestInt(int x, int y) { - super(x, y); - } - - @Override - public Integer call() throws Exception { - return new Integer(x); - } - } - - @SuppressWarnings("all") - public static int testSimpleSnippet(int b) throws Exception { - TestObject a = new TestObject(null); - a.callable = new TestInt(b, 9); - return a.callable.call(); - } - - @Test - public void testSimple() { - ValueNode result = getReturn("testSimpleSnippet").result(); - assertTrue(graph.getNodes().filter(LoadFieldNode.class).isEmpty()); - assertDeepEquals(graph.getParameter(0), result); - } - - final ReturnNode getReturn(String snippet) { - processMethod(snippet); - assertDeepEquals(1, graph.getNodes(ReturnNode.TYPE).count()); - return graph.getNodes(ReturnNode.TYPE).first(); - } - - private void processMethod(final String snippet) { - graph = parseEager(snippet, AllowAssumptions.YES); - HighTierContext context = new HighTierContext(getProviders(), null, getDefaultGraphBuilderSuite(), OptimisticOptimizations.ALL); - new IterativeInliningPhase(new CanonicalizerPhase()).apply(graph, context); - } -} diff -r 171b650a46ee -r 745e0fbcbdaf graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/HighTier.java --- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/HighTier.java Sun Mar 29 18:59:59 2015 +0200 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/HighTier.java Sun Mar 29 20:14:58 2015 +0200 @@ -56,16 +56,12 @@ } if (Inline.getValue()) { - if (IterativeInlining.getValue()) { - appendPhase(new IterativeInliningPhase(canonicalizer)); - } else { - appendPhase(new InliningPhase(canonicalizer)); - appendPhase(new DeadCodeEliminationPhase(Optional)); + appendPhase(new InliningPhase(canonicalizer)); + appendPhase(new DeadCodeEliminationPhase(Optional)); - if (ConditionalElimination.getValue() && OptCanonicalizer.getValue()) { - appendPhase(canonicalizer); - appendPhase(new IterativeConditionalEliminationPhase(canonicalizer, false)); - } + if (ConditionalElimination.getValue() && OptCanonicalizer.getValue()) { + appendPhase(canonicalizer); + appendPhase(new IterativeConditionalEliminationPhase(canonicalizer, false)); } } diff -r 171b650a46ee -r 745e0fbcbdaf graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/IterativeInliningPhase.java --- a/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/IterativeInliningPhase.java Sun Mar 29 18:59:59 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,87 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.oracle.graal.virtual.phases.ea; - -import static com.oracle.graal.compiler.common.GraalOptions.*; -import static com.oracle.graal.debug.Debug.*; -import static com.oracle.graal.phases.common.DeadCodeEliminationPhase.Optionality.*; - -import java.util.*; - -import com.oracle.graal.debug.*; -import com.oracle.graal.debug.Debug.Scope; -import com.oracle.graal.nodes.*; -import com.oracle.graal.phases.common.*; -import com.oracle.graal.phases.common.inlining.*; -import com.oracle.graal.phases.tiers.*; - -public class IterativeInliningPhase extends AbstractInliningPhase { - - private final CanonicalizerPhase canonicalizer; - - public IterativeInliningPhase(CanonicalizerPhase canonicalizer) { - this.canonicalizer = canonicalizer; - } - - public static final void trace(String format, Object... obj) { - if (TraceEscapeAnalysis.getValue() && Debug.isLogEnabled()) { - Debug.logv(format, obj); - } - } - - @Override - protected void run(final StructuredGraph graph, final HighTierContext context) { - runIterations(graph, true, context); - runIterations(graph, false, context); - } - - private void runIterations(final StructuredGraph graph, final boolean simple, final HighTierContext context) { - for (int iteration = 0; iteration < EscapeAnalysisIterations.getValue(); iteration++) { - try (Scope s = Debug.scope(isEnabled() ? "iteration " + iteration : null)) { - boolean progress = false; - PartialEscapePhase ea = new PartialEscapePhase(false, canonicalizer); - boolean eaResult = ea.runAnalysis(graph, context); - progress |= eaResult; - - Map hints = PEAInliningHints.getValue() ? PartialEscapePhase.getHints(graph) : null; - - InliningPhase inlining = new InliningPhase(hints, new CanonicalizerPhase()); - inlining.setMaxMethodsPerInlining(simple ? 1 : Integer.MAX_VALUE); - inlining.apply(graph, context); - progress |= inlining.getInliningCount() > 0; - - new DeadCodeEliminationPhase(Optional).apply(graph); - - if (ConditionalElimination.getValue() && OptCanonicalizer.getValue()) { - canonicalizer.apply(graph, context); - new IterativeConditionalEliminationPhase(canonicalizer, false).apply(graph, context); - } - if (!progress) { - break; - } - } catch (Throwable e) { - throw Debug.handle(e); - } - } - } -} diff -r 171b650a46ee -r 745e0fbcbdaf graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/PartialEscapePhase.java --- a/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/PartialEscapePhase.java Sun Mar 29 18:59:59 2015 +0200 +++ b/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/PartialEscapePhase.java Sun Mar 29 20:14:58 2015 +0200 @@ -26,19 +26,14 @@ import static com.oracle.graal.virtual.phases.ea.PartialEscapePhase.Options.*; import java.util.*; -import java.util.function.*; -import com.oracle.graal.compiler.common.*; import com.oracle.graal.graph.*; import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.cfg.*; -import com.oracle.graal.nodes.java.*; import com.oracle.graal.nodes.spi.*; -import com.oracle.graal.nodes.virtual.*; import com.oracle.graal.options.*; import com.oracle.graal.phases.*; import com.oracle.graal.phases.common.*; -import com.oracle.graal.phases.graph.*; import com.oracle.graal.phases.schedule.*; import com.oracle.graal.phases.tiers.*; @@ -94,44 +89,4 @@ return new PartialEscapeClosure.Final(schedule, context.getMetaAccess(), context.getConstantReflection()); } } - - public static Map getHints(StructuredGraph graph) { - ToDoubleFunction probabilities = new FixedNodeProbabilityCache(); - Map hints = null; - for (CommitAllocationNode commit : graph.getNodes().filter(CommitAllocationNode.class)) { - double sum = 0; - double invokeSum = 0; - for (Node commitUsage : commit.usages()) { - for (Node usage : commitUsage.usages()) { - if (usage instanceof FixedNode) { - sum += probabilities.applyAsDouble((FixedNode) usage); - } else { - if (usage instanceof MethodCallTargetNode) { - invokeSum += probabilities.applyAsDouble(((MethodCallTargetNode) usage).invoke().asNode()); - } - for (Node secondLevelUage : usage.usages()) { - if (secondLevelUage instanceof FixedNode) { - sum += probabilities.applyAsDouble(((FixedNode) secondLevelUage)); - } - } - } - } - } - // TODO(lstadler) get rid of this magic number - if (sum > 100 && invokeSum > 0) { - for (Node commitUsage : commit.usages()) { - for (Node usage : commitUsage.usages()) { - if (usage instanceof MethodCallTargetNode) { - if (hints == null) { - hints = CollectionsFactory.newMap(); - } - Invoke invoke = ((MethodCallTargetNode) usage).invoke(); - hints.put(invoke, sum / invokeSum); - } - } - } - } - } - return hints; - } }