OpenJDK / graal / graal-jvmci-8
changeset 8187:317b004fc741
Use sum of unscheduled blocks at merge point.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Sun, 10 Mar 2013 23:04:12 +0100 |
parents | bf1c9ae73775 |
children | a848153df742 |
files | graal/com.oracle.graal.alloc/src/com/oracle/graal/alloc/ComputeBlockOrder.java |
diffstat | 1 files changed, 18 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.graal.alloc/src/com/oracle/graal/alloc/ComputeBlockOrder.java Sun Mar 10 23:02:48 2013 +0100 +++ b/graal/com.oracle.graal.alloc/src/com/oracle/graal/alloc/ComputeBlockOrder.java Sun Mar 10 23:04:12 2013 +0100 @@ -55,6 +55,13 @@ private static final int INITIAL_WORKLIST_CAPACITY = 10; /** + * Divisor used for degrading the probability of the current path versus unscheduled paths at a + * merge node when calculating the linear scan order. A high value means that predecessors of + * merge nodes are more likely to be scheduled before the merge node. + */ + private static final int PENALTY_VERSUS_UNSCHEDULED = 10; + + /** * Computes the block order used for the linear scan register allocator. * * @return sorted list of blocks @@ -122,13 +129,20 @@ enqueueSuccessors(block, worklist, visitedBlocks); if (mostLikelySuccessor != null) { if (!mostLikelySuccessor.isLoopHeader() && mostLikelySuccessor.getPredecessorCount() > 1) { - // We are at a merge. Check that predecessors are scheduled. + // We are at a merge. Check probabilities of predecessors that are not yet + // scheduled. + double unscheduledSum = 0.0; for (Block pred : mostLikelySuccessor.getPredecessors()) { - if (pred.getLinearScanNumber() == -1) { - visitedBlocks.clear(mostLikelySuccessor.getId()); - return; + if (!visitedBlocks.get(pred.getId())) { + unscheduledSum += pred.getBeginNode().probability(); } } + + if (unscheduledSum > block.getProbability() / PENALTY_VERSUS_UNSCHEDULED) { + // Add this merge only after at least one additional predecessor gets scheduled. + visitedBlocks.clear(mostLikelySuccessor.getId()); + return; + } } addPathToLinearScanOrder(mostLikelySuccessor, order, worklist, visitedBlocks); }