# HG changeset patch # User Gilles Duboscq # Date 1398181101 -7200 # Node ID 0b25b81414c926c0b577e2010d8c4d77b83d7d05 # Parent cd51b1253c4ce5f161c3608f96ca083ba65d6935 Move various bci constants from FrameState (gral.nodes) to BytecodeFrame (graal.api.code) diff -r cd51b1253c4c -r 0b25b81414c9 graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/BytecodeFrame.java --- a/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/BytecodeFrame.java Tue Apr 22 15:46:06 2014 +0200 +++ b/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/BytecodeFrame.java Tue Apr 22 17:38:21 2014 +0200 @@ -94,6 +94,43 @@ public final boolean duringCall; /** + * This BCI should be used for frame states that are built for code with no meaningful BCI. + */ + public static final int UNKNOWN_BCI = -5; + + /** + * The BCI for exception unwind. This is synthetic code and has no representation in bytecode. + * In contrast with {@link #AFTER_EXCEPTION_BCI}, at this point, if the method is synchronized, + * the monitor is still held. + */ + public static final int UNWIND_BCI = -1; + + /** + * The BCI for the state before starting to execute a method. Note that if the method is + * synchronized, the monitor is not yet held. + */ + public static final int BEFORE_BCI = -2; + + /** + * The BCI for the state after finishing the execution of a method and returning normally. Note + * that if the method was synchronized the monitor is already released. + */ + public static final int AFTER_BCI = -3; + + /** + * The BCI for exception unwind. This is synthetic code and has no representation in bytecode. + * In contrast with {@link #UNWIND_BCI}, at this point, if the method is synchronized, the + * monitor is already released. + */ + public static final int AFTER_EXCEPTION_BCI = -4; + + /** + * This BCI should be used for states that cannot be the target of a deoptimization, like + * snippet frame states. + */ + public static final int INVALID_FRAMESTATE_BCI = -6; + + /** * Creates a new frame object. * * @param caller the caller frame (which may be {@code null}) diff -r cd51b1253c4c -r 0b25b81414c9 graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/DebugInfoBuilder.java --- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/DebugInfoBuilder.java Tue Apr 22 15:46:06 2014 +0200 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/DebugInfoBuilder.java Tue Apr 22 17:38:21 2014 +0200 @@ -129,7 +129,7 @@ if (state.outerFrameState() != null) { caller = computeFrameForState(state.outerFrameState()); } - assert state.bci >= FrameState.BEFORE_BCI : "bci == " + state.bci; + assert state.bci >= BytecodeFrame.BEFORE_BCI : "bci == " + state.bci; return new BytecodeFrame(caller, state.method(), state.bci, state.rethrowException(), state.duringCall(), values, numLocals, numStack, numLocks); } diff -r cd51b1253c4c -r 0b25b81414c9 graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotNodeLIRBuilder.java --- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotNodeLIRBuilder.java Tue Apr 22 15:46:06 2014 +0200 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotNodeLIRBuilder.java Tue Apr 22 17:38:21 2014 +0200 @@ -160,7 +160,7 @@ @Override public void visitInfopointNode(InfopointNode i) { - if (i.getState() != null && i.getState().bci == FrameState.AFTER_BCI) { + if (i.getState() != null && i.getState().bci == BytecodeFrame.AFTER_BCI) { Debug.log("Ignoring InfopointNode for AFTER_BCI"); } else { super.visitInfopointNode(i); diff -r cd51b1253c4c -r 0b25b81414c9 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/MonitorSnippets.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/MonitorSnippets.java Tue Apr 22 15:46:06 2014 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/MonitorSnippets.java Tue Apr 22 17:38:21 2014 +0200 @@ -511,7 +511,7 @@ callTarget = graph.add(new MethodCallTargetNode(InvokeKind.Static, checkCounter.getMethod(), new ValueNode[]{errMsg}, returnType)); invoke = graph.add(new InvokeNode(callTarget, 0)); List stack = Collections.emptyList(); - FrameState stateAfter = new FrameState(graph.method(), FrameState.AFTER_BCI, new ValueNode[0], stack, new ValueNode[0], new MonitorIdNode[0], false, false); + FrameState stateAfter = new FrameState(graph.method(), BytecodeFrame.AFTER_BCI, new ValueNode[0], stack, new ValueNode[0], new MonitorIdNode[0], false, false); invoke.setStateAfter(graph.add(stateAfter)); graph.addBeforeFixed(ret, invoke); diff -r cd51b1253c4c -r 0b25b81414c9 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 Tue Apr 22 15:46:06 2014 +0200 +++ b/graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java Tue Apr 22 17:38:21 2014 +0200 @@ -222,7 +222,7 @@ lastInstr = currentGraph.start(); if (isSynchronized(method.getModifiers())) { // add a monitor enter to the start block - currentGraph.start().setStateAfter(frameState.create(FrameState.BEFORE_BCI)); + currentGraph.start().setStateAfter(frameState.create(BytecodeFrame.BEFORE_BCI)); methodSynchronizedObject = synchronizedObject(frameState, method); lastInstr = genMonitorEnter(methodSynchronizedObject); } @@ -290,7 +290,7 @@ unwindBlock = new ExceptionDispatchBlock(); unwindBlock.startBci = -1; unwindBlock.endBci = -1; - unwindBlock.deoptBci = FrameState.UNWIND_BCI; + unwindBlock.deoptBci = BytecodeFrame.UNWIND_BCI; unwindBlock.setId(Integer.MAX_VALUE); } return unwindBlock; @@ -410,7 +410,7 @@ } private DispatchBeginNode handleException(ValueNode exceptionObject, int bci) { - assert bci == FrameState.BEFORE_BCI || bci == bci() : "invalid bci"; + assert bci == BytecodeFrame.BEFORE_BCI || bci == bci() : "invalid bci"; Debug.log("Creating exception dispatch edges at %d, exception object=%s, exception seen=%s", bci, exceptionObject, profilingInfo.getExceptionSeen(bci)); BciBlock dispatchBlock = currentBlock.exceptionDispatchBlock(); @@ -817,7 +817,7 @@ append(new InfopointNode(InfopointReason.METHOD_END, frameState.create(bci()))); } - synchronizedEpilogue(FrameState.AFTER_BCI, x); + synchronizedEpilogue(BytecodeFrame.AFTER_BCI, x); if (frameState.lockDepth() != 0) { throw new BailoutException("unbalanced monitors"); } @@ -1157,7 +1157,7 @@ assert frameState.stackSize() == 1 : frameState; ValueNode exception = frameState.apop(); append(new FixedGuardNode(currentGraph.unique(new IsNullNode(exception)), NullCheckException, InvalidateReprofile, true)); - synchronizedEpilogue(FrameState.AFTER_EXCEPTION_BCI, null); + synchronizedEpilogue(BytecodeFrame.AFTER_EXCEPTION_BCI, null); append(new UnwindNode(exception)); } diff -r cd51b1253c4c -r 0b25b81414c9 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/FrameState.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/FrameState.java Tue Apr 22 15:46:06 2014 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/FrameState.java Tue Apr 22 17:38:21 2014 +0200 @@ -51,41 +51,6 @@ private boolean duringCall; - /** - * This BCI should be used for frame states that are built for code with no meaningful BCI. - */ - public static final int UNKNOWN_BCI = -5; - - /** - * The BCI for the exception unwind block, i.e., the block containing the {@link UnwindNode}. - * This block and node is synthetic and has no representation in bytecode. - */ - public static final int UNWIND_BCI = -1; - - /** - * When a node whose frame state has this BCI value is inlined, its frame state will be replaced - * with the frame state before the inlined invoke node. - */ - public static final int BEFORE_BCI = -2; - - /** - * When a node whose frame state has this BCI value is inlined, its frame state will be replaced - * with the frame state {@linkplain Invoke#stateAfter() after} the inlined invoke node. - */ - public static final int AFTER_BCI = -3; - - /** - * When a node whose frame state has this BCI value is inlined, its frame state will be replaced - * with the frame state at the exception edge of the inlined invoke node. - */ - public static final int AFTER_EXCEPTION_BCI = -4; - - /** - * This BCI should be used for frame states that cannot be the target of a deoptimization, like - * snippet frame states. - */ - public static final int INVALID_FRAMESTATE_BCI = -6; - @Input(InputType.State) private FrameState outerFrameState; /** @@ -141,7 +106,8 @@ */ public FrameState(int bci) { this(null, bci, Collections. emptyList(), 0, 0, false, false, Collections. emptyList(), Collections. emptyList()); - assert bci == BEFORE_BCI || bci == AFTER_BCI || bci == AFTER_EXCEPTION_BCI || bci == UNKNOWN_BCI || bci == INVALID_FRAMESTATE_BCI; + assert bci == BytecodeFrame.BEFORE_BCI || bci == BytecodeFrame.AFTER_BCI || bci == BytecodeFrame.AFTER_EXCEPTION_BCI || bci == BytecodeFrame.UNKNOWN_BCI || + bci == BytecodeFrame.INVALID_FRAMESTATE_BCI; } public FrameState(ResolvedJavaMethod method, int bci, ValueNode[] locals, List stack, ValueNode[] locks, MonitorIdNode[] monitorIds, boolean rethrowException, boolean duringCall) { diff -r cd51b1253c4c -r 0b25b81414c9 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/MonitorExitNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/MonitorExitNode.java Tue Apr 22 15:46:06 2014 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/MonitorExitNode.java Tue Apr 22 17:38:21 2014 +0200 @@ -22,6 +22,7 @@ */ package com.oracle.graal.nodes.java; +import com.oracle.graal.api.code.*; import com.oracle.graal.api.meta.*; import com.oracle.graal.graph.*; import com.oracle.graal.graph.spi.*; @@ -58,7 +59,7 @@ @Override public void simplify(SimplifierTool tool) { - if (escapedReturnValue != null && stateAfter() != null && stateAfter().bci != FrameState.AFTER_BCI) { + if (escapedReturnValue != null && stateAfter() != null && stateAfter().bci != BytecodeFrame.AFTER_BCI) { ValueNode returnValue = escapedReturnValue; setEscapedReturnValue(null); tool.removeIfUnused(returnValue); @@ -74,7 +75,7 @@ public void virtualize(VirtualizerTool tool) { State state = tool.getObjectState(object()); // the monitor exit for a synchronized method should never be virtualized - assert stateAfter().bci != FrameState.AFTER_BCI || state == null; + assert stateAfter().bci != BytecodeFrame.AFTER_BCI || state == null; if (state != null && state.getState() == EscapeState.Virtual && state.getVirtualObject().hasIdentity()) { MonitorIdNode removedLock = state.removeLock(); assert removedLock == getMonitorId() : "mismatch at " + this + ": " + removedLock + " vs. " + getMonitorId(); diff -r cd51b1253c4c -r 0b25b81414c9 graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/InliningUtil.java --- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/InliningUtil.java Tue Apr 22 15:46:06 2014 +0200 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/InliningUtil.java Tue Apr 22 17:38:21 2014 +0200 @@ -1406,7 +1406,7 @@ // "after exception" frame state // (because there is no "after exception" frame state!) if (monitorExit != null) { - if (monitorExit.stateAfter() != null && monitorExit.stateAfter().bci == FrameState.AFTER_EXCEPTION_BCI) { + if (monitorExit.stateAfter() != null && monitorExit.stateAfter().bci == BytecodeFrame.AFTER_EXCEPTION_BCI) { FrameState monitorFrameState = monitorExit.stateAfter(); graph.removeFixed(monitorExit); monitorFrameState.safeDelete(); @@ -1421,11 +1421,11 @@ for (FrameState original : inlineGraph.getNodes(FrameState.class)) { FrameState frameState = (FrameState) duplicates.get(original); if (frameState != null) { - assert frameState.bci != FrameState.BEFORE_BCI : frameState; - if (frameState.bci == FrameState.AFTER_BCI) { + assert frameState.bci != BytecodeFrame.BEFORE_BCI : frameState; + if (frameState.bci == BytecodeFrame.AFTER_BCI) { frameState.replaceAndDelete(returnKind == Kind.Void ? stateAfter : stateAfter.duplicateModified(stateAfter.bci, stateAfter.rethrowException(), returnKind, frameState.stackAt(0))); - } else if (frameState.bci == FrameState.AFTER_EXCEPTION_BCI) { + } else if (frameState.bci == BytecodeFrame.AFTER_EXCEPTION_BCI) { if (frameState.isAlive()) { assert stateAtExceptionEdge != null; frameState.replaceAndDelete(stateAtExceptionEdge); @@ -1435,7 +1435,7 @@ } else { // only handle the outermost frame states if (frameState.outerFrameState() == null) { - assert frameState.bci == FrameState.INVALID_FRAMESTATE_BCI || frameState.method().equals(inlineGraph.method()); + assert frameState.bci == BytecodeFrame.INVALID_FRAMESTATE_BCI || frameState.method().equals(inlineGraph.method()); if (outerFrameState == null) { outerFrameState = stateAfter.duplicateModified(invoke.bci(), stateAfter.rethrowException(), invokeNode.getKind()); outerFrameState.setDuringCall(true); @@ -1507,7 +1507,7 @@ for (Node node : duplicates.values()) { if (node instanceof FrameState) { FrameState frameState = (FrameState) node; - assert frameState.bci == FrameState.AFTER_BCI || frameState.bci == FrameState.INVALID_FRAMESTATE_BCI : node.toString(Verbosity.Debugger); + assert frameState.bci == BytecodeFrame.AFTER_BCI || frameState.bci == BytecodeFrame.INVALID_FRAMESTATE_BCI : node.toString(Verbosity.Debugger); } } return true; diff -r cd51b1253c4c -r 0b25b81414c9 graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/ObjectAccessTest.java --- a/graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/ObjectAccessTest.java Tue Apr 22 15:46:06 2014 +0200 +++ b/graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/ObjectAccessTest.java Tue Apr 22 17:38:21 2014 +0200 @@ -127,7 +127,7 @@ JavaWriteNode write = (JavaWriteNode) graph.start().next(); Assert.assertEquals(graph.getParameter(2), write.value()); Assert.assertEquals(graph.getParameter(0), write.object()); - Assert.assertEquals(FrameState.AFTER_BCI, write.stateAfter().bci); + Assert.assertEquals(BytecodeFrame.AFTER_BCI, write.stateAfter().bci); IndexedLocationNode location = (IndexedLocationNode) write.location(); Assert.assertEquals(kind, location.getValueKind()); diff -r cd51b1253c4c -r 0b25b81414c9 graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/PointerTest.java --- a/graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/PointerTest.java Tue Apr 22 15:46:06 2014 +0200 +++ b/graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/PointerTest.java Tue Apr 22 17:38:21 2014 +0200 @@ -139,7 +139,7 @@ JavaWriteNode write = (JavaWriteNode) cast.next(); Assert.assertEquals(graph.getParameter(2), write.value()); - Assert.assertEquals(FrameState.AFTER_BCI, write.stateAfter().bci); + Assert.assertEquals(BytecodeFrame.AFTER_BCI, write.stateAfter().bci); Assert.assertEquals(cast, write.object()); Assert.assertEquals(graph.getParameter(0), cast.getInput()); diff -r cd51b1253c4c -r 0b25b81414c9 graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/CollapseFrameForSingleSideEffectPhase.java --- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/CollapseFrameForSingleSideEffectPhase.java Tue Apr 22 15:46:06 2014 +0200 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/CollapseFrameForSingleSideEffectPhase.java Tue Apr 22 17:38:21 2014 +0200 @@ -24,6 +24,7 @@ import java.util.*; +import com.oracle.graal.api.code.*; import com.oracle.graal.graph.*; import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.util.*; @@ -33,12 +34,12 @@ import com.oracle.graal.phases.graph.ReentrantNodeIterator.NodeIteratorClosure; /** - * This phase ensures that there's a single {@linkplain FrameState#AFTER_BCI collapsed frame state} - * per path. + * This phase ensures that there's a single {@linkplain BytecodeFrame#AFTER_BCI collapsed frame + * state} per path. * * Removes other frame states from {@linkplain StateSplit#hasSideEffect() non-side-effecting} nodes - * in the graph, and replaces them with {@linkplain FrameState#INVALID_FRAMESTATE_BCI invalid frame - * states}. + * in the graph, and replaces them with {@linkplain BytecodeFrame#INVALID_FRAMESTATE_BCI invalid + * frame states}. * * The invalid frame states ensure that no deoptimization to a snippet frame state will happen. */ @@ -176,7 +177,7 @@ if (!unwindSideEffects.contains(returnSideEffect) && !maskedSideEffects.contains(returnSideEffect)) { StateSplit split = (StateSplit) returnSideEffect; if (split.stateAfter() != null) { - split.setStateAfter(graph.add(new FrameState(FrameState.AFTER_BCI))); + split.setStateAfter(graph.add(new FrameState(BytecodeFrame.AFTER_BCI))); } } } @@ -185,7 +186,7 @@ if (!returnSideEffects.contains(unwindSideEffect) && !maskedSideEffects.contains(unwindSideEffect)) { StateSplit split = (StateSplit) unwindSideEffect; if (split.stateAfter() != null) { - split.setStateAfter(graph.add(new FrameState(FrameState.AFTER_EXCEPTION_BCI))); + split.setStateAfter(graph.add(new FrameState(BytecodeFrame.AFTER_EXCEPTION_BCI))); } } } @@ -214,7 +215,7 @@ } private static FrameState createInvalidFrameState(FixedNode node) { - return node.graph().add(new FrameState(FrameState.INVALID_FRAMESTATE_BCI)); + return node.graph().add(new FrameState(BytecodeFrame.INVALID_FRAMESTATE_BCI)); } } } diff -r cd51b1253c4c -r 0b25b81414c9 graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/GraphKit.java --- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/GraphKit.java Tue Apr 22 15:46:06 2014 +0200 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/GraphKit.java Tue Apr 22 17:38:21 2014 +0200 @@ -96,7 +96,7 @@ } public InvokeNode createInvoke(Class declaringClass, String name, ValueNode... args) { - return createInvoke(declaringClass, name, InvokeKind.Static, null, FrameState.UNKNOWN_BCI, args); + return createInvoke(declaringClass, name, InvokeKind.Static, null, BytecodeFrame.UNKNOWN_BCI, args); } /** diff -r cd51b1253c4c -r 0b25b81414c9 graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/MacroNode.java --- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/MacroNode.java Tue Apr 22 15:46:06 2014 +0200 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/MacroNode.java Tue Apr 22 17:38:21 2014 +0200 @@ -24,6 +24,7 @@ import static java.lang.reflect.Modifier.*; +import com.oracle.graal.api.code.*; import com.oracle.graal.api.meta.*; import com.oracle.graal.compiler.common.*; import com.oracle.graal.debug.*; @@ -89,7 +90,7 @@ StructuredGraph methodSubstitution = tool.getReplacements().getMethodSubstitution(getTargetMethod()); if (methodSubstitution != null) { methodSubstitution = methodSubstitution.copy(); - if (stateAfter() == null || stateAfter().bci == FrameState.AFTER_BCI) { + if (stateAfter() == null || stateAfter().bci == BytecodeFrame.AFTER_BCI) { /* * handles the case of a MacroNode inside a snippet used for another MacroNode * lowering @@ -173,7 +174,7 @@ if (!call.targetMethod().equals(getTargetMethod())) { throw new GraalInternalError("unexpected invoke %s in snippet", getClass().getSimpleName()); } - assert invoke.stateAfter().bci == FrameState.AFTER_BCI; + assert invoke.stateAfter().bci == BytecodeFrame.AFTER_BCI; // Here we need to fix the bci of the invoke InvokeNode newInvoke = snippetGraph.add(new InvokeNode(invoke.callTarget(), getBci())); newInvoke.setStateAfter(invoke.stateAfter());