Search in sources :

Example 1 with DeadEndNode

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

the class CEntryPointCallStubMethod method generatePrologueOrEpilogueInvoke.

private static InvokeWithExceptionNode generatePrologueOrEpilogueInvoke(SubstrateGraphKit kit, ResolvedJavaMethod method, ValueNode... args) {
    VMError.guarantee(method.isAnnotationPresent(Uninterruptible.class), "The method " + method + " must be uninterruptible as it is used for a prologue or epilogue.");
    InvokeWithExceptionNode invoke = kit.startInvokeWithException(method, InvokeKind.Static, kit.getFrameState(), kit.bci(), args);
    kit.exceptionPart();
    kit.append(new DeadEndNode());
    kit.endInvokeWithException();
    return invoke;
}
Also used : Uninterruptible(com.oracle.svm.core.annotate.Uninterruptible) InvokeWithExceptionNode(org.graalvm.compiler.nodes.InvokeWithExceptionNode) LoweredDeadEndNode(com.oracle.svm.core.graal.nodes.LoweredDeadEndNode) DeadEndNode(org.graalvm.compiler.nodes.DeadEndNode)

Example 2 with DeadEndNode

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

the class OptimizeExceptionPathsPhase method run.

@Override
protected void run(StructuredGraph graph) {
    /*
         * First walk back from all exceptional control flow sinks to a control flow split that also
         * goes to a "regular" return.
         */
    NodeBitMap exceptionPaths = new NodeBitMap(graph);
    for (UnwindNode unwind : graph.getNodes(UnwindNode.TYPE)) {
        walkBack(unwind, exceptionPaths);
    }
    for (DeadEndNode deadEnd : graph.getNodes(DeadEndNode.TYPE)) {
        walkBack(deadEnd, exceptionPaths);
    }
    for (LoweredDeadEndNode deadEnd : graph.getNodes(LoweredDeadEndNode.TYPE)) {
        walkBack(deadEnd, exceptionPaths);
    }
    /* Now that we know all control flow splits, we modify the branch probabilities. */
    for (Node n : exceptionPaths) {
        AbstractBeginNode exceptionBegin = (AbstractBeginNode) n;
        ControlSplitNode controlSplitNode = (ControlSplitNode) exceptionBegin.predecessor();
        /*
             * Only overwrite the branch probability if it comes from non-profiled sources. If we
             * have proper PGO information that the exception edge is used, it deserves to be
             * optimized.
             */
        if (controlSplitNode.getProfileData().getProfileSource() != ProfileData.ProfileSource.PROFILED) {
            controlSplitNode.setProbability(exceptionBegin, BranchProbabilityNode.EXTREMELY_SLOW_PATH_PROFILE);
        }
    }
}
Also used : NodeBitMap(org.graalvm.compiler.graph.NodeBitMap) DeadEndNode(org.graalvm.compiler.nodes.DeadEndNode) LoweredDeadEndNode(com.oracle.svm.core.graal.nodes.LoweredDeadEndNode) IfNode(org.graalvm.compiler.nodes.IfNode) BranchProbabilityNode(org.graalvm.compiler.nodes.extended.BranchProbabilityNode) AbstractBeginNode(org.graalvm.compiler.nodes.AbstractBeginNode) AbstractMergeNode(org.graalvm.compiler.nodes.AbstractMergeNode) ValueNode(org.graalvm.compiler.nodes.ValueNode) ControlSplitNode(org.graalvm.compiler.nodes.ControlSplitNode) SwitchNode(org.graalvm.compiler.nodes.extended.SwitchNode) UnwindNode(org.graalvm.compiler.nodes.UnwindNode) WithExceptionNode(org.graalvm.compiler.nodes.WithExceptionNode) Node(org.graalvm.compiler.graph.Node) MergeNode(org.graalvm.compiler.nodes.MergeNode) ControlSinkNode(org.graalvm.compiler.nodes.ControlSinkNode) ControlSplitNode(org.graalvm.compiler.nodes.ControlSplitNode) UnwindNode(org.graalvm.compiler.nodes.UnwindNode) LoweredDeadEndNode(com.oracle.svm.core.graal.nodes.LoweredDeadEndNode) DeadEndNode(org.graalvm.compiler.nodes.DeadEndNode) LoweredDeadEndNode(com.oracle.svm.core.graal.nodes.LoweredDeadEndNode) AbstractBeginNode(org.graalvm.compiler.nodes.AbstractBeginNode)

Example 3 with DeadEndNode

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

the class DefaultHotSpotLoweringProvider method lowerWithoutDelegation.

/**
 * Handles the lowering of {@code n} without delegating to plugins or super.
 *
 * @return {@code true} if this method handles lowering of {@code n}
 */
private boolean lowerWithoutDelegation(Node n, LoweringTool tool) {
    StructuredGraph graph = (StructuredGraph) n.graph();
    if (n instanceof Invoke) {
        lowerInvoke((Invoke) n, tool, graph);
    } else if (n instanceof LoadMethodNode) {
        lowerLoadMethodNode((LoadMethodNode) n);
    } else if (n instanceof GetClassNode) {
        lowerGetClassNode((GetClassNode) n, tool, graph);
    } else if (n instanceof StoreHubNode) {
        lowerStoreHubNode((StoreHubNode) n, graph);
    } else if (n instanceof OSRStartNode) {
        lowerOSRStartNode((OSRStartNode) n);
    } else if (n instanceof BytecodeExceptionNode) {
        lowerBytecodeExceptionNode((BytecodeExceptionNode) n);
    } else if (n instanceof InstanceOfNode) {
        InstanceOfNode instanceOfNode = (InstanceOfNode) n;
        if (graph.getGuardsStage().areDeoptsFixed()) {
            instanceofSnippets.lower(instanceOfNode, tool);
        } else {
            if (instanceOfNode.allowsNull()) {
                ValueNode object = instanceOfNode.getValue();
                LogicNode newTypeCheck = graph.addOrUniqueWithInputs(InstanceOfNode.create(instanceOfNode.type(), object, instanceOfNode.profile(), instanceOfNode.getAnchor()));
                LogicNode newNode = LogicNode.or(graph.unique(IsNullNode.create(object)), newTypeCheck, BranchProbabilityNode.NOT_LIKELY_PROFILE);
                instanceOfNode.replaceAndDelete(newNode);
            }
        }
    } else if (n instanceof InstanceOfDynamicNode) {
        InstanceOfDynamicNode instanceOfDynamicNode = (InstanceOfDynamicNode) n;
        if (graph.getGuardsStage().areDeoptsFixed()) {
            instanceofSnippets.lower(instanceOfDynamicNode, tool);
        } else {
            ValueNode mirror = instanceOfDynamicNode.getMirrorOrHub();
            if (mirror.stamp(NodeView.DEFAULT).getStackKind() == JavaKind.Object) {
                ClassGetHubNode classGetHub = graph.unique(new ClassGetHubNode(mirror));
                instanceOfDynamicNode.setMirror(classGetHub);
            }
            if (instanceOfDynamicNode.allowsNull()) {
                ValueNode object = instanceOfDynamicNode.getObject();
                LogicNode newTypeCheck = graph.addOrUniqueWithInputs(InstanceOfDynamicNode.create(graph.getAssumptions(), tool.getConstantReflection(), instanceOfDynamicNode.getMirrorOrHub(), object, false, /* null checked below */
                instanceOfDynamicNode.isExact()));
                LogicNode newNode = LogicNode.or(graph.unique(IsNullNode.create(object)), newTypeCheck, BranchProbabilityNode.NOT_LIKELY_PROFILE);
                instanceOfDynamicNode.replaceAndDelete(newNode);
            }
        }
    } else if (n instanceof ClassIsAssignableFromNode) {
        if (graph.getGuardsStage().areDeoptsFixed()) {
            instanceofSnippets.lower((ClassIsAssignableFromNode) n, tool);
        }
    } else if (n instanceof NewInstanceNode) {
        if (graph.getGuardsStage().areFrameStatesAtDeopts()) {
            getAllocationSnippets().lower((NewInstanceNode) n, tool);
        }
    } else if (n instanceof DynamicNewInstanceNode) {
        if (graph.getGuardsStage().areFrameStatesAtDeopts()) {
            getAllocationSnippets().lower((DynamicNewInstanceNode) n, tool);
        }
    } else if (n instanceof ValidateNewInstanceClassNode) {
        ValidateNewInstanceClassNode validateNewInstance = (ValidateNewInstanceClassNode) n;
        if (validateNewInstance.getClassClass() == null) {
            JavaConstant classClassMirror = constantReflection.asJavaClass(metaAccess.lookupJavaType(Class.class));
            ConstantNode classClass = ConstantNode.forConstant(classClassMirror, tool.getMetaAccess(), graph);
            validateNewInstance.setClassClass(classClass);
        }
        getAllocationSnippets().lower(validateNewInstance, tool);
    } else if (n instanceof NewArrayNode) {
        if (graph.getGuardsStage().areFrameStatesAtDeopts()) {
            getAllocationSnippets().lower((NewArrayNode) n, tool);
        }
    } else if (n instanceof DynamicNewArrayNode) {
        DynamicNewArrayNode dynamicNewArrayNode = (DynamicNewArrayNode) n;
        if (dynamicNewArrayNode.getVoidClass() == null) {
            JavaConstant voidClassMirror = constantReflection.asJavaClass(metaAccess.lookupJavaType(void.class));
            ConstantNode voidClass = ConstantNode.forConstant(voidClassMirror, tool.getMetaAccess(), graph);
            dynamicNewArrayNode.setVoidClass(voidClass);
        }
        if (graph.getGuardsStage().areFrameStatesAtDeopts()) {
            getAllocationSnippets().lower(dynamicNewArrayNode, tool);
        }
    } else if (n instanceof VerifyHeapNode) {
        if (graph.getGuardsStage().areFrameStatesAtDeopts()) {
            getAllocationSnippets().lower((VerifyHeapNode) n, tool);
        }
    } else if (n instanceof MonitorEnterNode) {
        if (graph.getGuardsStage().areFrameStatesAtDeopts()) {
            monitorSnippets.lower((MonitorEnterNode) n, registers, tool);
        } else {
            loadHubForMonitorEnterNode((MonitorEnterNode) n, tool, graph);
        }
    } else if (n instanceof MonitorExitNode) {
        if (graph.getGuardsStage().areFrameStatesAtDeopts()) {
            monitorSnippets.lower((MonitorExitNode) n, registers, tool);
        }
    } else if (n instanceof ArrayCopyNode) {
        arraycopySnippets.lower((ArrayCopyNode) n, tool);
    } else if (n instanceof ArrayCopyWithDelayedLoweringNode) {
        arraycopySnippets.lower((ArrayCopyWithDelayedLoweringNode) n, tool);
    } else if (n instanceof G1PreWriteBarrier) {
        g1WriteBarrierSnippets.lower((G1PreWriteBarrier) n, tool);
    } else if (n instanceof G1PostWriteBarrier) {
        g1WriteBarrierSnippets.lower((G1PostWriteBarrier) n, tool);
    } else if (n instanceof G1ReferentFieldReadBarrier) {
        g1WriteBarrierSnippets.lower((G1ReferentFieldReadBarrier) n, tool);
    } else if (n instanceof SerialWriteBarrier) {
        serialWriteBarrierSnippets.lower((SerialWriteBarrier) n, tool);
    } else if (n instanceof SerialArrayRangeWriteBarrier) {
        serialWriteBarrierSnippets.lower((SerialArrayRangeWriteBarrier) n, tool);
    } else if (n instanceof G1ArrayRangePreWriteBarrier) {
        g1WriteBarrierSnippets.lower((G1ArrayRangePreWriteBarrier) n, tool);
    } else if (n instanceof G1ArrayRangePostWriteBarrier) {
        g1WriteBarrierSnippets.lower((G1ArrayRangePostWriteBarrier) n, tool);
    } else if (n instanceof NewMultiArrayNode) {
        if (graph.getGuardsStage().areFrameStatesAtDeopts()) {
            getAllocationSnippets().lower((NewMultiArrayNode) n, tool);
        }
    } else if (n instanceof LoadExceptionObjectNode) {
        exceptionObjectSnippets.lower((LoadExceptionObjectNode) n, registers, tool);
    } else if (n instanceof AssertionNode) {
        assertionSnippets.lower((AssertionNode) n, tool);
    } else if (n instanceof LogNode) {
        logSnippets.lower((LogNode) n, tool);
    } else if (n instanceof StringToBytesNode) {
        if (graph.getGuardsStage().areDeoptsFixed()) {
            stringToBytesSnippets.lower((StringToBytesNode) n, tool);
        }
    } else if (n instanceof IntegerDivRemNode) {
    // Nothing to do for division nodes. The HotSpot signal handler catches divisions by
    // zero and the MIN_VALUE / -1 cases.
    } else if (n instanceof AbstractDeoptimizeNode || n instanceof UnwindNode || n instanceof RemNode || n instanceof SafepointNode) {
    /* No lowering, we generate LIR directly for these nodes. */
    } else if (n instanceof ClassGetHubNode) {
        lowerClassGetHubNode((ClassGetHubNode) n, tool);
    } else if (n instanceof HubGetClassNode) {
        lowerHubGetClassNode((HubGetClassNode) n, tool);
    } else if (n instanceof KlassLayoutHelperNode) {
        lowerKlassLayoutHelperNode((KlassLayoutHelperNode) n, tool);
    } else if (n instanceof KlassBeingInitializedCheckNode) {
        getAllocationSnippets().lower((KlassBeingInitializedCheckNode) n, tool);
    } else if (n instanceof FastNotifyNode) {
        if (graph.getGuardsStage() == GuardsStage.AFTER_FSA) {
            objectSnippets.lower(n, tool);
        }
    } else if (n instanceof UnsafeCopyMemoryNode) {
        if (graph.getGuardsStage() == GuardsStage.AFTER_FSA) {
            unsafeSnippets.lower((UnsafeCopyMemoryNode) n, tool);
        }
    } else if (n instanceof RegisterFinalizerNode) {
        lowerRegisterFinalizer((RegisterFinalizerNode) n, tool);
    } else if (n instanceof DeadEndNode) {
        lowerDeadEnd((DeadEndNode) n);
    } else {
        return false;
    }
    return true;
}
Also used : ClassIsAssignableFromNode(org.graalvm.compiler.nodes.java.ClassIsAssignableFromNode) SafepointNode(org.graalvm.compiler.nodes.SafepointNode) HubGetClassNode(org.graalvm.compiler.hotspot.replacements.HubGetClassNode) BytecodeExceptionNode(org.graalvm.compiler.nodes.extended.BytecodeExceptionNode) UnsafeCopyMemoryNode(org.graalvm.compiler.hotspot.replacements.UnsafeCopyMemoryNode) MonitorExitNode(org.graalvm.compiler.nodes.java.MonitorExitNode) ConstantNode(org.graalvm.compiler.nodes.ConstantNode) KlassLayoutHelperNode(org.graalvm.compiler.hotspot.replacements.KlassLayoutHelperNode) ValidateNewInstanceClassNode(org.graalvm.compiler.nodes.java.ValidateNewInstanceClassNode) FastNotifyNode(org.graalvm.compiler.hotspot.replacements.FastNotifyNode) IntegerDivRemNode(org.graalvm.compiler.nodes.calc.IntegerDivRemNode) RemNode(org.graalvm.compiler.nodes.calc.RemNode) DynamicNewArrayNode(org.graalvm.compiler.nodes.java.DynamicNewArrayNode) NewArrayNode(org.graalvm.compiler.nodes.java.NewArrayNode) HubGetClassNode(org.graalvm.compiler.hotspot.replacements.HubGetClassNode) GetClassNode(org.graalvm.compiler.nodes.extended.GetClassNode) SerialWriteBarrier(org.graalvm.compiler.nodes.gc.SerialWriteBarrier) LoadMethodNode(org.graalvm.compiler.nodes.extended.LoadMethodNode) AbstractDeoptimizeNode(org.graalvm.compiler.nodes.AbstractDeoptimizeNode) InstanceOfDynamicNode(org.graalvm.compiler.nodes.java.InstanceOfDynamicNode) OSRStartNode(org.graalvm.compiler.nodes.extended.OSRStartNode) ValueNode(org.graalvm.compiler.nodes.ValueNode) LogicNode(org.graalvm.compiler.nodes.LogicNode) G1PostWriteBarrier(org.graalvm.compiler.nodes.gc.G1PostWriteBarrier) KlassBeingInitializedCheckNode(org.graalvm.compiler.hotspot.nodes.KlassBeingInitializedCheckNode) InstanceOfNode(org.graalvm.compiler.nodes.java.InstanceOfNode) NewInstanceNode(org.graalvm.compiler.nodes.java.NewInstanceNode) DynamicNewInstanceNode(org.graalvm.compiler.nodes.java.DynamicNewInstanceNode) StoreHubNode(org.graalvm.compiler.nodes.extended.StoreHubNode) G1ArrayRangePreWriteBarrier(org.graalvm.compiler.nodes.gc.G1ArrayRangePreWriteBarrier) JavaConstant(jdk.vm.ci.meta.JavaConstant) ArrayCopyWithDelayedLoweringNode(org.graalvm.compiler.replacements.arraycopy.ArrayCopyWithDelayedLoweringNode) RegisterFinalizerNode(org.graalvm.compiler.nodes.java.RegisterFinalizerNode) Invoke(org.graalvm.compiler.nodes.Invoke) AssertionNode(org.graalvm.compiler.replacements.nodes.AssertionNode) LogNode(org.graalvm.compiler.replacements.nodes.LogNode) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) OSRMonitorEnterNode(org.graalvm.compiler.nodes.extended.OSRMonitorEnterNode) MonitorEnterNode(org.graalvm.compiler.nodes.java.MonitorEnterNode) StringToBytesNode(org.graalvm.compiler.nodes.debug.StringToBytesNode) ClassGetHubNode(org.graalvm.compiler.hotspot.replacements.ClassGetHubNode) UnwindNode(org.graalvm.compiler.nodes.UnwindNode) DeadEndNode(org.graalvm.compiler.nodes.DeadEndNode) SerialArrayRangeWriteBarrier(org.graalvm.compiler.nodes.gc.SerialArrayRangeWriteBarrier) IntegerDivRemNode(org.graalvm.compiler.nodes.calc.IntegerDivRemNode) ArrayCopyNode(org.graalvm.compiler.replacements.arraycopy.ArrayCopyNode) G1ArrayRangePostWriteBarrier(org.graalvm.compiler.nodes.gc.G1ArrayRangePostWriteBarrier) DynamicNewInstanceNode(org.graalvm.compiler.nodes.java.DynamicNewInstanceNode) G1PreWriteBarrier(org.graalvm.compiler.nodes.gc.G1PreWriteBarrier) G1ReferentFieldReadBarrier(org.graalvm.compiler.nodes.gc.G1ReferentFieldReadBarrier) VerifyHeapNode(org.graalvm.compiler.nodes.debug.VerifyHeapNode) LoadExceptionObjectNode(org.graalvm.compiler.nodes.java.LoadExceptionObjectNode) NewMultiArrayNode(org.graalvm.compiler.nodes.java.NewMultiArrayNode) DynamicNewArrayNode(org.graalvm.compiler.nodes.java.DynamicNewArrayNode)

Aggregations

DeadEndNode (org.graalvm.compiler.nodes.DeadEndNode)3 LoweredDeadEndNode (com.oracle.svm.core.graal.nodes.LoweredDeadEndNode)2 UnwindNode (org.graalvm.compiler.nodes.UnwindNode)2 ValueNode (org.graalvm.compiler.nodes.ValueNode)2 Uninterruptible (com.oracle.svm.core.annotate.Uninterruptible)1 JavaConstant (jdk.vm.ci.meta.JavaConstant)1 Node (org.graalvm.compiler.graph.Node)1 NodeBitMap (org.graalvm.compiler.graph.NodeBitMap)1 KlassBeingInitializedCheckNode (org.graalvm.compiler.hotspot.nodes.KlassBeingInitializedCheckNode)1 ClassGetHubNode (org.graalvm.compiler.hotspot.replacements.ClassGetHubNode)1 FastNotifyNode (org.graalvm.compiler.hotspot.replacements.FastNotifyNode)1 HubGetClassNode (org.graalvm.compiler.hotspot.replacements.HubGetClassNode)1 KlassLayoutHelperNode (org.graalvm.compiler.hotspot.replacements.KlassLayoutHelperNode)1 UnsafeCopyMemoryNode (org.graalvm.compiler.hotspot.replacements.UnsafeCopyMemoryNode)1 AbstractBeginNode (org.graalvm.compiler.nodes.AbstractBeginNode)1 AbstractDeoptimizeNode (org.graalvm.compiler.nodes.AbstractDeoptimizeNode)1 AbstractMergeNode (org.graalvm.compiler.nodes.AbstractMergeNode)1 ConstantNode (org.graalvm.compiler.nodes.ConstantNode)1 ControlSinkNode (org.graalvm.compiler.nodes.ControlSinkNode)1 ControlSplitNode (org.graalvm.compiler.nodes.ControlSplitNode)1