# HG changeset patch # User Erik Eckstein # Date 1395825315 -3600 # Node ID c612c2742a4fcb2c0fdabf24e820ca2ab41811ff # Parent 91c88fc2157c79a374fc9ee0f866909edcda1b48 extend graph builder and CompilationResult for substrateVM diff -r 91c88fc2157c -r c612c2742a4f graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/CompilationResult.java --- a/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/CompilationResult.java Wed Mar 26 10:10:12 2014 +0100 +++ b/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/CompilationResult.java Wed Mar 26 10:15:15 2014 +0100 @@ -602,7 +602,15 @@ addInfopoint(new Infopoint(codePos, debugInfo, reason)); } - private void addInfopoint(Infopoint infopoint) { + /** + * Records a custom infopoint in the code section. + * + * Compiler implementations can use this method to record non-standard infopoints, which are not + * handled by the dedicated methods like {@link #recordCall}. + * + * @param infopoint the infopoint to record, usually a derived class from {@link Infopoint} + */ + public void addInfopoint(Infopoint infopoint) { // The infopoints list must always be sorted if (!infopoints.isEmpty() && infopoints.get(infopoints.size() - 1).pcOffset >= infopoint.pcOffset) { // This re-sorting should be very rare diff -r 91c88fc2157c -r c612c2742a4f graal/com.oracle.graal.java/src/com/oracle/graal/java/FrameStateBuilder.java --- a/graal/com.oracle.graal.java/src/com/oracle/graal/java/FrameStateBuilder.java Wed Mar 26 10:10:12 2014 +0100 +++ b/graal/com.oracle.graal.java/src/com/oracle/graal/java/FrameStateBuilder.java Wed Mar 26 10:15:15 2014 +0100 @@ -386,6 +386,10 @@ return stack[i]; } + public final ValueNode lockAt(int i) { + return lockedObjects[i]; + } + /** * Adds a locked monitor to this frame state. * @@ -470,6 +474,11 @@ stack[i] = x; } + public void storeLock(int i, ValueNode x) { + assert x == null || x.isAlive() && (lockedObjects[i] == null || x.getKind() == lockedObjects[i].getKind()) : "unexpected lock value: " + x; + lockedObjects[i] = x; + } + /** * Pushes an instruction onto the stack with the expected type. * diff -r 91c88fc2157c -r c612c2742a4f 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 Mar 26 10:10:12 2014 +0100 +++ b/graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java Wed Mar 26 10:15:15 2014 +0100 @@ -139,7 +139,7 @@ * the jump. When the block is seen the second time, a {@link MergeNode} is created to * correctly merge the now two different predecessor states. */ - private static class BlockPlaceholderNode extends FixedWithNextNode { + protected static class BlockPlaceholderNode extends FixedWithNextNode { /* * Cannot be explicitly declared as a Node type since it is not an input; would cause @@ -238,6 +238,7 @@ } frameState.clearNonLiveLocals(blockMap.startBlock, liveness, true); ((StateSplit) lastInstr).setStateAfter(frameState.create(0)); + finishPrepare(lastInstr); if (graphBuilderConfig.eagerInfopointMode()) { InfopointNode ipn = currentGraph.add(new InfopointNode(InfopointReason.METHOD_START, frameState.create(0))); @@ -285,6 +286,15 @@ indent.outdent(); } + /** + * A hook for derived classes to modify the graph start instruction or append new + * instructions to it. + * + * @param startInstr The start instruction of the graph. + */ + protected void finishPrepare(FixedWithNextNode startInstr) { + } + private Block unwindBlock(int bci) { if (unwindBlock == null) { unwindBlock = new ExceptionDispatchBlock(); @@ -454,7 +464,7 @@ dispatchState.setRethrowException(true); } FixedNode target = createTarget(dispatchBlock, dispatchState); - dispatchBegin.setNext(target); + finishInstruction(dispatchBegin, dispatchState).setNext(target); return dispatchBegin; } @@ -1754,6 +1764,8 @@ assert lastInstr.next() == null : "instructions already appended at block " + block; Debug.log(" frameState: %s", frameState); + lastInstr = finishInstruction(lastInstr, frameState); + int endBCI = stream.endBCI(); stream.setBCI(block.startBci); @@ -1803,6 +1815,7 @@ } } } + lastInstr = finishInstruction(lastInstr, frameState); if (bci < endBCI) { if (bci > block.endBci) { assert !block.successors.get(0).isExceptionEntry; @@ -1815,6 +1828,17 @@ } } + /** + * A hook for derived classes to modify the last instruction or add other instructions. + * + * @param instr The last instruction (= fixed node) which was added. + * @param state The current frame state. + * @Returns Returns the (new) last instruction. + */ + protected FixedWithNextNode finishInstruction(FixedWithNextNode instr, FrameStateBuilder state) { + return instr; + } + private final int traceLevel = Options.TraceBytecodeParserLevel.getValue(); private void traceState() {