# HG changeset patch # User Thomas Wuerthinger # Date 1306501894 -7200 # Node ID 2af109bec0c00d6d08cce2c59cc6e963cf2802b4 # Parent e3a0630a1dab7ba6a27da18565b86d26b537f518 Make block contains a list of nodes instead a list of instructions. diff -r e3a0630a1dab -r 2af109bec0c0 graal/GraalCompiler/src/com/oracle/max/graal/schedule/Block.java --- a/graal/GraalCompiler/src/com/oracle/max/graal/schedule/Block.java Fri May 27 14:58:55 2011 +0200 +++ b/graal/GraalCompiler/src/com/oracle/max/graal/schedule/Block.java Fri May 27 15:11:34 2011 +0200 @@ -24,6 +24,7 @@ import java.util.*; +import com.oracle.graal.graph.*; import com.sun.c1x.ir.*; @@ -32,7 +33,7 @@ private int blockID; private final List successors = new ArrayList(); private final List predecessors = new ArrayList(); - private List instructions = new ArrayList(); + private List instructions = new ArrayList(); private boolean exceptionEntry; private Block dominator; private final List dominators = new ArrayList(); @@ -52,7 +53,7 @@ return Collections.unmodifiableList(dominators); } - public List getInstructions() { + public List getInstructions() { return instructions; } @@ -115,7 +116,7 @@ return dominator; } - public void setInstructions(List instructions) { + public void setInstructions(List instructions) { this.instructions = instructions; } } diff -r e3a0630a1dab -r 2af109bec0c0 graal/GraalCompiler/src/com/oracle/max/graal/schedule/Schedule.java --- a/graal/GraalCompiler/src/com/oracle/max/graal/schedule/Schedule.java Fri May 27 14:58:55 2011 +0200 +++ b/graal/GraalCompiler/src/com/oracle/max/graal/schedule/Schedule.java Fri May 27 15:11:34 2011 +0200 @@ -28,7 +28,6 @@ import com.sun.c1x.debug.*; import com.sun.c1x.ir.*; import com.sun.cri.ci.*; -import com.sun.jmx.remote.util.*; public class Schedule { @@ -68,9 +67,7 @@ private Block assignBlock(Node n, Block b) { assert nodeToBlock.get(n) == null; nodeToBlock.set(n, b); - if (n != n.graph().start()) { - b.getInstructions().add((Instruction) n); - } + b.getInstructions().add(n); return b; } @@ -157,18 +154,25 @@ } private void sortNodesWithinBlocks() { + NodeBitMap map = graph.createNodeBitMap(); for (Block b : blocks) { - sortNodesWithinBlocks(b); + sortNodesWithinBlocks(b, map); } } - private void sortNodesWithinBlocks(Block b) { - List instructions = b.getInstructions(); + private void sortNodesWithinBlocks(Block b, NodeBitMap map) { + List instructions = b.getInstructions(); Collections.shuffle(instructions); - List sortedInstructions = new ArrayList(); + List sortedInstructions = new ArrayList(); sortedInstructions.addAll(instructions); b.setInstructions(sortedInstructions); + + for (Node i : instructions) { + if (!map.isMarked(i)) { + + } + } } private void computeDominators() { diff -r e3a0630a1dab -r 2af109bec0c0 graal/GraalCompiler/src/com/sun/c1x/debug/BlockPrinter.java --- a/graal/GraalCompiler/src/com/sun/c1x/debug/BlockPrinter.java Fri May 27 14:58:55 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/debug/BlockPrinter.java Fri May 27 15:11:34 2011 +0200 @@ -22,6 +22,7 @@ */ package com.sun.c1x.debug; +import com.oracle.graal.graph.*; import com.oracle.max.graal.schedule.*; import com.sun.c1x.graph.*; import com.sun.c1x.ir.*; @@ -44,7 +45,7 @@ public void apply(Block block) { if (cfgOnly) { if (block.getInstructions().size() > 0) { - ip.printInstruction(block.getInstructions().get(0)); + ip.printInstruction((Instruction) block.getInstructions().get(0)); } else { ip.out().println("Empty block"); } @@ -60,8 +61,10 @@ ip.printInstructionListingHeader(); - for (Instruction i : block.getInstructions()) { - ip.printInstructionListing(i); + for (Node i : block.getInstructions()) { + if (i instanceof Instruction) { + ip.printInstructionListing((Instruction) i); + } } out.println(); diff -r e3a0630a1dab -r 2af109bec0c0 graal/GraalCompiler/src/com/sun/c1x/debug/CFGPrinter.java --- a/graal/GraalCompiler/src/com/sun/c1x/debug/CFGPrinter.java Fri May 27 14:58:55 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/debug/CFGPrinter.java Fri May 27 15:11:34 2011 +0200 @@ -25,6 +25,7 @@ import java.io.*; import java.util.*; +import com.oracle.graal.graph.*; import com.oracle.max.graal.schedule.*; import com.sun.c1x.*; import com.sun.c1x.alloc.*; @@ -407,8 +408,10 @@ begin("IR"); out.println("HIR"); out.disableIndentation(); - for (Instruction i : block.getInstructions()) { - printInstructionHIR(i); + for (Node i : block.getInstructions()) { + if (i instanceof Instruction) { + printInstructionHIR((Instruction) i); + } } out.enableIndentation(); end("IR"); diff -r e3a0630a1dab -r 2af109bec0c0 graal/GraalCompiler/src/com/sun/c1x/gen/LIRGenerator.java --- a/graal/GraalCompiler/src/com/sun/c1x/gen/LIRGenerator.java Fri May 27 14:58:55 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/gen/LIRGenerator.java Fri May 27 15:11:34 2011 +0200 @@ -224,8 +224,11 @@ TTY.println("BEGIN Generating LIR for block B" + block.blockID()); } - for (Instruction instr : block.getInstructions()) { - FrameState stateAfter = instr.stateAfter(); + for (Node instr : block.getInstructions()) { + FrameState stateAfter = null; + if (instr instanceof Instruction) { + stateAfter = ((Instruction) instr).stateAfter(); + } FrameState stateBefore = null; if (instr instanceof StateSplit && ((StateSplit) instr).stateBefore() != null) { stateBefore = ((StateSplit) instr).stateBefore(); @@ -239,9 +242,9 @@ } } } - if (!(instr instanceof Merge)) { + if (!(instr instanceof Merge) && instr != instr.graph().start()) { walkState(instr, stateAfter); - doRoot(instr); + doRoot((Value) instr); } if (stateAfter != null) { lastState = stateAfter; @@ -1215,12 +1218,11 @@ return res.toArray(new SwitchRange[res.size()]); } - void doRoot(Instruction instr) { + void doRoot(Value instr) { if (C1XOptions.TraceLIRGeneratorLevel >= 2) { - TTY.println("Emitting LIR for instruction " + instr.toString()); + TTY.println("Emitting LIR for instruction " + instr); } currentInstruction = instr; - assert !instr.hasSubst() : "shouldn't have missed substitution"; if (C1XOptions.TraceLIRVisit) { TTY.println("Visiting " + instr); @@ -1289,7 +1291,7 @@ private List getPhis(LIRBlock block) { if (block.getInstructions().size() > 0) { - Instruction i = block.getInstructions().get(0); + Node i = block.getInstructions().get(0); if (i instanceof Merge) { List result = new ArrayList(); for (Node n : i.usages()) { @@ -1431,7 +1433,7 @@ } } - protected void walkState(Instruction x, FrameState state) { + protected void walkState(Node x, FrameState state) { if (state == null) { return; } @@ -1453,7 +1455,6 @@ private void walkStateValue(Value value) { if (value != null) { - assert !value.hasSubst() : "missed substitution on " + value.toString(); if (value instanceof Phi && !value.isIllegal()) { // phi's are special operandForPhi((Phi) value); diff -r e3a0630a1dab -r 2af109bec0c0 graal/GraalCompiler/src/com/sun/c1x/graph/CriticalEdgeFinder.java --- a/graal/GraalCompiler/src/com/sun/c1x/graph/CriticalEdgeFinder.java Fri May 27 14:58:55 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/graph/CriticalEdgeFinder.java Fri May 27 15:11:34 2011 +0200 @@ -105,8 +105,8 @@ // This goto is not a safepoint. Anchor e = new Anchor(null, graph); - Instruction sourceInstruction = source.getInstructions().get(source.getInstructions().size() - 1); - Instruction targetInstruction = target.getInstructions().get(0); + Node sourceInstruction = source.getInstructions().get(source.getInstructions().size() - 1); + Node targetInstruction = target.getInstructions().get(0); int sourceInstructionPredIndex = targetInstruction.predecessors().indexOf(sourceInstruction); int replacedIndex = targetInstruction.predecessorsIndex().get(sourceInstructionPredIndex); assert replacedIndex != -1 && sourceInstruction.successors().get(replacedIndex) != null; diff -r e3a0630a1dab -r 2af109bec0c0 graal/GraalCompiler/src/com/sun/c1x/graph/IR.java --- a/graal/GraalCompiler/src/com/sun/c1x/graph/IR.java Fri May 27 14:58:55 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/graph/IR.java Fri May 27 15:11:34 2011 +0200 @@ -24,6 +24,7 @@ import java.util.*; +import com.oracle.graal.graph.*; import com.oracle.max.graal.schedule.*; import com.sun.c1x.*; import com.sun.c1x.debug.*; @@ -62,7 +63,7 @@ this.compilation = compilation; } - public Map valueToBlock; + public Map valueToBlock; /** * Builds the graph, optimizes it, and computes the linear scan block order. @@ -116,9 +117,9 @@ orderedBlocks = lirBlocks; - valueToBlock = new HashMap(); + valueToBlock = new HashMap(); for (LIRBlock b : orderedBlocks) { - for (Instruction i : b.getInstructions()) { + for (Node i : b.getInstructions()) { valueToBlock.put(i, b); } } diff -r e3a0630a1dab -r 2af109bec0c0 graal/GraalCompiler/src/com/sun/c1x/ir/Merge.java --- a/graal/GraalCompiler/src/com/sun/c1x/ir/Merge.java Fri May 27 14:58:55 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/ir/Merge.java Fri May 27 15:11:34 2011 +0200 @@ -262,9 +262,6 @@ sb.append("] "); } } - if (value != null && value.hasSubst()) { - sb.append("alias ").append(Util.valueString(value.subst())); - } return sb.toString(); } diff -r e3a0630a1dab -r 2af109bec0c0 graal/GraalCompiler/src/com/sun/c1x/ir/Value.java --- a/graal/GraalCompiler/src/com/sun/c1x/ir/Value.java Fri May 27 14:58:55 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/ir/Value.java Fri May 27 15:11:34 2011 +0200 @@ -56,11 +56,6 @@ protected CiValue operand = CiValue.IllegalValue; - /** - * Used by {@link InstructionSubstituter}. - */ - public Value subst; - public abstract Merge block(); /** @@ -89,30 +84,6 @@ throw new CloneNotSupportedException(); } - ///////////////// - - /** - * Gets the instruction that should be substituted for this one. Note that this - * method is recursive; if the substituted instruction has a substitution, then - * the final substituted instruction will be returned. If there is no substitution - * for this instruction, {@code this} will be returned. - * @return the substitution for this instruction - */ - public final Value subst() { - if (subst == null) { - return this; - } - return subst.subst(); - } - - /** - * Checks whether this instruction has a substitute. - * @return {@code true} if this instruction has a substitution. - */ - public final boolean hasSubst() { - return subst != null; - } - /** * Check whether this instruction has the specified flag set. * @param flag the flag to test diff -r e3a0630a1dab -r 2af109bec0c0 graal/GraalCompiler/src/com/sun/c1x/lir/LIRBlock.java --- a/graal/GraalCompiler/src/com/sun/c1x/lir/LIRBlock.java Fri May 27 14:58:55 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/lir/LIRBlock.java Fri May 27 15:11:34 2011 +0200 @@ -24,10 +24,10 @@ import java.util.*; +import com.oracle.graal.graph.*; import com.oracle.max.asm.*; import com.sun.c1x.alloc.*; import com.sun.c1x.debug.*; -import com.sun.c1x.ir.*; import com.sun.c1x.util.*; import com.sun.c1x.value.*; import com.sun.cri.ci.*; @@ -41,7 +41,7 @@ private LIRList lir; private final int blockID; private FrameState lastState; - private List instructions = new ArrayList(4); + private List instructions = new ArrayList(4); private List predecessors = new ArrayList(4); private List successors = new ArrayList(4); private List exceptionHandlerSuccessors = new ArrayList(4); @@ -89,7 +89,7 @@ linearScanNumber = blockID; } - public List getInstructions() { + public List getInstructions() { return instructions; } @@ -248,7 +248,7 @@ predecessors.clear(); } - public void setInstructions(List list) { + public void setInstructions(List list) { instructions = list; }