Mercurial > hg > graal-compiler
changeset 19481:b0ba6f39cb60
Allocate unwind and return block in bci block mapping instead of the graph builder and give them proper ids.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Wed, 18 Feb 2015 18:10:42 +0100 |
parents | ff67cb313c9a |
children | 63965fcb019b |
files | graal/com.oracle.graal.java/src/com/oracle/graal/java/BciBlockMapping.java graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java |
diffstat | 2 files changed, 23 insertions(+), 22 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.graal.java/src/com/oracle/graal/java/BciBlockMapping.java Wed Feb 18 17:59:18 2015 +0100 +++ b/graal/com.oracle.graal.java/src/com/oracle/graal/java/BciBlockMapping.java Wed Feb 18 18:10:42 2015 +0100 @@ -474,9 +474,7 @@ assert verify(); - // Discard big arrays so that they can be GCed startBlock = blockMap[0]; - blockMap = null; if (Debug.isLogEnabled()) { this.log(blockMap, "Before LivenessAnalysis"); } @@ -819,17 +817,9 @@ throw new BailoutException("Non-reducible loop"); } - if (blocks[0] != null && this.nextLoop == 0) { - // No unreached blocks and no loops - for (int i = 0; i < blocks.length; ++i) { - blocks[i].setId(i); - } - return; - } - // Purge null entries for unreached blocks and sort blocks such that loop bodies are always // consecutively in the array. - int blockCount = maxBlocks - blocksNotYetAssignedId; + int blockCount = maxBlocks - blocksNotYetAssignedId + 2; BciBlock[] newBlocks = new BciBlock[blockCount]; int next = 0; for (int i = 0; i < blocks.length; ++i) { @@ -842,6 +832,18 @@ } } } + + // Add return block. + BciBlock returnBlock = new BciBlock(); + returnBlock.setId(newBlocks.length - 2); + newBlocks[newBlocks.length - 2] = returnBlock; + + // Add unwind block. + ExceptionDispatchBlock unwindBlock = new ExceptionDispatchBlock(); + unwindBlock.deoptBci = method.isSynchronized() ? BytecodeFrame.UNWIND_BCI : BytecodeFrame.AFTER_EXCEPTION_BCI; + unwindBlock.setId(newBlocks.length - 1); + newBlocks[newBlocks.length - 1] = unwindBlock; + blocks = newBlocks; } @@ -1047,6 +1049,14 @@ return startBlock; } + public BciBlock getReturnBlock() { + return blocks[blocks.length - 2]; + } + + public ExceptionDispatchBlock getUnwindBlock() { + return (ExceptionDispatchBlock) blocks[blocks.length - 1]; + } + public int getLoopCount() { return nextLoop; }
--- a/graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java Wed Feb 18 17:59:18 2015 +0100 +++ b/graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java Wed Feb 18 18:10:42 2015 +0100 @@ -299,12 +299,12 @@ int index = 0; BciBlock[] blocks = blockMap.getBlocks(); + this.returnBlock = blockMap.getReturnBlock(); + this.unwindBlock = blockMap.getUnwindBlock(); while (index < blocks.length) { BciBlock block = blocks[index]; index = iterateBlock(blocks, block); } - processBlock(this, returnBlock); - processBlock(this, unwindBlock); if (Debug.isDumpEnabled() && this.beforeReturnNode != startInstruction) { Debug.dump(currentGraph, "Bytecodes parsed: " + method.getDeclaringClass().getUnqualifiedName() + "." + method.getName()); @@ -355,19 +355,10 @@ } private BciBlock returnBlock() { - if (returnBlock == null) { - returnBlock = new BciBlock(); - returnBlock.setId(Integer.MAX_VALUE); - } return returnBlock; } private BciBlock unwindBlock() { - if (unwindBlock == null) { - unwindBlock = new ExceptionDispatchBlock(); - unwindBlock.deoptBci = method.isSynchronized() ? BytecodeFrame.UNWIND_BCI : BytecodeFrame.AFTER_EXCEPTION_BCI; - unwindBlock.setId(Integer.MAX_VALUE); - } return unwindBlock; }