Search in sources :

Example 46 with LogicNode

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

the class UseTrappingNullChecksPhase method checkPredecessor.

private static void checkPredecessor(AbstractDeoptimizeNode deopt, Node predecessor, DeoptimizationReason deoptimizationReason, long implicitNullCheckLimit) {
    Node current = predecessor;
    AbstractBeginNode branch = null;
    while (current instanceof AbstractBeginNode) {
        branch = (AbstractBeginNode) current;
        if (branch.anchored().isNotEmpty()) {
            // some input of the deopt framestate is anchored to this branch
            return;
        }
        current = current.predecessor();
    }
    if (current instanceof IfNode) {
        IfNode ifNode = (IfNode) current;
        if (branch != ifNode.trueSuccessor()) {
            return;
        }
        LogicNode condition = ifNode.condition();
        if (condition instanceof IsNullNode) {
            replaceWithTrappingNullCheck(deopt, ifNode, condition, deoptimizationReason, implicitNullCheckLimit);
        }
    }
}
Also used : IsNullNode(org.graalvm.compiler.nodes.calc.IsNullNode) ValuePhiNode(org.graalvm.compiler.nodes.ValuePhiNode) AbstractMergeNode(org.graalvm.compiler.nodes.AbstractMergeNode) DynamicDeoptimizeNode(org.graalvm.compiler.nodes.DynamicDeoptimizeNode) FixedAccessNode(org.graalvm.compiler.nodes.memory.FixedAccessNode) DeoptimizingFixedWithNextNode(org.graalvm.compiler.nodes.DeoptimizingFixedWithNextNode) BeginNode(org.graalvm.compiler.nodes.BeginNode) DeoptimizeNode(org.graalvm.compiler.nodes.DeoptimizeNode) FixedNode(org.graalvm.compiler.nodes.FixedNode) IfNode(org.graalvm.compiler.nodes.IfNode) AbstractBeginNode(org.graalvm.compiler.nodes.AbstractBeginNode) CompressionNode(org.graalvm.compiler.nodes.CompressionNode) AbstractEndNode(org.graalvm.compiler.nodes.AbstractEndNode) AbstractDeoptimizeNode(org.graalvm.compiler.nodes.AbstractDeoptimizeNode) AddressNode(org.graalvm.compiler.nodes.memory.address.AddressNode) LogicNode(org.graalvm.compiler.nodes.LogicNode) ValueNode(org.graalvm.compiler.nodes.ValueNode) IsNullNode(org.graalvm.compiler.nodes.calc.IsNullNode) NullCheckNode(org.graalvm.compiler.nodes.extended.NullCheckNode) Node(org.graalvm.compiler.graph.Node) LogicNode(org.graalvm.compiler.nodes.LogicNode) IfNode(org.graalvm.compiler.nodes.IfNode) AbstractBeginNode(org.graalvm.compiler.nodes.AbstractBeginNode)

Example 47 with LogicNode

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

the class TypeGuardInlineInfo method createGuard.

@SuppressWarnings("try")
private void createGuard(StructuredGraph graph, Providers providers) {
    try (DebugCloseable context = invoke.asNode().withNodeSourcePosition()) {
        ValueNode nonNullReceiver = InliningUtil.nonNullReceiver(invoke);
        LoadHubNode receiverHub = graph.unique(new LoadHubNode(providers.getStampProvider(), nonNullReceiver));
        ConstantNode typeHub = ConstantNode.forConstant(receiverHub.stamp(NodeView.DEFAULT), providers.getConstantReflection().asObjectHub(type), providers.getMetaAccess(), graph);
        LogicNode typeCheck = CompareNode.createCompareNode(graph, CanonicalCondition.EQ, receiverHub, typeHub, providers.getConstantReflection(), NodeView.DEFAULT);
        FixedGuardNode guard = graph.add(new FixedGuardNode(typeCheck, DeoptimizationReason.TypeCheckedInliningViolated, DeoptimizationAction.InvalidateReprofile));
        assert invoke.predecessor() != null;
        ValueNode anchoredReceiver = InliningUtil.createAnchoredReceiver(graph, guard, type, nonNullReceiver, true);
        invoke.callTarget().replaceFirstInput(nonNullReceiver, anchoredReceiver);
        graph.addBeforeFixed(invoke.asNode(), guard);
    }
}
Also used : FixedGuardNode(org.graalvm.compiler.nodes.FixedGuardNode) LoadHubNode(org.graalvm.compiler.nodes.extended.LoadHubNode) ConstantNode(org.graalvm.compiler.nodes.ConstantNode) ValueNode(org.graalvm.compiler.nodes.ValueNode) LogicNode(org.graalvm.compiler.nodes.LogicNode) DebugCloseable(org.graalvm.compiler.debug.DebugCloseable)

Example 48 with LogicNode

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

the class ReflectionSubstitutionType method createCheckcast.

private static ValueNode createCheckcast(HostedGraphKit graphKit, ValueNode value, ResolvedJavaType type, boolean nonNull) {
    TypeReference typeRef = TypeReference.createTrusted(graphKit.getAssumptions(), type);
    LogicNode condition;
    if (nonNull) {
        condition = graphKit.append(InstanceOfNode.create(typeRef, value));
    } else {
        condition = graphKit.append(InstanceOfNode.createAllowNull(typeRef, value, null, null));
    }
    graphKit.startIf(condition, BranchProbabilityNode.FAST_PATH_PROBABILITY);
    graphKit.thenPart();
    PiNode ret = graphKit.createPiNode(value, StampFactory.object(typeRef, nonNull));
    graphKit.elsePart();
    throwFailedCast(graphKit, type, value);
    graphKit.endIf();
    return ret;
}
Also used : LogicNode(org.graalvm.compiler.nodes.LogicNode) TypeReference(org.graalvm.compiler.core.common.type.TypeReference) PiNode(org.graalvm.compiler.nodes.PiNode)

Aggregations

LogicNode (org.graalvm.compiler.nodes.LogicNode)48 ValueNode (org.graalvm.compiler.nodes.ValueNode)37 FixedGuardNode (org.graalvm.compiler.nodes.FixedGuardNode)26 ConstantNode (org.graalvm.compiler.nodes.ConstantNode)11 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)11 ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)10 ResolvedJavaType (jdk.vm.ci.meta.ResolvedJavaType)9 Stamp (org.graalvm.compiler.core.common.type.Stamp)9 IfNode (org.graalvm.compiler.nodes.IfNode)9 TypeReference (org.graalvm.compiler.core.common.type.TypeReference)8 LogicConstantNode (org.graalvm.compiler.nodes.LogicConstantNode)7 CompareNode (org.graalvm.compiler.nodes.calc.CompareNode)7 ConditionalNode (org.graalvm.compiler.nodes.calc.ConditionalNode)7 JavaConstant (jdk.vm.ci.meta.JavaConstant)6 AbstractBeginNode (org.graalvm.compiler.nodes.AbstractBeginNode)6 FixedNode (org.graalvm.compiler.nodes.FixedNode)6 LoopBeginNode (org.graalvm.compiler.nodes.LoopBeginNode)6 JavaKind (jdk.vm.ci.meta.JavaKind)5 ObjectStamp (org.graalvm.compiler.core.common.type.ObjectStamp)5 Node (org.graalvm.compiler.graph.Node)5