Mercurial > hg > truffle
comparison graal/GraalCompiler/src/com/sun/c1x/ir/BlockBegin.java @ 2773:27512ea6bbcb
exception dispatch simplification:
* BlockMap creates exception dispatch blocks (so they're iterated in the right order)
* GraphBuilder uses exception dispatch blocks, simplified handleException, removed updateDispatchChain
* simplified mergeOrClone
* removed successor & predecessor methods from BlockBegin
author | Lukas Stadler <lukas.stadler@jku.at> |
---|---|
date | Tue, 24 May 2011 12:07:17 +0200 |
parents | 43ffa0e47a46 |
children | 93ec3f067420 bda5972a40a5 |
comparison
equal
deleted
inserted
replaced
2772:3e3338a1abb9 | 2773:27512ea6bbcb |
---|---|
95 this.bci = bci; | 95 this.bci = bci; |
96 this.isLoopHeader = isLoopHeader; | 96 this.isLoopHeader = isLoopHeader; |
97 } | 97 } |
98 | 98 |
99 /** | 99 /** |
100 * Gets the list of predecessors of this block. | |
101 * @return the predecessor list | |
102 */ | |
103 @SuppressWarnings({ "unchecked", "rawtypes" }) | |
104 public List<Instruction> blockPredecessors() { | |
105 if (predecessors().size() == 1 && predecessors().get(0) == graph().start()) { | |
106 return Collections.EMPTY_LIST; | |
107 } else { | |
108 return (List) Collections.unmodifiableList(predecessors()); | |
109 } | |
110 } | |
111 | |
112 /** | |
113 * Gets the linear scan number of this block. | 100 * Gets the linear scan number of this block. |
114 * @return the linear scan number | 101 * @return the linear scan number |
115 */ | 102 */ |
116 public int linearScanNumber() { | 103 public int linearScanNumber() { |
117 return linearScanNumber; | 104 return linearScanNumber; |
145 BlockEnd e = end(); | 132 BlockEnd e = end(); |
146 | 133 |
147 Instruction inst = this; | 134 Instruction inst = this; |
148 ArrayList<BlockBegin> excBlocks = new ArrayList<BlockBegin>(); | 135 ArrayList<BlockBegin> excBlocks = new ArrayList<BlockBegin>(); |
149 while (inst != null) { | 136 while (inst != null) { |
150 if (inst instanceof Invoke) { | 137 if (inst instanceof ExceptionEdgeInstruction) { |
151 excBlocks.add(((Invoke) inst).exceptionEdge()); | 138 excBlocks.add(((ExceptionEdgeInstruction) inst).exceptionEdge()); |
152 } else if (inst instanceof Throw) { | |
153 excBlocks.add(((Throw) inst).exceptionEdge()); | |
154 } | 139 } |
155 inst = inst.next(); | 140 inst = inst.next(); |
156 } | 141 } |
157 while (excBlocks.remove(null)) { | 142 while (excBlocks.remove(null)) { |
158 // nothing | 143 // nothing |
198 builder.append(s.blockID); | 183 builder.append(s.blockID); |
199 hasSucc = true; | 184 hasSucc = true; |
200 } | 185 } |
201 } | 186 } |
202 return builder.toString(); | 187 return builder.toString(); |
203 } | |
204 | |
205 /** | |
206 * Get the number of successors. | |
207 * @return the number of successors | |
208 */ | |
209 public int numberOfSux() { | |
210 return end().blockSuccessorCount(); | |
211 } | |
212 | |
213 /** | |
214 * Get the successor at a certain position. | |
215 * @param i the position | |
216 * @return the successor | |
217 */ | |
218 public BlockBegin suxAt(int i) { | |
219 return end().blockSuccessor(i); | |
220 } | |
221 | |
222 /** | |
223 * Get the number of predecessors. | |
224 * @return the number of predecessors | |
225 */ | |
226 public int numberOfPreds() { | |
227 // ignore the graph root | |
228 if (predecessors().size() == 1 && predecessors().get(0) == graph().start()) { | |
229 return 0; | |
230 } else { | |
231 return predecessors().size(); | |
232 } | |
233 } | |
234 | |
235 public Instruction predAt(int j) { | |
236 return (Instruction) predecessors().get(j); | |
237 } | 188 } |
238 | 189 |
239 public void printWithoutPhis(LogStream out) { | 190 public void printWithoutPhis(LogStream out) { |
240 // print block id | 191 // print block id |
241 BlockEnd end = end(); | 192 BlockEnd end = end(); |
395 | 346 |
396 /** | 347 /** |
397 * Iterates over all successors of this block: successors of the end node and exception handler. | 348 * Iterates over all successors of this block: successors of the end node and exception handler. |
398 */ | 349 */ |
399 public void allSuccessorsDo(boolean backwards, BlockClosure closure) { | 350 public void allSuccessorsDo(boolean backwards, BlockClosure closure) { |
351 BlockEnd end = end(); | |
400 if (backwards) { | 352 if (backwards) { |
401 for (int i = numberOfSux() - 1; i >= 0; i--) { | 353 for (int i = end.blockSuccessorCount() - 1; i >= 0; i--) { |
402 closure.apply(suxAt(i)); | 354 closure.apply(end.blockSuccessor(i)); |
403 } | 355 } |
404 } else { | 356 } else { |
405 for (int i = 0; i < numberOfSux(); i++) { | 357 for (int i = 0; i < end.blockSuccessorCount(); i++) { |
406 closure.apply(suxAt(i)); | 358 closure.apply(end.blockSuccessor(i)); |
407 } | 359 } |
408 } | 360 } |
409 for (Instruction x = next(); x != null; x = x.next()) { | 361 for (Instruction x = next(); x != null; x = x.next()) { |
410 if (x instanceof ExceptionEdgeInstruction && ((ExceptionEdgeInstruction) x).exceptionEdge() != null) { | 362 if (x instanceof ExceptionEdgeInstruction && ((ExceptionEdgeInstruction) x).exceptionEdge() != null) { |
411 closure.apply(((ExceptionEdgeInstruction) x).exceptionEdge()); | 363 closure.apply(((ExceptionEdgeInstruction) x).exceptionEdge()); |