Mercurial > hg > truffle
comparison graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java @ 19536:2c3ea61e8b65
Small clean up for graph building.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Sun, 22 Feb 2015 15:37:46 +0100 |
parents | 97b35083d49d |
children | e7d46a5f177b |
comparison
equal
deleted
inserted
replaced
19535:97b35083d49d | 19536:2c3ea61e8b65 |
---|---|
1499 } | 1499 } |
1500 } | 1500 } |
1501 | 1501 |
1502 protected void processBlock(BytecodeParser parser, BciBlock block) { | 1502 protected void processBlock(BytecodeParser parser, BciBlock block) { |
1503 // Ignore blocks that have no predecessors by the time their bytecodes are parsed | 1503 // Ignore blocks that have no predecessors by the time their bytecodes are parsed |
1504 if (block == null || getFirstInstruction(block, this.getCurrentDimension()) == null) { | 1504 int currentDimension = this.getCurrentDimension(); |
1505 FixedWithNextNode firstInstruction = getFirstInstruction(block, currentDimension); | |
1506 if (firstInstruction == null) { | |
1505 Debug.log("Ignoring block %s", block); | 1507 Debug.log("Ignoring block %s", block); |
1506 return; | 1508 return; |
1507 } | 1509 } |
1508 try (Indent indent = Debug.logAndIndent("Parsing block %s firstInstruction: %s loopHeader: %b", block, getFirstInstruction(block, this.getCurrentDimension()), block.isLoopHeader)) { | 1510 try (Indent indent = Debug.logAndIndent("Parsing block %s firstInstruction: %s loopHeader: %b", block, firstInstruction, block.isLoopHeader)) { |
1509 | 1511 |
1510 lastInstr = getFirstInstruction(block, this.getCurrentDimension()); | 1512 lastInstr = firstInstruction; |
1511 frameState = getEntryState(block, this.getCurrentDimension()); | 1513 frameState = getEntryState(block, currentDimension); |
1512 parser.setCurrentFrameState(frameState); | 1514 parser.setCurrentFrameState(frameState); |
1513 currentBlock = block; | 1515 currentBlock = block; |
1514 | 1516 |
1515 if (lastInstr instanceof AbstractMergeNode) { | 1517 if (firstInstruction instanceof AbstractMergeNode) { |
1516 | 1518 setMergeStateAfter(block, firstInstruction); |
1517 AbstractMergeNode abstractMergeNode = (AbstractMergeNode) lastInstr; | |
1518 if (abstractMergeNode.stateAfter() == null) { | |
1519 int bci = block.startBci; | |
1520 if (block instanceof ExceptionDispatchBlock) { | |
1521 bci = ((ExceptionDispatchBlock) block).deoptBci; | |
1522 } | |
1523 abstractMergeNode.setStateAfter(frameState.create(bci)); | |
1524 } | |
1525 } | 1519 } |
1526 | 1520 |
1527 if (block == blockMap.getReturnBlock()) { | 1521 if (block == blockMap.getReturnBlock()) { |
1528 Kind returnKind = method.getSignature().getReturnKind().getStackKind(); | 1522 handleReturnBlock(); |
1529 ValueNode x = returnKind == Kind.Void ? null : frameState.pop(returnKind); | |
1530 assert frameState.stackSize() == 0; | |
1531 beforeReturn(x); | |
1532 this.returnValue = x; | |
1533 this.beforeReturnNode = this.lastInstr; | |
1534 } else if (block == blockMap.getUnwindBlock()) { | 1523 } else if (block == blockMap.getUnwindBlock()) { |
1535 if (currentDepth == 0) { | 1524 handleUnwindBlock(); |
1536 frameState.setRethrowException(false); | |
1537 createUnwind(); | |
1538 } else { | |
1539 ValueNode exception = frameState.apop(); | |
1540 this.unwindValue = exception; | |
1541 this.beforeUnwindNode = this.lastInstr; | |
1542 } | |
1543 } else if (block instanceof ExceptionDispatchBlock) { | 1525 } else if (block instanceof ExceptionDispatchBlock) { |
1544 createExceptionDispatch((ExceptionDispatchBlock) block); | 1526 createExceptionDispatch((ExceptionDispatchBlock) block); |
1545 } else { | 1527 } else { |
1546 frameState.setRethrowException(false); | 1528 frameState.setRethrowException(false); |
1547 iterateBytecodesForBlock(block); | 1529 iterateBytecodesForBlock(block); |
1548 } | 1530 } |
1531 } | |
1532 } | |
1533 | |
1534 private void handleUnwindBlock() { | |
1535 if (currentDepth == 0) { | |
1536 frameState.setRethrowException(false); | |
1537 createUnwind(); | |
1538 } else { | |
1539 ValueNode exception = frameState.apop(); | |
1540 this.unwindValue = exception; | |
1541 this.beforeUnwindNode = this.lastInstr; | |
1542 } | |
1543 } | |
1544 | |
1545 private void handleReturnBlock() { | |
1546 Kind returnKind = method.getSignature().getReturnKind().getStackKind(); | |
1547 ValueNode x = returnKind == Kind.Void ? null : frameState.pop(returnKind); | |
1548 assert frameState.stackSize() == 0; | |
1549 beforeReturn(x); | |
1550 this.returnValue = x; | |
1551 this.beforeReturnNode = this.lastInstr; | |
1552 } | |
1553 | |
1554 private void setMergeStateAfter(BciBlock block, FixedWithNextNode firstInstruction) { | |
1555 AbstractMergeNode abstractMergeNode = (AbstractMergeNode) firstInstruction; | |
1556 if (abstractMergeNode.stateAfter() == null) { | |
1557 int bci = block.startBci; | |
1558 if (block instanceof ExceptionDispatchBlock) { | |
1559 bci = ((ExceptionDispatchBlock) block).deoptBci; | |
1560 } | |
1561 abstractMergeNode.setStateAfter(frameState.create(bci)); | |
1549 } | 1562 } |
1550 } | 1563 } |
1551 | 1564 |
1552 /** | 1565 /** |
1553 * Remove loop header without loop ends. This can happen with degenerated loops like | 1566 * Remove loop header without loop ends. This can happen with degenerated loops like |