changeset 9960:b1b69cb27756

Merge (1b33ef6544b4 Fixed a warning)
author Lukas Stadler <lukas.stadler@jku.at>
date Mon, 10 Jun 2013 10:52:40 +0200
parents 38b1517cf458 (current diff) 1b33ef6544b4 (diff)
children e2ffbaa682b8
files
diffstat 2 files changed, 7 insertions(+), 94 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java	Mon Jun 10 10:52:02 2013 +0200
+++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java	Mon Jun 10 10:52:40 2013 +0200
@@ -38,6 +38,7 @@
 import com.oracle.graal.lir.asm.*;
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.nodes.cfg.*;
+import com.oracle.graal.nodes.extended.*;
 import com.oracle.graal.nodes.spi.*;
 import com.oracle.graal.nodes.util.*;
 import com.oracle.graal.options.*;
@@ -172,7 +173,12 @@
 
         LowTierContext lowTierContext = new LowTierContext(runtime, assumptions, replacements, target);
         Suites.DEFAULT.getLowTier().apply(graph, lowTierContext);
-        InliningPhase.storeStatisticsAfterLowTier(graph);
+
+        // we do not want to store statistics about OSR compilations because it may prevent inlining
+        boolean isOSRCompilation = graph.start() instanceof OSRStartNode;
+        if (!isOSRCompilation) {
+            InliningPhase.storeStatisticsAfterLowTier(graph);
+        }
 
         final SchedulePhase schedule = new SchedulePhase();
         schedule.apply(graph);
--- a/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/graph/ComputeProbabilityClosure.java	Mon Jun 10 10:52:02 2013 +0200
+++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/graph/ComputeProbabilityClosure.java	Mon Jun 10 10:52:40 2013 +0200
@@ -26,7 +26,6 @@
 
 import com.oracle.graal.graph.*;
 import com.oracle.graal.nodes.*;
-import com.oracle.graal.nodes.extended.*;
 import com.oracle.graal.nodes.util.*;
 
 /**
@@ -64,104 +63,12 @@
     }
 
     public NodesToDoubles apply() {
-        adjustControlSplitProbabilities();
         new PropagateProbability(graph.start()).apply();
         computeLoopFactors();
         new PropagateLoopFrequency(graph.start()).apply();
-        assert verifyProbabilities();
         return nodeProbabilities;
     }
 
-    /**
-     * Assume that paths with a DeoptimizeNode at their end are taken infrequently.
-     */
-    private void adjustControlSplitProbabilities() {
-        HashSet<ControlSplitNode> result = new HashSet<>();
-        NodeBitMap visitedNodes = new NodeBitMap(graph);
-        for (DeoptimizeNode n : graph.getNodes(DeoptimizeNode.class)) {
-            if (n.action().doesInvalidateCompilation()) {
-                findParentControlSplitNodes(result, n, visitedNodes);
-            }
-        }
-
-        for (ControlSplitNode n : result) {
-            if (!allSuxVisited(n, visitedNodes)) {
-                modifyProbabilities(n, visitedNodes);
-            }
-        }
-    }
-
-    private static void findParentControlSplitNodes(HashSet<ControlSplitNode> result, DeoptimizeNode n, NodeBitMap visitedNodes) {
-        ArrayDeque<FixedNode> nodes = new ArrayDeque<>();
-        nodes.push(n);
-
-        Node currentNode;
-        do {
-            currentNode = nodes.pop();
-            visitedNodes.mark(currentNode);
-
-            for (Node pred : currentNode.cfgPredecessors()) {
-                FixedNode fixedPred = (FixedNode) pred;
-                if (allSuxVisited(fixedPred, visitedNodes) || fixedPred instanceof InvokeWithExceptionNode) {
-                    nodes.push(fixedPred);
-                } else {
-                    assert fixedPred instanceof ControlSplitNode : "only control splits can have more than one sux";
-                    result.add((ControlSplitNode) fixedPred);
-                }
-            }
-        } while (!nodes.isEmpty());
-    }
-
-    private static void modifyProbabilities(ControlSplitNode node, NodeBitMap visitedNodes) {
-        if (node instanceof IfNode) {
-            IfNode ifNode = (IfNode) node;
-            assert visitedNodes.isMarked(ifNode.falseSuccessor()) ^ visitedNodes.isMarked(ifNode.trueSuccessor());
-
-            if (visitedNodes.isMarked(ifNode.trueSuccessor())) {
-                if (ifNode.probability(ifNode.trueSuccessor()) > 0) {
-                    ifNode.setTrueSuccessorProbability(0);
-                }
-            } else {
-                if (ifNode.probability(ifNode.trueSuccessor()) < 1) {
-                    ifNode.setTrueSuccessorProbability(1);
-                }
-            }
-        } else if (node instanceof SwitchNode) {
-            SwitchNode switchNode = (SwitchNode) node;
-            for (Node sux : switchNode.successors()) {
-                if (visitedNodes.isMarked(sux)) {
-                    switchNode.setProbability(sux, 0);
-                }
-            }
-        } else {
-            GraalInternalError.shouldNotReachHere();
-        }
-    }
-
-    private static boolean allSuxVisited(FixedNode fixedPred, NodeBitMap visitedNodes) {
-        for (Node sux : fixedPred.successors()) {
-            if (!visitedNodes.contains(sux)) {
-                return false;
-            }
-        }
-        return true;
-    }
-
-    private boolean verifyProbabilities() {
-        if (doesNotAlwaysDeopt(graph)) {
-            for (DeoptimizeNode n : graph.getNodes(DeoptimizeNode.class)) {
-                if (n.action().doesInvalidateCompilation() && nodeProbabilities.get(n) > 0.01) {
-                    throw new AssertionError(String.format("%s with reason %s and probability %f in graph %s", n, n.reason(), nodeProbabilities.get(n), graph));
-                }
-            }
-        }
-        return true;
-    }
-
-    private static boolean doesNotAlwaysDeopt(StructuredGraph graph) {
-        return graph.getNodes(ReturnNode.class).iterator().hasNext();
-    }
-
     private void computeLoopFactors() {
         for (LoopInfo info : loopInfos) {
             double frequency = info.loopFrequency(nodeProbabilities);