comparison graal/GraalCompiler/src/com/sun/c1x/ir/BlockBegin.java @ 2741:a3cd5eb68837

more GraphBuilder cleanup, moved mergeOrClone to GraphBuilder
author Lukas Stadler <lukas.stadler@jku.at>
date Fri, 20 May 2011 11:11:33 +0200
parents d913f3049cee
children 6048da340364 0fe79e7435c3
comparison
equal deleted inserted replaced
2736:03b80fb10ae9 2741:a3cd5eb68837
76 /** 76 /**
77 * A unique id used in tracing. 77 * A unique id used in tracing.
78 */ 78 */
79 public final int blockID; 79 public final int blockID;
80 80
81 private int depthFirstNumber;
82 private int linearScanNumber; 81 private int linearScanNumber;
83 82
84 // LIR block 83 // LIR block
85 public LIRBlock lirBlock; 84 public LIRBlock lirBlock;
86 85
249 @Override 248 @Override
250 public void accept(ValueVisitor v) { 249 public void accept(ValueVisitor v) {
251 v.visitBlockBegin(this); 250 v.visitBlockBegin(this);
252 } 251 }
253 252
254 public void mergeOrClone(FrameStateAccess newState, RiMethod method, boolean loopHeader) {
255 FrameState existingState = stateBefore();
256
257 if (existingState == null) {
258 // copy state because it is modified
259 FrameState duplicate = newState.duplicate(bci());
260
261 // if the block is a loop header, insert all necessary phis
262 if (loopHeader) {
263 insertLoopPhis(duplicate);
264 }
265
266 setStateBefore(duplicate);
267 } else {
268 if (!C1XOptions.AssumeVerifiedBytecode && !existingState.isCompatibleWith(newState)) {
269 // stacks or locks do not match--bytecodes would not verify
270 throw new CiBailout("stack or locks do not match");
271 }
272
273 assert existingState.localsSize() == newState.localsSize();
274 assert existingState.stackSize() == newState.stackSize();
275
276 existingState.merge(this, newState);
277 }
278 }
279
280 private void insertLoopPhis(FrameState newState) {
281 int stackSize = newState.stackSize();
282 for (int i = 0; i < stackSize; i++) {
283 // always insert phis for the stack
284 newState.setupPhiForStack(this, i);
285 }
286 int localsSize = newState.localsSize();
287 for (int i = 0; i < localsSize; i++) {
288 Value x = newState.localAt(i);
289 if (x != null) {
290 newState.setupPhiForLocal(this, i);
291 }
292 }
293 }
294
295 @Override 253 @Override
296 public String toString() { 254 public String toString() {
297 StringBuilder builder = new StringBuilder(); 255 StringBuilder builder = new StringBuilder();
298 builder.append("block #"); 256 builder.append("block #");
299 builder.append(blockID); 257 builder.append(blockID);
300 builder.append(","); 258 builder.append(",");
301 builder.append(depthFirstNumber); 259 builder.append(blockID); // was: depthFirstNumber
302 builder.append(" ["); 260 builder.append(" [");
303 261
304 builder.append("]"); 262 builder.append("]");
305 if (end() != null) { 263 if (end() != null) {
306 builder.append(" -> "); 264 builder.append(" -> ");