# HG changeset patch # User Miguel Garcia # Date 1400158885 -7200 # Node ID 1efd95f6e1ba0ce56b54812efbc127414aaa491c # Parent 33d9741ccfe3f362584a2c3edae97ca8212447a6 [inlining] readability improvements for (by now extracted) loop-body diff -r 33d9741ccfe3 -r 1efd95f6e1ba graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/InliningPhase.java --- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/InliningPhase.java Thu May 15 14:53:50 2014 +0200 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/InliningPhase.java Thu May 15 15:01:25 2014 +0200 @@ -161,34 +161,43 @@ } private void moveForward(HighTierContext context, InliningData data, ToDoubleFunction probabilities) { + final MethodInvocation currentInvocation = data.currentInvocation(); - if (!currentInvocation.isRoot() && - !inliningPolicy.isWorthInlining(probabilities, context.getReplacements(), currentInvocation.callee(), data.inliningDepth(), currentInvocation.probability(), - currentInvocation.relevance(), false)) { + + final boolean backtrack = (!currentInvocation.isRoot() && !inliningPolicy.isWorthInlining(probabilities, context.getReplacements(), currentInvocation.callee(), data.inliningDepth(), + currentInvocation.probability(), currentInvocation.relevance(), false)); + if (backtrack) { int remainingGraphs = currentInvocation.totalGraphs() - currentInvocation.processedGraphs(); assert remainingGraphs > 0; data.popGraphs(remainingGraphs); data.popInvocation(); - } else if (data.currentGraph().hasRemainingInvokes() && inliningPolicy.continueInlining(data.currentGraph().graph())) { + return; + } + + final boolean delve = data.currentGraph().hasRemainingInvokes() && inliningPolicy.continueInlining(data.currentGraph().graph()); + if (delve) { data.processNextInvoke(context); - } else { - data.popGraph(); - if (!currentInvocation.isRoot()) { - assert currentInvocation.callee().invoke().asNode().isAlive(); - currentInvocation.incrementProcessedGraphs(); - if (currentInvocation.processedGraphs() == currentInvocation.totalGraphs()) { - data.popInvocation(); - final MethodInvocation parentInvoke = data.currentInvocation(); - try (Scope s = Debug.scope("Inlining", data.inliningContext())) { - boolean wasInlined = InliningData.tryToInline(probabilities, data.currentGraph(), currentInvocation, parentInvoke, data.inliningDepth() + 1, context, inliningPolicy, - canonicalizer); - if (wasInlined) { - inliningCount++; - } - } catch (Throwable e) { - throw Debug.handle(e); - } + return; + } + + data.popGraph(); + if (currentInvocation.isRoot()) { + return; + } + + // try to inline + assert currentInvocation.callee().invoke().asNode().isAlive(); + currentInvocation.incrementProcessedGraphs(); + if (currentInvocation.processedGraphs() == currentInvocation.totalGraphs()) { + data.popInvocation(); + final MethodInvocation parentInvoke = data.currentInvocation(); + try (Scope s = Debug.scope("Inlining", data.inliningContext())) { + boolean wasInlined = InliningData.tryToInline(probabilities, data.currentGraph(), currentInvocation, parentInvoke, data.inliningDepth() + 1, context, inliningPolicy, canonicalizer); + if (wasInlined) { + inliningCount++; } + } catch (Throwable e) { + throw Debug.handle(e); } } }