# HG changeset patch # User Lukas Stadler # Date 1370854360 -7200 # Node ID b1b69cb27756ac262cc78b4463e7ae79a9ad6156 # Parent 38b1517cf458472320a3dfdbf4887ecbaf17fafe# Parent 1b33ef6544b436973a2471f6c4f5f541b14fcb09 Merge (1b33ef6544b4 Fixed a warning) diff -r 38b1517cf458 -r b1b69cb27756 graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java --- 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); diff -r 38b1517cf458 -r b1b69cb27756 graal/com.oracle.graal.phases/src/com/oracle/graal/phases/graph/ComputeProbabilityClosure.java --- 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 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 result, DeoptimizeNode n, NodeBitMap visitedNodes) { - ArrayDeque 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);