Search in sources :

Example 56 with FrameState

use of org.graalvm.compiler.nodes.FrameState in project graal by oracle.

the class BytecodeParser method genPutStatic.

protected void genPutStatic(JavaField field) {
    ValueNode value = frameState.pop(field.getJavaKind());
    ResolvedJavaField resolvedField = resolveStaticFieldAccess(field, value);
    if (resolvedField == null) {
        return;
    }
    if (!parsingIntrinsic() && GeneratePIC.getValue(getOptions())) {
        graph.recordField(resolvedField);
    }
    ClassInitializationPlugin classInitializationPlugin = this.graphBuilderConfig.getPlugins().getClassInitializationPlugin();
    if (classInitializationPlugin != null && classInitializationPlugin.shouldApply(this, resolvedField.getDeclaringClass())) {
        FrameState stateBefore = frameState.create(bci(), getNonIntrinsicAncestor(), false, null, null);
        classInitializationPlugin.apply(this, resolvedField.getDeclaringClass(), stateBefore);
    }
    for (NodePlugin plugin : graphBuilderConfig.getPlugins().getNodePlugins()) {
        if (plugin.handleStoreStaticField(this, resolvedField, value)) {
            return;
        }
    }
    genStoreField(null, resolvedField, value);
}
Also used : NodePlugin(org.graalvm.compiler.nodes.graphbuilderconf.NodePlugin) ValueNode(org.graalvm.compiler.nodes.ValueNode) FrameState(org.graalvm.compiler.nodes.FrameState) ClassInitializationPlugin(org.graalvm.compiler.nodes.graphbuilderconf.ClassInitializationPlugin) ResolvedJavaField(jdk.vm.ci.meta.ResolvedJavaField)

Example 57 with FrameState

use of org.graalvm.compiler.nodes.FrameState in project graal by oracle.

the class FrameStateBuilder method create.

/**
 * @param pushedValues if non-null, values to {@link #push(JavaKind, ValueNode)} to the stack
 *            before creating the {@link FrameState}
 */
public FrameState create(int bci, BytecodeParser parent, boolean duringCall, JavaKind[] pushedSlotKinds, ValueNode[] pushedValues) {
    if (outerFrameState == null && parent != null) {
        assert !parent.parsingIntrinsic() : "must already have the next non-intrinsic ancestor";
        outerFrameState = parent.getFrameStateBuilder().create(parent.bci(), parent.getNonIntrinsicAncestor(), true, null, null);
    }
    if (bci == BytecodeFrame.AFTER_EXCEPTION_BCI && parent != null) {
        FrameState newFrameState = outerFrameState.duplicateModified(outerFrameState.bci, true, false, JavaKind.Void, new JavaKind[] { JavaKind.Object }, new ValueNode[] { stack[0] });
        return newFrameState;
    }
    if (bci == BytecodeFrame.INVALID_FRAMESTATE_BCI) {
        throw shouldNotReachHere();
    }
    if (pushedValues != null) {
        assert pushedSlotKinds.length == pushedValues.length;
        int stackSizeToRestore = stackSize;
        for (int i = 0; i < pushedValues.length; i++) {
            push(pushedSlotKinds[i], pushedValues[i]);
        }
        FrameState res = graph.add(new FrameState(outerFrameState, code, bci, locals, stack, stackSize, lockedObjects, Arrays.asList(monitorIds), rethrowException, duringCall));
        stackSize = stackSizeToRestore;
        return res;
    } else {
        if (bci == BytecodeFrame.AFTER_EXCEPTION_BCI) {
            assert outerFrameState == null;
            clearLocals();
        }
        return graph.add(new FrameState(outerFrameState, code, bci, locals, stack, stackSize, lockedObjects, Arrays.asList(monitorIds), rethrowException, duringCall));
    }
}
Also used : FrameState(org.graalvm.compiler.nodes.FrameState)

Example 58 with FrameState

use of org.graalvm.compiler.nodes.FrameState in project graal by oracle.

the class SubstrateIntrinsicGraphBuilder method setStateAfter.

@Override
public void setStateAfter(StateSplit sideEffect) {
    List<ValueNode> values = new ArrayList<>(Arrays.asList(arguments));
    int stackSize = 0;
    if (returnValue != null) {
        values.add(returnValue);
        stackSize++;
        if (method.getSignature().getReturnKind().needsTwoSlots()) {
            values.add(null);
            stackSize++;
        }
    }
    FrameState stateAfter = getGraph().add(new FrameState(null, code, bci, values, arguments.length, stackSize, false, false, null, null));
    sideEffect.setStateAfter(stateAfter);
    bci++;
}
Also used : ValueNode(org.graalvm.compiler.nodes.ValueNode) ArrayList(java.util.ArrayList) FrameState(org.graalvm.compiler.nodes.FrameState)

Example 59 with FrameState

use of org.graalvm.compiler.nodes.FrameState in project graal by oracle.

the class CallTreePrinter method sourceReference.

private static SourceReference[] sourceReference(InvokeTypeFlow invoke) {
    List<SourceReference> sourceReference = new ArrayList<>();
    FrameState state = invoke.getSource().invoke().stateAfter();
    while (state != null) {
        if (state.getCode() != null) {
            sourceReference.add(new SourceReference(state.bci, state.getCode().asStackTraceElement(state.bci)));
        } else {
            sourceReference.add(UNKNOWN_SOURCE_REFERENCE);
        }
        state = state.outerFrameState();
    }
    return sourceReference.toArray(new SourceReference[sourceReference.size()]);
}
Also used : ArrayList(java.util.ArrayList) FrameState(org.graalvm.compiler.nodes.FrameState)

Example 60 with FrameState

use of org.graalvm.compiler.nodes.FrameState in project graal by oracle.

the class GraphUtil method approxSourceStackTraceElement.

/**
 * Gets an approximate source code location for frame state.
 *
 * @return the StackTraceElements if an approximate source location is found, null otherwise
 */
public static StackTraceElement[] approxSourceStackTraceElement(FrameState frameState) {
    ArrayList<StackTraceElement> elements = new ArrayList<>();
    FrameState state = frameState;
    while (state != null) {
        Bytecode code = state.getCode();
        if (code != null) {
            elements.add(code.asStackTraceElement(state.bci - 1));
        }
        state = state.outerFrameState();
    }
    return elements.toArray(new StackTraceElement[0]);
}
Also used : ArrayList(java.util.ArrayList) Bytecode(org.graalvm.compiler.bytecode.Bytecode) FrameState(org.graalvm.compiler.nodes.FrameState)

Aggregations

FrameState (org.graalvm.compiler.nodes.FrameState)73 ValueNode (org.graalvm.compiler.nodes.ValueNode)38 Node (org.graalvm.compiler.graph.Node)27 FixedNode (org.graalvm.compiler.nodes.FixedNode)21 AbstractMergeNode (org.graalvm.compiler.nodes.AbstractMergeNode)19 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)19 AbstractBeginNode (org.graalvm.compiler.nodes.AbstractBeginNode)16 ParameterNode (org.graalvm.compiler.nodes.ParameterNode)16 PhiNode (org.graalvm.compiler.nodes.PhiNode)16 EndNode (org.graalvm.compiler.nodes.EndNode)15 MethodCallTargetNode (org.graalvm.compiler.nodes.java.MethodCallTargetNode)15 FixedWithNextNode (org.graalvm.compiler.nodes.FixedWithNextNode)14 MergeNode (org.graalvm.compiler.nodes.MergeNode)14 ReturnNode (org.graalvm.compiler.nodes.ReturnNode)13 InvokeWithExceptionNode (org.graalvm.compiler.nodes.InvokeWithExceptionNode)12 StateSplit (org.graalvm.compiler.nodes.StateSplit)12 MonitorIdNode (org.graalvm.compiler.nodes.java.MonitorIdNode)12 DebugContext (org.graalvm.compiler.debug.DebugContext)11 AbstractEndNode (org.graalvm.compiler.nodes.AbstractEndNode)11 DeoptimizeNode (org.graalvm.compiler.nodes.DeoptimizeNode)11