# HG changeset patch # User Thomas Wuerthinger # Date 1424279442 -3600 # Node ID b0ba6f39cb6052120c304a0d1f4c380a6d60d696 # Parent ff67cb313c9a56680149f4bfa6381ce97e742259 Allocate unwind and return block in bci block mapping instead of the graph builder and give them proper ids. diff -r ff67cb313c9a -r b0ba6f39cb60 graal/com.oracle.graal.java/src/com/oracle/graal/java/BciBlockMapping.java --- 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; } diff -r ff67cb313c9a -r b0ba6f39cb60 graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java --- 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; }