Mercurial > hg > truffle
comparison graal/GraalCompiler/src/com/sun/c1x/graph/IR.java @ 2779:93ec3f067420
Changed CriticalEdgeFinder to use LIRBlock.
author | Thomas Wuerthinger <thomas@wuerthinger.net> |
---|---|
date | Wed, 25 May 2011 11:04:59 +0200 |
parents | 2ac7b30b7290 |
children | 79dda81dd337 |
comparison
equal
deleted
inserted
replaced
2778:2ac7b30b7290 | 2779:93ec3f067420 |
---|---|
77 | 77 |
78 if (C1XOptions.PrintTimers) { | 78 if (C1XOptions.PrintTimers) { |
79 C1XTimers.HIR_CREATE.stop(); | 79 C1XTimers.HIR_CREATE.stop(); |
80 C1XTimers.HIR_OPTIMIZE.start(); | 80 C1XTimers.HIR_OPTIMIZE.start(); |
81 } | 81 } |
82 | |
83 CriticalEdgeFinder finder = new CriticalEdgeFinder(this); | |
84 getHIRStartBlock().iteratePreOrder(finder); | |
85 finder.splitCriticalEdges(); | |
86 | 82 |
87 Schedule schedule = new Schedule(this.compilation.graph); | 83 Schedule schedule = new Schedule(this.compilation.graph); |
88 List<Block> blocks = schedule.getBlocks(); | 84 List<Block> blocks = schedule.getBlocks(); |
89 List<LIRBlock> lirBlocks = new ArrayList<LIRBlock>(); | 85 List<LIRBlock> lirBlocks = new ArrayList<LIRBlock>(); |
90 Map<Block, LIRBlock> map = new HashMap<Block, LIRBlock>(); | 86 Map<Block, LIRBlock> map = new HashMap<Block, LIRBlock>(); |
114 | 110 |
115 // TODO(tw): Schedule nodes within a block. | 111 // TODO(tw): Schedule nodes within a block. |
116 //computeLinearScanOrder(); | 112 //computeLinearScanOrder(); |
117 | 113 |
118 // assert orderedBlocks.size() == lirBlocks.size(); | 114 // assert orderedBlocks.size() == lirBlocks.size(); |
115 | |
116 | |
117 CriticalEdgeFinder finder = new CriticalEdgeFinder(lirBlocks, compilation.graph); | |
118 finder.splitCriticalEdges(); | |
119 | |
120 | |
119 orderedBlocks = lirBlocks; | 121 orderedBlocks = lirBlocks; |
120 | |
121 | 122 |
122 valueToBlock = new HashMap<Value, LIRBlock>(); | 123 valueToBlock = new HashMap<Value, LIRBlock>(); |
123 for (LIRBlock b : orderedBlocks) { | 124 for (LIRBlock b : orderedBlocks) { |
124 for (Instruction i : b.getInstructions()) { | 125 for (Instruction i : b.getInstructions()) { |
125 valueToBlock.put(i, b); | 126 valueToBlock.put(i, b); |
254 if (compilation.compiler.isObserved()) { | 255 if (compilation.compiler.isObserved()) { |
255 compilation.compiler.fireCompilationEvent(new CompilationEvent(compilation, phase, getHIRStartBlock(), true, false)); | 256 compilation.compiler.fireCompilationEvent(new CompilationEvent(compilation, phase, getHIRStartBlock(), true, false)); |
256 } | 257 } |
257 } | 258 } |
258 | 259 |
259 /** | |
260 * Creates and inserts a new block between this block and the specified successor, | |
261 * altering the successor and predecessor lists of involved blocks appropriately. | |
262 * @param source the source of the edge | |
263 * @param target the successor before which to insert a block | |
264 * @return the new block inserted | |
265 */ | |
266 public BlockBegin splitEdge(BlockBegin source, BlockBegin target) { | |
267 int bci = -2; | |
268 | |
269 int backEdgeIndex = target.predecessors().indexOf(source.end()); | |
270 | |
271 // create new successor and mark it for special block order treatment | |
272 BlockBegin newSucc = new BlockBegin(bci, nextBlockNumber(), false, compilation.graph); | |
273 | |
274 List<Integer> removePhiInputs = null; | |
275 for (int i = backEdgeIndex + 1; i < target.predecessors().size(); ++i) { | |
276 if (target.predecessors().get(i) == source.end()) { | |
277 if (removePhiInputs == null) { | |
278 removePhiInputs = new ArrayList<Integer>(); | |
279 } | |
280 removePhiInputs.add(i); | |
281 } | |
282 } | |
283 | |
284 // This goto is not a safepoint. | |
285 Goto e = new Goto(target, compilation.graph); | |
286 newSucc.appendNext(e); | |
287 e.reorderSuccessor(0, backEdgeIndex); | |
288 | |
289 // link predecessor to new block | |
290 source.end().substituteSuccessor(target, newSucc); | |
291 if (removePhiInputs != null && removePhiInputs.size() > 0) { | |
292 | |
293 for (Node n : target.usages()) { | |
294 if (n instanceof Phi) { | |
295 Phi phi = (Phi) n; | |
296 int correction = 0; | |
297 for (int index : removePhiInputs) { | |
298 phi.removeInput(index - correction); | |
299 correction++; | |
300 } | |
301 } | |
302 } | |
303 | |
304 } | |
305 | |
306 return newSucc; | |
307 } | |
308 | 260 |
309 public int nextBlockNumber() { | 261 public int nextBlockNumber() { |
310 return compilation.stats.blockCount++; | 262 return compilation.stats.blockCount++; |
311 } | 263 } |
312 | 264 |