# HG changeset patch # User Thomas Wuerthinger # Date 1306514653 -7200 # Node ID 095162a84dcce761f6b581ff58418f27a1c35636 # Parent 6a1e5d7e1f4e76af604851ac15abf5f744267d32 Introduced scheduling code. diff -r 6a1e5d7e1f4e -r 095162a84dcc graal/GraalCompiler/src/com/oracle/max/graal/schedule/Schedule.java --- a/graal/GraalCompiler/src/com/oracle/max/graal/schedule/Schedule.java Fri May 27 18:14:36 2011 +0200 +++ b/graal/GraalCompiler/src/com/oracle/max/graal/schedule/Schedule.java Fri May 27 18:44:13 2011 +0200 @@ -27,6 +27,7 @@ import com.oracle.graal.graph.*; import com.sun.c1x.debug.*; import com.sun.c1x.ir.*; +import com.sun.c1x.value.*; import com.sun.cri.ci.*; @@ -153,16 +154,29 @@ predBlock.addSuccessor(block); } } - if (n instanceof LoopBegin) { - LoopBegin loopBegin = (LoopBegin) n; - nodeToBlock.get(loopBegin.loopEnd()).addSuccessor(block); -// System.out.println("added LoopEnd to LoopBegin successor 2: " + loopBegin.loopEnd() + "->" + loopBegin); + + if (n instanceof Merge) { + for (Node usage : n.usages()) { + if (usage instanceof Phi) { + nodeToBlock.set(usage, block); + } + } } } computeDominators(); assignLatestPossibleBlockToNodes(); sortNodesWithinBlocks(); + + // Add successors of loop end nodes. Makes the graph cyclic. + for (Node n : blockBeginNodes) { + Block block = nodeToBlock.get(n); + if (n instanceof LoopBegin) { + LoopBegin loopBegin = (LoopBegin) n; + nodeToBlock.get(loopBegin.loopEnd()).addSuccessor(block); + } + } + //print(); } @@ -213,6 +227,7 @@ private void sortNodesWithinBlocks(Block b, NodeBitMap map) { List instructions = b.getInstructions(); + Collections.shuffle(instructions); List sortedInstructions = new ArrayList(); @@ -220,16 +235,18 @@ addToSorting(b, i, sortedInstructions, map); } b.setInstructions(sortedInstructions); +// TTY.println("Block " + b); +// for (Node n : sortedInstructions) { +// TTY.println("Node: " + n); +// } } private void addToSorting(Block b, Node i, List sortedInstructions, NodeBitMap map) { - if (i == null || map.isMarked(i) || nodeToBlock.get(i) != b) { + if (i == null || map.isMarked(i) || nodeToBlock.get(i) != b || i instanceof Phi || i instanceof FrameState || i instanceof Local) { return; } - TTY.println("addToSorting " + i.id() + " " + i.getClass().getName()); for (Node input : i.inputs()) { - if (input != null) TTY.println("visiting input " + input.id() + " " + input.getClass().getName()); addToSorting(b, input, sortedInstructions, map); } @@ -253,7 +270,6 @@ while (!workList.isEmpty()) { Block b = workList.remove(); - TTY.println("processing" + b); List predecessors = b.getPredecessors(); if (predecessors.size() == 1) { b.setDominator(predecessors.get(0)); diff -r 6a1e5d7e1f4e -r 095162a84dcc graal/GraalCompiler/src/com/sun/c1x/graph/CriticalEdgeFinder.java --- a/graal/GraalCompiler/src/com/sun/c1x/graph/CriticalEdgeFinder.java Fri May 27 18:14:36 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/graph/CriticalEdgeFinder.java Fri May 27 18:44:13 2011 +0200 @@ -108,6 +108,7 @@ Node sourceInstruction = source.getInstructions().get(source.getInstructions().size() - 1); Node targetInstruction = target.getInstructions().get(0); int sourceInstructionPredIndex = targetInstruction.predecessors().indexOf(sourceInstruction); + assert sourceInstructionPredIndex != -1 : "must find source instruction " + sourceInstruction + " in predecessor array of target instruction " + targetInstruction; int replacedIndex = targetInstruction.predecessorsIndex().get(sourceInstructionPredIndex); assert replacedIndex != -1 && sourceInstruction.successors().get(replacedIndex) != null; e.successors().setAndClear(1, sourceInstruction, replacedIndex); diff -r 6a1e5d7e1f4e -r 095162a84dcc graal/GraalCompiler/src/com/sun/c1x/ir/Merge.java --- a/graal/GraalCompiler/src/com/sun/c1x/ir/Merge.java Fri May 27 18:14:36 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/ir/Merge.java Fri May 27 18:44:13 2011 +0200 @@ -250,9 +250,4 @@ } return sb.toString(); } - - @Override - public String shortName() { - return "Merge #" + id(); - } } diff -r 6a1e5d7e1f4e -r 095162a84dcc graal/GraalCompiler/src/com/sun/c1x/ir/Value.java --- a/graal/GraalCompiler/src/com/sun/c1x/ir/Value.java Fri May 27 18:14:36 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/ir/Value.java Fri May 27 18:44:13 2011 +0200 @@ -245,9 +245,6 @@ } builder.append(getClass().getSimpleName()); builder.append(" [").append(flagsToString()).append("]"); - for (Node input : inputs()) { - TTY.println("input: " + input); - } return builder.toString(); }