Mercurial > hg > truffle
comparison graal/GraalCompiler/src/com/sun/c1x/graph/GraphBuilder.java @ 2790:50677668afe3
Towards making goto removal work.
author | Thomas Wuerthinger <thomas@wuerthinger.net> |
---|---|
date | Wed, 25 May 2011 19:29:40 +0200 |
parents | aeccd2af4e9e |
children | 6d14aa4fbf90 |
comparison
equal
deleted
inserted
replaced
2789:aeccd2af4e9e | 2790:50677668afe3 |
---|---|
219 } | 219 } |
220 | 220 |
221 for (Node n : graph.getNodes()) { | 221 for (Node n : graph.getNodes()) { |
222 if (n instanceof Placeholder) { | 222 if (n instanceof Placeholder) { |
223 Placeholder p = (Placeholder) n; | 223 Placeholder p = (Placeholder) n; |
224 | 224 assert p.blockPredecessors().size() == 1; |
225 /*if (p == graph.start().successors().get(0)) { | 225 Node pred = p.blockPredecessors().get(0); |
226 // nothing to do... | 226 int predIndex = p.predecessorsIndex().get(0); |
227 } else*/ | 227 pred.successors().setAndClear(predIndex, p, 0); |
228 if (p.blockPredecessors().size() == 0) { | 228 p.delete(); |
229 assert p.next() == null; | |
230 p.delete(); | |
231 } else { | |
232 assert p.blockPredecessors().size() == 1; | |
233 p.successors().replaceKeepOrder(p.next(), p.blockPredecessors().get(0)); | |
234 p.delete(); | |
235 } | |
236 } | 229 } |
237 } | 230 } |
238 | 231 |
239 for (Node n : graph.getNodes()) { | 232 for (Node n : graph.getNodes()) { |
240 assert !(n instanceof Placeholder); | 233 assert !(n instanceof Placeholder); |
324 assert existingState.localsSize() == newState.localsSize(); | 317 assert existingState.localsSize() == newState.localsSize(); |
325 assert existingState.stackSize() == newState.stackSize(); | 318 assert existingState.stackSize() == newState.stackSize(); |
326 | 319 |
327 if (first instanceof Placeholder) { | 320 if (first instanceof Placeholder) { |
328 BlockBegin merge = new BlockBegin(existingState.bci, target.blockID, target.isLoopHeader, graph); | 321 BlockBegin merge = new BlockBegin(existingState.bci, target.blockID, target.isLoopHeader, graph); |
329 for (Node n : new ArrayList<Node>(first.predecessors())) { | 322 |
330 n.successors().replace(first, merge); | 323 Placeholder p = (Placeholder) first; |
331 } | 324 assert p.next() == null; |
325 p.replace(merge); | |
332 target.firstInstruction = merge; | 326 target.firstInstruction = merge; |
333 merge.setStateBefore(existingState); | 327 merge.setStateBefore(existingState); |
334 } | 328 } |
335 | 329 |
336 existingState.merge((BlockBegin) target.firstInstruction, newState); | 330 existingState.merge((BlockBegin) target.firstInstruction, newState); |
1175 } | 1169 } |
1176 } | 1170 } |
1177 } | 1171 } |
1178 | 1172 |
1179 private void appendGoto(Instruction target) { | 1173 private void appendGoto(Instruction target) { |
1180 lastInstr.appendNext(target); | 1174 //if (target instanceof BlockBegin && !((BlockBegin)target).isLoopHeader) { |
1181 //append(new Goto(target, graph)); | 1175 // System.out.println("NOTOMITTED"); |
1176 //append(new Goto(target, graph)); | |
1177 //} else { | |
1178 // System.out.println("omitted"); | |
1179 lastInstr.appendNext(target); | |
1180 //} | |
1182 } | 1181 } |
1183 | 1182 |
1184 private void iterateBytecodesForBlock(Block block) { | 1183 private void iterateBytecodesForBlock(Block block) { |
1185 assert frameState != null; | 1184 assert frameState != null; |
1186 | 1185 |