comparison graal/GraalCompiler/src/com/sun/c1x/gen/LIRGenerator.java @ 2634:4dd0573f510b

FrameState fixes.
author Thomas Wuerthinger <thomas@wuerthinger.net>
date Wed, 11 May 2011 10:52:37 +0200
parents 721a45190d6d
children 0f69be73d5ce
comparison
equal deleted inserted replaced
2633:721a45190d6d 2634:4dd0573f510b
227 TTY.println("BEGIN Generating LIR for block B" + block.blockID); 227 TTY.println("BEGIN Generating LIR for block B" + block.blockID);
228 } 228 }
229 229
230 for (Instruction instr = block; instr != null; instr = instr.next()) { 230 for (Instruction instr = block; instr != null; instr = instr.next()) {
231 FrameState stateAfter = instr.stateAfter(); 231 FrameState stateAfter = instr.stateAfter();
232 FrameState stateBefore = null;
233 if (instr instanceof StateSplit && ((StateSplit) instr).stateBefore() != null) {
234 stateBefore = ((StateSplit) instr).stateBefore();
235 }
236 if (stateBefore != null) {
237 lastState = stateBefore;
238 if (C1XOptions.TraceLIRGeneratorLevel >= 2) {
239 TTY.println("STATE CHANGE (stateBefore)");
240 if (C1XOptions.TraceLIRGeneratorLevel >= 3) {
241 TTY.println(stateBefore.toString());
242 }
243 }
244 }
232 if (!(instr instanceof BlockBegin)) { 245 if (!(instr instanceof BlockBegin)) {
233 walkState(instr, stateAfter); 246 walkState(instr, stateAfter);
234 doRoot(instr); 247 doRoot(instr);
235 } 248 }
236 if (stateAfter != null) { 249 if (stateAfter != null) {
295 } 308 }
296 } 309 }
297 310
298 @Override 311 @Override
299 public void visitResolveClass(ResolveClass i) { 312 public void visitResolveClass(ResolveClass i) {
300 LIRDebugInfo info = stateFor(i, i.stateAfter()); 313 LIRDebugInfo info = stateFor(i);
301 XirSnippet snippet = xir.genResolveClass(site(i), i.type, i.portion); 314 XirSnippet snippet = xir.genResolveClass(site(i), i.type, i.portion);
302 emitXir(snippet, i, info, null, true); 315 emitXir(snippet, i, info, null, true);
303 } 316 }
304 317
305 @Override 318 @Override
311 324
312 @Override 325 @Override
313 public void visitInstanceOf(InstanceOf x) { 326 public void visitInstanceOf(InstanceOf x) {
314 XirArgument obj = toXirArgument(x.object()); 327 XirArgument obj = toXirArgument(x.object());
315 XirSnippet snippet = xir.genInstanceOf(site(x), obj, toXirArgument(x.targetClassInstruction()), x.targetClass()); 328 XirSnippet snippet = xir.genInstanceOf(site(x), obj, toXirArgument(x.targetClassInstruction()), x.targetClass());
316 emitXir(snippet, x, maybeStateFor(x), null, true); 329 emitXir(snippet, x, stateFor(x), null, true);
317 } 330 }
318 331
319 @Override 332 @Override
320 public void visitMonitorEnter(MonitorEnter x) { 333 public void visitMonitorEnter(MonitorEnter x) {
321 XirArgument obj = toXirArgument(x.object()); 334 XirArgument obj = toXirArgument(x.object());
322 XirArgument lockAddress = toXirArgument(x.lockAddress()); 335 XirArgument lockAddress = toXirArgument(x.lockAddress());
323 XirSnippet snippet = xir.genMonitorEnter(site(x), obj, lockAddress); 336 XirSnippet snippet = xir.genMonitorEnter(site(x), obj, lockAddress);
324 emitXir(snippet, x, maybeStateFor(x), stateFor(x, x.stateAfter()), null, true, null); 337 emitXir(snippet, x, stateFor(x), stateFor(x, x.stateAfter()), null, true, null);
325 } 338 }
326 339
327 @Override 340 @Override
328 public void visitMonitorExit(MonitorExit x) { 341 public void visitMonitorExit(MonitorExit x) {
329 XirArgument obj = toXirArgument(x.object()); 342 XirArgument obj = toXirArgument(x.object());
330 XirArgument lockAddress = toXirArgument(x.lockAddress()); 343 XirArgument lockAddress = toXirArgument(x.lockAddress());
331 XirSnippet snippet = xir.genMonitorExit(site(x), obj, lockAddress); 344 XirSnippet snippet = xir.genMonitorExit(site(x), obj, lockAddress);
332 emitXir(snippet, x, maybeStateFor(x), null, true); 345 emitXir(snippet, x, stateFor(x), null, true);
333 } 346 }
334 347
335 @Override 348 @Override
336 public void visitStoreIndexed(StoreIndexed x) { 349 public void visitStoreIndexed(StoreIndexed x) {
337 XirArgument array = toXirArgument(x.array()); 350 XirArgument array = toXirArgument(x.array());
338 XirArgument length = x.length() == null ? null : toXirArgument(x.length()); 351 XirArgument length = x.length() == null ? null : toXirArgument(x.length());
339 XirArgument index = toXirArgument(x.index()); 352 XirArgument index = toXirArgument(x.index());
340 XirArgument value = toXirArgument(x.value()); 353 XirArgument value = toXirArgument(x.value());
341 XirSnippet snippet = xir.genArrayStore(site(x), array, index, length, value, x.elementKind(), null); 354 XirSnippet snippet = xir.genArrayStore(site(x), array, index, length, value, x.elementKind(), null);
342 emitXir(snippet, x, maybeStateFor(x), null, true); 355 emitXir(snippet, x, stateFor(x), null, true);
343 } 356 }
344 357
345 @Override 358 @Override
346 public void visitNewInstance(NewInstance x) { 359 public void visitNewInstance(NewInstance x) {
347 XirSnippet snippet = xir.genNewInstance(site(x), x.instanceClass()); 360 XirSnippet snippet = xir.genNewInstance(site(x), x.instanceClass());
403 return true; 416 return true;
404 } 417 }
405 }); 418 });
406 419
407 XirSnippet snippet = xir.genExceptionObject(site(x)); 420 XirSnippet snippet = xir.genExceptionObject(site(x));
408 emitXir(snippet, x, maybeStateFor(x), null, true); 421 emitXir(snippet, x, stateFor(x), null, true);
409 } 422 }
410 423
411 @Override 424 @Override
412 public void visitGoto(Goto x) { 425 public void visitGoto(Goto x) {
413 setNoResult(x); 426 setNoResult(x);
546 public void visitLoadIndexed(LoadIndexed x) { 559 public void visitLoadIndexed(LoadIndexed x) {
547 XirArgument array = toXirArgument(x.array()); 560 XirArgument array = toXirArgument(x.array());
548 XirArgument index = toXirArgument(x.index()); 561 XirArgument index = toXirArgument(x.index());
549 XirArgument length = toXirArgument(x.length()); 562 XirArgument length = toXirArgument(x.length());
550 XirSnippet snippet = xir.genArrayLoad(site(x), array, index, length, x.elementKind(), null); 563 XirSnippet snippet = xir.genArrayLoad(site(x), array, index, length, x.elementKind(), null);
551 emitXir(snippet, x, maybeStateFor(x), null, true); 564 emitXir(snippet, x, stateFor(x), null, true);
552 } 565 }
553 566
554 protected GlobalStub stubFor(CiRuntimeCall runtimeCall) { 567 protected GlobalStub stubFor(CiRuntimeCall runtimeCall) {
555 GlobalStub stub = compilation.compiler.lookupGlobalStub(runtimeCall); 568 GlobalStub stub = compilation.compiler.lookupGlobalStub(runtimeCall);
556 compilation.frameMap().usesGlobalStub(stub); 569 compilation.frameMap().usesGlobalStub(stub);
1462 assert operand.isLegal() : "must be evaluated now"; 1475 assert operand.isLegal() : "must be evaluated now";
1463 } 1476 }
1464 } 1477 }
1465 } 1478 }
1466 1479
1467 protected LIRDebugInfo maybeStateFor(Instruction x) {
1468 if (x.stateAfter() == null) {
1469 return null;
1470 }
1471 return stateFor(x, x.stateAfter());
1472 }
1473
1474 protected LIRDebugInfo stateFor(Instruction x) { 1480 protected LIRDebugInfo stateFor(Instruction x) {
1475 assert lastState != null : "must have state before instruction for " + x; 1481 assert lastState != null : "must have state before instruction for " + x;
1476 return stateFor(x, lastState); 1482 return stateFor(x, lastState);
1477 } 1483 }
1478 1484
1601 } 1607 }
1602 return false; 1608 return false;
1603 } 1609 }
1604 1610
1605 public boolean requiresNullCheck() { 1611 public boolean requiresNullCheck() {
1606 return current == null || current.canTrap(); 1612 return current == null || current.canTrap() || current instanceof InstanceOf || current instanceof CheckCast;
1607 } 1613 }
1608 1614
1609 public boolean requiresBoundsCheck() { 1615 public boolean requiresBoundsCheck() {
1610 return true; 1616 return true;
1611 } 1617 }