Mercurial > hg > truffle
comparison graal/GraalCompiler/src/com/sun/c1x/graph/GraphBuilder.java @ 2645:b2c1e959be46
Clean up around BlockBegin / StdEntry.
author | Thomas Wuerthinger <thomas@wuerthinger.net> |
---|---|
date | Wed, 11 May 2011 14:34:29 +0200 |
parents | 4694daa6af3a |
children | 0bf54306c139 |
comparison
equal
deleted
inserted
replaced
2644:4694daa6af3a | 2645:b2c1e959be46 |
---|---|
343 } else { | 343 } else { |
344 throw new Error("lookupConstant returned an object of incorrect type"); | 344 throw new Error("lookupConstant returned an object of incorrect type"); |
345 } | 345 } |
346 } | 346 } |
347 | 347 |
348 void genLoadIndexed(CiKind kind) { | 348 private void genLoadIndexed(CiKind kind) { |
349 Value index = frameState.ipop(); | 349 Value index = frameState.ipop(); |
350 Value array = frameState.apop(); | 350 Value array = frameState.apop(); |
351 Value length = append(new ArrayLength(array, graph)); | 351 Value length = append(new ArrayLength(array, graph)); |
352 Value v = append(new LoadIndexed(array, index, length, kind, graph)); | 352 Value v = append(new LoadIndexed(array, index, length, kind, graph)); |
353 frameState.push(kind.stackKind(), v); | 353 frameState.push(kind.stackKind(), v); |
354 } | 354 } |
355 | 355 |
356 void genStoreIndexed(CiKind kind) { | 356 private void genStoreIndexed(CiKind kind) { |
357 Value value = frameState.pop(kind.stackKind()); | 357 Value value = frameState.pop(kind.stackKind()); |
358 Value index = frameState.ipop(); | 358 Value index = frameState.ipop(); |
359 Value array = frameState.apop(); | 359 Value array = frameState.apop(); |
360 Value length = append(new ArrayLength(array, graph)); | 360 Value length = append(new ArrayLength(array, graph)); |
361 StoreIndexed result = new StoreIndexed(array, index, length, kind, value, graph); | 361 StoreIndexed result = new StoreIndexed(array, index, length, kind, value, graph); |
362 append(result); | 362 append(result); |
363 } | 363 } |
364 | 364 |
365 void stackOp(int opcode) { | 365 private void stackOp(int opcode) { |
366 switch (opcode) { | 366 switch (opcode) { |
367 case POP: { | 367 case POP: { |
368 frameState.xpop(); | 368 frameState.xpop(); |
369 break; | 369 break; |
370 } | 370 } |
441 throw Util.shouldNotReachHere(); | 441 throw Util.shouldNotReachHere(); |
442 } | 442 } |
443 | 443 |
444 } | 444 } |
445 | 445 |
446 void genArithmeticOp(CiKind kind, int opcode) { | 446 private void genArithmeticOp(CiKind kind, int opcode) { |
447 genArithmeticOp(kind, opcode, false); | 447 genArithmeticOp(kind, opcode, false); |
448 } | 448 } |
449 | 449 |
450 void genArithmeticOp(CiKind kind, int opcode, boolean canTrap) { | 450 private void genArithmeticOp(CiKind kind, int opcode, boolean canTrap) { |
451 genArithmeticOp(kind, opcode, kind, kind, canTrap); | 451 genArithmeticOp(kind, opcode, kind, kind, canTrap); |
452 } | 452 } |
453 | 453 |
454 void genArithmeticOp(CiKind result, int opcode, CiKind x, CiKind y, boolean canTrap) { | 454 private void genArithmeticOp(CiKind result, int opcode, CiKind x, CiKind y, boolean canTrap) { |
455 Value yValue = frameState.pop(y); | 455 Value yValue = frameState.pop(y); |
456 Value xValue = frameState.pop(x); | 456 Value xValue = frameState.pop(x); |
457 Value result1 = append(new ArithmeticOp(opcode, result, xValue, yValue, isStrict(method().accessFlags()), canTrap, graph)); | 457 Value result1 = append(new ArithmeticOp(opcode, result, xValue, yValue, isStrict(method().accessFlags()), canTrap, graph)); |
458 frameState.push(result, result1); | 458 frameState.push(result, result1); |
459 } | 459 } |
460 | 460 |
461 void genNegateOp(CiKind kind) { | 461 private void genNegateOp(CiKind kind) { |
462 frameState.push(kind, append(new NegateOp(frameState.pop(kind), graph))); | 462 frameState.push(kind, append(new NegateOp(frameState.pop(kind), graph))); |
463 } | 463 } |
464 | 464 |
465 void genShiftOp(CiKind kind, int opcode) { | 465 private void genShiftOp(CiKind kind, int opcode) { |
466 Value s = frameState.ipop(); | 466 Value s = frameState.ipop(); |
467 Value x = frameState.pop(kind); | 467 Value x = frameState.pop(kind); |
468 // note that strength reduction of e << K >>> K is correctly handled in canonicalizer now | |
469 frameState.push(kind, append(new ShiftOp(opcode, x, s, graph))); | 468 frameState.push(kind, append(new ShiftOp(opcode, x, s, graph))); |
470 } | 469 } |
471 | 470 |
472 void genLogicOp(CiKind kind, int opcode) { | 471 private void genLogicOp(CiKind kind, int opcode) { |
473 Value y = frameState.pop(kind); | 472 Value y = frameState.pop(kind); |
474 Value x = frameState.pop(kind); | 473 Value x = frameState.pop(kind); |
475 frameState.push(kind, append(new LogicOp(opcode, x, y, graph))); | 474 frameState.push(kind, append(new LogicOp(opcode, x, y, graph))); |
476 } | 475 } |
477 | 476 |
478 void genCompareOp(CiKind kind, int opcode, CiKind resultKind) { | 477 private void genCompareOp(CiKind kind, int opcode, CiKind resultKind) { |
479 Value y = frameState.pop(kind); | 478 Value y = frameState.pop(kind); |
480 Value x = frameState.pop(kind); | 479 Value x = frameState.pop(kind); |
481 Value value = append(new CompareOp(opcode, resultKind, x, y, graph)); | 480 Value value = append(new CompareOp(opcode, resultKind, x, y, graph)); |
482 if (!resultKind.isVoid()) { | 481 if (!resultKind.isVoid()) { |
483 frameState.ipush(value); | 482 frameState.ipush(value); |
484 } | 483 } |
485 } | 484 } |
486 | 485 |
487 void genConvert(int opcode, CiKind from, CiKind to) { | 486 private void genConvert(int opcode, CiKind from, CiKind to) { |
488 CiKind tt = to.stackKind(); | 487 CiKind tt = to.stackKind(); |
489 frameState.push(tt, append(new Convert(opcode, frameState.pop(from.stackKind()), tt, graph))); | 488 frameState.push(tt, append(new Convert(opcode, frameState.pop(from.stackKind()), tt, graph))); |
490 } | 489 } |
491 | 490 |
492 void genIncrement() { | 491 private void genIncrement() { |
493 int index = stream().readLocalIndex(); | 492 int index = stream().readLocalIndex(); |
494 int delta = stream().readIncrement(); | 493 int delta = stream().readIncrement(); |
495 Value x = frameState.localAt(index); | 494 Value x = frameState.localAt(index); |
496 Value y = append(Constant.forInt(delta, graph)); | 495 Value y = append(Constant.forInt(delta, graph)); |
497 frameState.storeLocal(index, append(new ArithmeticOp(IADD, CiKind.Int, x, y, isStrict(method().accessFlags()), false, graph))); | 496 frameState.storeLocal(index, append(new ArithmeticOp(IADD, CiKind.Int, x, y, isStrict(method().accessFlags()), false, graph))); |
498 } | 497 } |
499 | 498 |
500 void genGoto(int fromBCI, int toBCI) { | 499 private void genGoto(int fromBCI, int toBCI) { |
501 boolean isSafepoint = !noSafepoints() && toBCI <= fromBCI; | 500 boolean isSafepoint = !noSafepoints() && toBCI <= fromBCI; |
502 append(new Goto(blockAt(toBCI), null, isSafepoint, graph)); | 501 append(new Goto(blockAt(toBCI), null, isSafepoint, graph)); |
503 } | 502 } |
504 | 503 |
505 void ifNode(Value x, Condition cond, Value y, FrameState stateBefore) { | 504 private void ifNode(Value x, Condition cond, Value y, FrameState stateBefore) { |
506 BlockBegin tsucc = blockAt(stream().readBranchDest()); | 505 BlockBegin tsucc = blockAt(stream().readBranchDest()); |
507 BlockBegin fsucc = blockAt(stream().nextBCI()); | 506 BlockBegin fsucc = blockAt(stream().nextBCI()); |
508 int bci = stream().currentBCI(); | 507 int bci = stream().currentBCI(); |
509 boolean isSafepoint = !noSafepoints() && (tsucc.bci() <= bci || fsucc.bci() <= bci); | 508 boolean isSafepoint = !noSafepoints() && (tsucc.bci() <= bci || fsucc.bci() <= bci); |
510 append(new If(x, cond, y, tsucc, fsucc, isSafepoint ? stateBefore : null, isSafepoint, graph)); | 509 append(new If(x, cond, y, tsucc, fsucc, isSafepoint ? stateBefore : null, isSafepoint, graph)); |