Mercurial > hg > graal-compiler
comparison graal/GraalCompiler/src/com/sun/c1x/graph/IR.java @ 2674:6ab73784566a
* BlockBegin.predecessors changed to List<BlockEnd>
* Node: add input/successor with given back edge index, allows for explicit ordering of predecessors/usages
* Graphviz: PDF output, option to omit FrameStates
* runscimark.sh: forward additional options to JVM
author | Lukas Stadler <lukas.stadler@jku.at> |
---|---|
date | Fri, 13 May 2011 15:18:41 +0200 |
parents | 194d93d089bd |
children | bd4c3be86fb7 7ed72769d51a |
comparison
equal
deleted
inserted
replaced
2673:98447ab8bd83 | 2674:6ab73784566a |
---|---|
161 bci = target.bci(); | 161 bci = target.bci(); |
162 } else { | 162 } else { |
163 bci = source.end().bci(); | 163 bci = source.end().bci(); |
164 } | 164 } |
165 | 165 |
166 int backEdgeIndex = target.predecessors().indexOf(source.end()); | |
167 | |
166 // create new successor and mark it for special block order treatment | 168 // create new successor and mark it for special block order treatment |
167 BlockBegin newSucc = new BlockBegin(bci, nextBlockNumber(), compilation.graph); | 169 BlockBegin newSucc = new BlockBegin(bci, nextBlockNumber(), compilation.graph); |
168 | 170 |
169 newSucc.setCriticalEdgeSplit(true); | 171 newSucc.setCriticalEdgeSplit(true); |
170 | 172 |
171 // This goto is not a safepoint. | 173 // This goto is not a safepoint. |
172 Goto e = new Goto(target, null, false, compilation.graph); | 174 Goto e = new Goto(target, null, false, compilation.graph); |
173 newSucc.appendNext(e, bci); | 175 newSucc.appendNext(e, bci); |
174 newSucc.setEnd(e); | 176 newSucc.setEnd(e); |
177 e.reorderSuccessor(0, backEdgeIndex); | |
175 // setup states | 178 // setup states |
176 FrameState s = source.end().stateAfter(); | 179 FrameState s = source.end().stateAfter(); |
177 newSucc.setStateBefore(s); | 180 newSucc.setStateBefore(s); |
178 e.setStateAfter(s); | 181 e.setStateAfter(s); |
179 assert newSucc.stateBefore().localsSize() == s.localsSize(); | 182 assert newSucc.stateBefore().localsSize() == s.localsSize(); |
183 source.end().substituteSuccessor(target, newSucc); | 186 source.end().substituteSuccessor(target, newSucc); |
184 | 187 |
185 // The ordering needs to be the same, so remove the link that the | 188 // The ordering needs to be the same, so remove the link that the |
186 // set_end call above added and substitute the new_sux for this | 189 // set_end call above added and substitute the new_sux for this |
187 // block. | 190 // block. |
188 target.removePredecessor(newSucc); | 191 target.removePredecessor(newSucc.end()); |
189 | 192 |
190 // the successor could be the target of a switch so it might have | 193 // the successor could be the target of a switch so it might have |
191 // multiple copies of this predecessor, so substitute the new_sux | 194 // multiple copies of this predecessor, so substitute the new_sux |
192 // for the first and delete the rest. | 195 // for the first and delete the rest. |
193 List<BlockBegin> list = target.blockPredecessors(); | 196 List<BlockEnd> list = target.blockPredecessors(); |
194 int x = list.indexOf(source); | 197 int x = list.indexOf(source.end()); |
195 list.set(x, newSucc); | 198 list.set(x, newSucc.end()); |
196 newSucc.addPredecessor(source); | 199 newSucc.addPredecessor(source.end()); |
197 Iterator<BlockBegin> iterator = list.iterator(); | 200 Iterator<BlockEnd> iterator = list.iterator(); |
198 while (iterator.hasNext()) { | 201 while (iterator.hasNext()) { |
199 if (iterator.next() == source) { | 202 if (iterator.next() == source.end()) { |
200 iterator.remove(); | 203 iterator.remove(); |
201 newSucc.addPredecessor(source); | 204 newSucc.addPredecessor(source.end()); |
202 } | 205 } |
203 } | 206 } |
204 return newSucc; | 207 return newSucc; |
205 } | 208 } |
206 | 209 |
207 public void replaceBlock(BlockBegin oldBlock, BlockBegin newBlock) { | 210 public void replaceBlock(BlockBegin oldBlock, BlockBegin newBlock) { |
208 assert !oldBlock.isExceptionEntry() : "cannot replace exception handler blocks (yet)"; | 211 assert !oldBlock.isExceptionEntry() : "cannot replace exception handler blocks (yet)"; |
209 for (BlockBegin succ : oldBlock.end().blockSuccessors()) { | 212 for (BlockBegin succ : oldBlock.end().blockSuccessors()) { |
210 succ.removePredecessor(oldBlock); | 213 succ.removePredecessor(oldBlock.end()); |
211 } | 214 } |
212 for (BlockBegin pred : oldBlock.blockPredecessors()) { | 215 for (BlockEnd pred : oldBlock.blockPredecessors()) { |
213 // substitute the new successor for this block in each predecessor | 216 // substitute the new successor for this block in each predecessor |
214 pred.end().substituteSuccessor(oldBlock, newBlock); | 217 pred.substituteSuccessor(oldBlock, newBlock); |
215 // and add each predecessor to the successor | 218 // and add each predecessor to the successor |
216 newBlock.addPredecessor(pred); | 219 newBlock.addPredecessor(pred); |
217 } | 220 } |
218 // this block is now disconnected; remove all its incoming and outgoing edges | 221 // this block is now disconnected; remove all its incoming and outgoing edges |
219 // oldBlock.blockPredecessors().clear(); | 222 // oldBlock.blockPredecessors().clear(); |
220 // oldBlock.end().blockSuccessors().clear(); | 223 // oldBlock.end().successors().clear(); |
221 } | 224 } |
222 | 225 |
223 /** | 226 /** |
224 * Disconnects the specified block from all other blocks. | 227 * Disconnects the specified block from all other blocks. |
225 * @param block the block to remove from the graph | 228 * @param block the block to remove from the graph |
226 */ | 229 */ |
227 public void disconnectFromGraph(BlockBegin block) { | 230 public void disconnectFromGraph(BlockBegin block) { |
228 for (BlockBegin p : block.blockPredecessors()) { | 231 for (BlockEnd p : block.blockPredecessors()) { |
229 p.end().blockSuccessors().remove(block); | 232 p.blockSuccessors().remove(block); |
230 } | 233 } |
231 for (BlockBegin s : block.end().blockSuccessors()) { | 234 for (BlockBegin s : block.end().blockSuccessors()) { |
232 s.blockPredecessors().remove(block); | 235 s.blockPredecessors().remove(block); |
233 } | 236 } |
234 } | 237 } |