Search in sources :

Example 6 with MonitorExitNode

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

the class InliningUtil method handleAfterBciFrameState.

private static FrameState handleAfterBciFrameState(FrameState frameState, Invoke invoke, boolean alwaysDuplicateStateAfter) {
    FrameState stateAtReturn = invoke.stateAfter();
    JavaKind invokeReturnKind = invoke.asNode().getStackKind();
    FrameState stateAfterReturn = stateAtReturn;
    if (frameState.getCode() == null) {
        // that was parsed for post-parse intrinsification
        for (Node usage : frameState.usages()) {
            if (usage instanceof ForeignCallNode) {
                // A foreign call inside an intrinsic needs to have
                // the BCI of the invoke being intrinsified
                ForeignCallNode foreign = (ForeignCallNode) usage;
                foreign.setBci(invoke.bci());
            }
        }
    }
    // value (top of stack)
    assert !frameState.rethrowException() : frameState;
    if (frameState.stackSize() > 0 && (alwaysDuplicateStateAfter || stateAfterReturn.stackAt(0) != frameState.stackAt(0))) {
        // A non-void return value.
        stateAfterReturn = stateAtReturn.duplicateModified(invokeReturnKind, invokeReturnKind, frameState.stackAt(0));
    } else {
        // A void return value.
        stateAfterReturn = stateAtReturn.duplicate();
    }
    assert stateAfterReturn.bci != BytecodeFrame.UNKNOWN_BCI;
    // Return value does no longer need to be limited by the monitor exit.
    for (MonitorExitNode n : frameState.usages().filter(MonitorExitNode.class)) {
        n.clearEscapedReturnValue();
    }
    frameState.replaceAndDelete(stateAfterReturn);
    return stateAfterReturn;
}
Also used : ForeignCallNode(org.graalvm.compiler.nodes.extended.ForeignCallNode) AbstractMergeNode(org.graalvm.compiler.nodes.AbstractMergeNode) BeginNode(org.graalvm.compiler.nodes.BeginNode) MonitorIdNode(org.graalvm.compiler.nodes.java.MonitorIdNode) MethodCallTargetNode(org.graalvm.compiler.nodes.java.MethodCallTargetNode) ReturnNode(org.graalvm.compiler.nodes.ReturnNode) CallTargetNode(org.graalvm.compiler.nodes.CallTargetNode) AbstractBeginNode(org.graalvm.compiler.nodes.AbstractBeginNode) FixedGuardNode(org.graalvm.compiler.nodes.FixedGuardNode) PiNode(org.graalvm.compiler.nodes.PiNode) LogicNode(org.graalvm.compiler.nodes.LogicNode) ValueNode(org.graalvm.compiler.nodes.ValueNode) MonitorExitNode(org.graalvm.compiler.nodes.java.MonitorExitNode) IsNullNode(org.graalvm.compiler.nodes.calc.IsNullNode) GuardingNode(org.graalvm.compiler.nodes.extended.GuardingNode) KillingBeginNode(org.graalvm.compiler.nodes.KillingBeginNode) StartNode(org.graalvm.compiler.nodes.StartNode) InvokeWithExceptionNode(org.graalvm.compiler.nodes.InvokeWithExceptionNode) ExceptionObjectNode(org.graalvm.compiler.nodes.java.ExceptionObjectNode) InvokeNode(org.graalvm.compiler.nodes.InvokeNode) ParameterNode(org.graalvm.compiler.nodes.ParameterNode) MergeNode(org.graalvm.compiler.nodes.MergeNode) DeoptimizeNode(org.graalvm.compiler.nodes.DeoptimizeNode) FixedNode(org.graalvm.compiler.nodes.FixedNode) AbstractEndNode(org.graalvm.compiler.nodes.AbstractEndNode) UnwindNode(org.graalvm.compiler.nodes.UnwindNode) Node(org.graalvm.compiler.graph.Node) EndNode(org.graalvm.compiler.nodes.EndNode) ForeignCallNode(org.graalvm.compiler.nodes.extended.ForeignCallNode) FixedWithNextNode(org.graalvm.compiler.nodes.FixedWithNextNode) PhiNode(org.graalvm.compiler.nodes.PhiNode) FrameState(org.graalvm.compiler.nodes.FrameState) MonitorExitNode(org.graalvm.compiler.nodes.java.MonitorExitNode) JavaKind(jdk.vm.ci.meta.JavaKind)

Example 7 with MonitorExitNode

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

the class LockEliminationPhase method run.

@Override
protected void run(StructuredGraph graph) {
    for (MonitorExitNode monitorExitNode : graph.getNodes(MonitorExitNode.TYPE)) {
        FixedNode next = monitorExitNode.next();
        if ((next instanceof MonitorEnterNode || next instanceof RawMonitorEnterNode)) {
            // start
            assert !(next instanceof OSRMonitorEnterNode);
            AccessMonitorNode monitorEnterNode = (AccessMonitorNode) next;
            if (GraphUtil.unproxify(monitorEnterNode.object()) == GraphUtil.unproxify(monitorExitNode.object())) {
                /*
                     * We've coarsened the lock so use the same monitor id for the whole region,
                     * otherwise the monitor operations appear to be unrelated.
                     */
                MonitorIdNode enterId = monitorEnterNode.getMonitorId();
                MonitorIdNode exitId = monitorExitNode.getMonitorId();
                if (enterId != exitId) {
                    enterId.replaceAndDelete(exitId);
                }
                GraphUtil.removeFixedWithUnusedInputs(monitorEnterNode);
                GraphUtil.removeFixedWithUnusedInputs(monitorExitNode);
            }
        }
    }
}
Also used : OSRMonitorEnterNode(org.graalvm.compiler.nodes.extended.OSRMonitorEnterNode) MonitorIdNode(org.graalvm.compiler.nodes.java.MonitorIdNode) AccessMonitorNode(org.graalvm.compiler.nodes.java.AccessMonitorNode) OSRMonitorEnterNode(org.graalvm.compiler.nodes.extended.OSRMonitorEnterNode) RawMonitorEnterNode(org.graalvm.compiler.nodes.java.RawMonitorEnterNode) MonitorEnterNode(org.graalvm.compiler.nodes.java.MonitorEnterNode) FixedNode(org.graalvm.compiler.nodes.FixedNode) MonitorExitNode(org.graalvm.compiler.nodes.java.MonitorExitNode) RawMonitorEnterNode(org.graalvm.compiler.nodes.java.RawMonitorEnterNode)

Aggregations

MonitorExitNode (org.graalvm.compiler.nodes.java.MonitorExitNode)7 ValueNode (org.graalvm.compiler.nodes.ValueNode)5 MonitorIdNode (org.graalvm.compiler.nodes.java.MonitorIdNode)5 JavaConstant (jdk.vm.ci.meta.JavaConstant)3 FixedNode (org.graalvm.compiler.nodes.FixedNode)3 LogicNode (org.graalvm.compiler.nodes.LogicNode)3 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)3 MonitorEnterNode (org.graalvm.compiler.nodes.java.MonitorEnterNode)3 Node (org.graalvm.compiler.graph.Node)2 ConstantNode (org.graalvm.compiler.nodes.ConstantNode)2 InvokeWithExceptionNode (org.graalvm.compiler.nodes.InvokeWithExceptionNode)2 UnwindNode (org.graalvm.compiler.nodes.UnwindNode)2 RawMonitorEnterNode (org.graalvm.compiler.nodes.java.RawMonitorEnterNode)2 DynamicHub (com.oracle.svm.core.hub.DynamicHub)1 SubstrateObjectConstant (com.oracle.svm.core.meta.SubstrateObjectConstant)1 ArrayList (java.util.ArrayList)1 Constant (jdk.vm.ci.meta.Constant)1 JavaKind (jdk.vm.ci.meta.JavaKind)1 JavaType (jdk.vm.ci.meta.JavaType)1 ResolvedJavaType (jdk.vm.ci.meta.ResolvedJavaType)1