changeset 15680:1efd95f6e1ba

[inlining] readability improvements for (by now extracted) loop-body
author Miguel Garcia <miguel.m.garcia@oracle.com>
date Thu, 15 May 2014 15:01:25 +0200
parents 33d9741ccfe3
children 0d0ce3c657df
files graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/InliningPhase.java
diffstat 1 files changed, 30 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- 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<FixedNode> 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);
             }
         }
     }