Search in sources :

Example 1 with ComputeObjectAddressNode

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

the class DefaultHotSpotLoweringProvider method lowerComputeObjectAddressNode.

private static void lowerComputeObjectAddressNode(ComputeObjectAddressNode n) {
    /*
         * Lower the node into a ComputeObjectAddress node and an Add but ensure that it's below any
         * potential safepoints and above it's uses.
         */
    for (Node use : n.usages().snapshot()) {
        if (use instanceof FixedNode) {
            FixedNode fixed = (FixedNode) use;
            StructuredGraph graph = n.graph();
            GetObjectAddressNode address = graph.add(new GetObjectAddressNode(n.getObject()));
            graph.addBeforeFixed(fixed, address);
            AddNode add = graph.addOrUnique(new AddNode(address, n.getOffset()));
            use.replaceFirstInput(n, add);
        } else {
            throw GraalError.shouldNotReachHere("Unexpected floating use of ComputeObjectAddressNode " + n);
        }
    }
    GraphUtil.unlinkFixedNode(n);
    n.safeDelete();
}
Also used : StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) RawLoadNode(org.graalvm.compiler.nodes.extended.RawLoadNode) GetObjectAddressNode(org.graalvm.compiler.hotspot.nodes.GetObjectAddressNode) MonitorIdNode(org.graalvm.compiler.nodes.java.MonitorIdNode) MethodCallTargetNode(org.graalvm.compiler.nodes.java.MethodCallTargetNode) OSRLocalNode(org.graalvm.compiler.nodes.extended.OSRLocalNode) RawMonitorEnterNode(org.graalvm.compiler.nodes.java.RawMonitorEnterNode) AbstractDeoptimizeNode(org.graalvm.compiler.nodes.AbstractDeoptimizeNode) StringToBytesNode(org.graalvm.compiler.nodes.debug.StringToBytesNode) DynamicNewArrayNode(org.graalvm.compiler.nodes.java.DynamicNewArrayNode) LoadExceptionObjectNode(org.graalvm.compiler.nodes.java.LoadExceptionObjectNode) WriteNode(org.graalvm.compiler.nodes.memory.WriteNode) LoadMethodNode(org.graalvm.compiler.nodes.extended.LoadMethodNode) ConstantNode(org.graalvm.compiler.nodes.ConstantNode) FloatingReadNode(org.graalvm.compiler.nodes.memory.FloatingReadNode) BeginLockScopeNode(org.graalvm.compiler.hotspot.nodes.BeginLockScopeNode) InitializeKlassNode(org.graalvm.compiler.hotspot.nodes.aot.InitializeKlassNode) IdentityHashCodeNode(org.graalvm.compiler.hotspot.replacements.IdentityHashCodeNode) FixedNode(org.graalvm.compiler.nodes.FixedNode) ResolveMethodAndLoadCountersNode(org.graalvm.compiler.hotspot.nodes.aot.ResolveMethodAndLoadCountersNode) OSRStartNode(org.graalvm.compiler.nodes.extended.OSRStartNode) HotSpotDirectCallTargetNode(org.graalvm.compiler.hotspot.nodes.HotSpotDirectCallTargetNode) SafepointNode(org.graalvm.compiler.nodes.SafepointNode) VerifyHeapNode(org.graalvm.compiler.nodes.debug.VerifyHeapNode) ForeignCallNode(org.graalvm.compiler.nodes.extended.ForeignCallNode) NewInstanceNode(org.graalvm.compiler.nodes.java.NewInstanceNode) DynamicNewInstanceNode(org.graalvm.compiler.nodes.java.DynamicNewInstanceNode) ArrayCopyWithSlowPathNode(org.graalvm.compiler.hotspot.replacements.arraycopy.ArrayCopyWithSlowPathNode) KlassLayoutHelperNode(org.graalvm.compiler.hotspot.replacements.KlassLayoutHelperNode) ClassGetHubNode(org.graalvm.compiler.hotspot.replacements.ClassGetHubNode) HotSpotCompressionNode(org.graalvm.compiler.hotspot.nodes.HotSpotCompressionNode) OSRLockNode(org.graalvm.compiler.nodes.extended.OSRLockNode) AssertionNode(org.graalvm.compiler.replacements.nodes.AssertionNode) IntegerDivRemNode(org.graalvm.compiler.nodes.calc.IntegerDivRemNode) NewMultiArrayNode(org.graalvm.compiler.nodes.java.NewMultiArrayNode) ResolveDynamicConstantNode(org.graalvm.compiler.hotspot.nodes.aot.ResolveDynamicConstantNode) ProfileNode(org.graalvm.compiler.hotspot.nodes.profiling.ProfileNode) AbstractBeginNode(org.graalvm.compiler.nodes.AbstractBeginNode) LogicNode(org.graalvm.compiler.nodes.LogicNode) ValueNode(org.graalvm.compiler.nodes.ValueNode) HotSpotIndirectCallTargetNode(org.graalvm.compiler.hotspot.nodes.HotSpotIndirectCallTargetNode) ArrayCopyNode(org.graalvm.compiler.hotspot.replacements.arraycopy.ArrayCopyNode) HubGetClassNode(org.graalvm.compiler.hotspot.replacements.HubGetClassNode) OSRMonitorEnterNode(org.graalvm.compiler.nodes.extended.OSRMonitorEnterNode) MonitorExitNode(org.graalvm.compiler.nodes.java.MonitorExitNode) IsNullNode(org.graalvm.compiler.nodes.calc.IsNullNode) StoreHubNode(org.graalvm.compiler.nodes.extended.StoreHubNode) NewArrayNode(org.graalvm.compiler.nodes.java.NewArrayNode) ResolveConstantNode(org.graalvm.compiler.hotspot.nodes.aot.ResolveConstantNode) FloatingNode(org.graalvm.compiler.nodes.calc.FloatingNode) StartNode(org.graalvm.compiler.nodes.StartNode) RemNode(org.graalvm.compiler.nodes.calc.RemNode) ClassIsAssignableFromNode(org.graalvm.compiler.nodes.java.ClassIsAssignableFromNode) ReadNode(org.graalvm.compiler.nodes.memory.ReadNode) InstanceOfDynamicNode(org.graalvm.compiler.nodes.java.InstanceOfDynamicNode) AddNode(org.graalvm.compiler.nodes.calc.AddNode) LoadHubNode(org.graalvm.compiler.nodes.extended.LoadHubNode) ComputeObjectAddressNode(org.graalvm.compiler.hotspot.nodes.ComputeObjectAddressNode) InstanceOfNode(org.graalvm.compiler.nodes.java.InstanceOfNode) LoweredCallTargetNode(org.graalvm.compiler.nodes.LoweredCallTargetNode) ParameterNode(org.graalvm.compiler.nodes.ParameterNode) GuardedUnsafeLoadNode(org.graalvm.compiler.nodes.extended.GuardedUnsafeLoadNode) AddressNode(org.graalvm.compiler.nodes.memory.address.AddressNode) UnwindNode(org.graalvm.compiler.nodes.UnwindNode) GetClassNode(org.graalvm.compiler.nodes.extended.GetClassNode) BytecodeExceptionNode(org.graalvm.compiler.nodes.extended.BytecodeExceptionNode) Node(org.graalvm.compiler.graph.Node) FixedNode(org.graalvm.compiler.nodes.FixedNode) AddNode(org.graalvm.compiler.nodes.calc.AddNode) GetObjectAddressNode(org.graalvm.compiler.hotspot.nodes.GetObjectAddressNode)

Example 2 with ComputeObjectAddressNode

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

the class DefaultHotSpotLoweringProvider method lower.

@Override
public void lower(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, GraalDirectives.UNLIKELY_PROBABILITY);
                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));
                LogicNode newNode = LogicNode.or(graph.unique(IsNullNode.create(object)), newTypeCheck, GraalDirectives.UNLIKELY_PROBABILITY);
                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()) {
            newObjectSnippets.lower((NewInstanceNode) n, registers, tool);
        }
    } else if (n instanceof DynamicNewInstanceNode) {
        DynamicNewInstanceNode newInstanceNode = (DynamicNewInstanceNode) n;
        if (newInstanceNode.getClassClass() == null) {
            JavaConstant classClassMirror = constantReflection.forObject(Class.class);
            ConstantNode classClass = ConstantNode.forConstant(classClassMirror, tool.getMetaAccess(), graph);
            newInstanceNode.setClassClass(classClass);
        }
        if (graph.getGuardsStage().areFrameStatesAtDeopts()) {
            newObjectSnippets.lower(newInstanceNode, registers, tool);
        }
    } else if (n instanceof NewArrayNode) {
        if (graph.getGuardsStage().areFrameStatesAtDeopts()) {
            newObjectSnippets.lower((NewArrayNode) n, registers, tool);
        }
    } else if (n instanceof DynamicNewArrayNode) {
        DynamicNewArrayNode dynamicNewArrayNode = (DynamicNewArrayNode) n;
        if (dynamicNewArrayNode.getVoidClass() == null) {
            JavaConstant voidClassMirror = constantReflection.forObject(void.class);
            ConstantNode voidClass = ConstantNode.forConstant(voidClassMirror, tool.getMetaAccess(), graph);
            dynamicNewArrayNode.setVoidClass(voidClass);
        }
        if (graph.getGuardsStage().areFrameStatesAtDeopts()) {
            newObjectSnippets.lower(dynamicNewArrayNode, registers, tool);
        }
    } else if (n instanceof VerifyHeapNode) {
        if (graph.getGuardsStage().areFrameStatesAtDeopts()) {
            newObjectSnippets.lower((VerifyHeapNode) n, registers, tool);
        }
    } else if (n instanceof RawMonitorEnterNode) {
        if (graph.getGuardsStage().areFrameStatesAtDeopts()) {
            monitorSnippets.lower((RawMonitorEnterNode) n, registers, tool);
        }
    } 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 ArrayCopyWithSlowPathNode) {
        arraycopySnippets.lower((ArrayCopyWithSlowPathNode) n, tool);
    } else if (n instanceof G1PreWriteBarrier) {
        writeBarrierSnippets.lower((G1PreWriteBarrier) n, registers, tool);
    } else if (n instanceof G1PostWriteBarrier) {
        writeBarrierSnippets.lower((G1PostWriteBarrier) n, registers, tool);
    } else if (n instanceof G1ReferentFieldReadBarrier) {
        writeBarrierSnippets.lower((G1ReferentFieldReadBarrier) n, registers, tool);
    } else if (n instanceof SerialWriteBarrier) {
        writeBarrierSnippets.lower((SerialWriteBarrier) n, tool);
    } else if (n instanceof SerialArrayRangeWriteBarrier) {
        writeBarrierSnippets.lower((SerialArrayRangeWriteBarrier) n, tool);
    } else if (n instanceof G1ArrayRangePreWriteBarrier) {
        writeBarrierSnippets.lower((G1ArrayRangePreWriteBarrier) n, registers, tool);
    } else if (n instanceof G1ArrayRangePostWriteBarrier) {
        writeBarrierSnippets.lower((G1ArrayRangePostWriteBarrier) n, registers, tool);
    } else if (n instanceof NewMultiArrayNode) {
        if (graph.getGuardsStage().areFrameStatesAtDeopts()) {
            newObjectSnippets.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 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 ComputeObjectAddressNode) {
        if (graph.getGuardsStage().areFrameStatesAtDeopts()) {
            lowerComputeObjectAddressNode((ComputeObjectAddressNode) n);
        }
    } else if (n instanceof IdentityHashCodeNode) {
        hashCodeSnippets.lower((IdentityHashCodeNode) n, tool);
    } else if (n instanceof ResolveDynamicConstantNode) {
        if (graph.getGuardsStage().areFrameStatesAtDeopts()) {
            resolveConstantSnippets.lower((ResolveDynamicConstantNode) n, tool);
        }
    } else if (n instanceof ResolveConstantNode) {
        if (graph.getGuardsStage().areFrameStatesAtDeopts()) {
            resolveConstantSnippets.lower((ResolveConstantNode) n, tool);
        }
    } else if (n instanceof ResolveMethodAndLoadCountersNode) {
        if (graph.getGuardsStage().areFrameStatesAtDeopts()) {
            resolveConstantSnippets.lower((ResolveMethodAndLoadCountersNode) n, tool);
        }
    } else if (n instanceof InitializeKlassNode) {
        if (graph.getGuardsStage().areFrameStatesAtDeopts()) {
            resolveConstantSnippets.lower((InitializeKlassNode) n, tool);
        }
    } else if (n instanceof ProfileNode) {
        profileSnippets.lower((ProfileNode) n, tool);
    } else {
        super.lower(n, tool);
    }
}
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) MonitorExitNode(org.graalvm.compiler.nodes.java.MonitorExitNode) ResolveConstantNode(org.graalvm.compiler.hotspot.nodes.aot.ResolveConstantNode) ConstantNode(org.graalvm.compiler.nodes.ConstantNode) ResolveDynamicConstantNode(org.graalvm.compiler.hotspot.nodes.aot.ResolveDynamicConstantNode) ResolveConstantNode(org.graalvm.compiler.hotspot.nodes.aot.ResolveConstantNode) KlassLayoutHelperNode(org.graalvm.compiler.hotspot.replacements.KlassLayoutHelperNode) ComputeObjectAddressNode(org.graalvm.compiler.hotspot.nodes.ComputeObjectAddressNode) ResolveDynamicConstantNode(org.graalvm.compiler.hotspot.nodes.aot.ResolveDynamicConstantNode) 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.hotspot.nodes.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) ResolveMethodAndLoadCountersNode(org.graalvm.compiler.hotspot.nodes.aot.ResolveMethodAndLoadCountersNode) ValueNode(org.graalvm.compiler.nodes.ValueNode) LogicNode(org.graalvm.compiler.nodes.LogicNode) G1PostWriteBarrier(org.graalvm.compiler.hotspot.nodes.G1PostWriteBarrier) 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.hotspot.nodes.G1ArrayRangePreWriteBarrier) JavaConstant(jdk.vm.ci.meta.JavaConstant) Invoke(org.graalvm.compiler.nodes.Invoke) AssertionNode(org.graalvm.compiler.replacements.nodes.AssertionNode) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) ProfileNode(org.graalvm.compiler.hotspot.nodes.profiling.ProfileNode) StringToBytesNode(org.graalvm.compiler.nodes.debug.StringToBytesNode) ClassGetHubNode(org.graalvm.compiler.hotspot.replacements.ClassGetHubNode) UnwindNode(org.graalvm.compiler.nodes.UnwindNode) SerialArrayRangeWriteBarrier(org.graalvm.compiler.hotspot.nodes.SerialArrayRangeWriteBarrier) IntegerDivRemNode(org.graalvm.compiler.nodes.calc.IntegerDivRemNode) ArrayCopyNode(org.graalvm.compiler.hotspot.replacements.arraycopy.ArrayCopyNode) G1ArrayRangePostWriteBarrier(org.graalvm.compiler.hotspot.nodes.G1ArrayRangePostWriteBarrier) DynamicNewInstanceNode(org.graalvm.compiler.nodes.java.DynamicNewInstanceNode) G1PreWriteBarrier(org.graalvm.compiler.hotspot.nodes.G1PreWriteBarrier) RawMonitorEnterNode(org.graalvm.compiler.nodes.java.RawMonitorEnterNode) G1ReferentFieldReadBarrier(org.graalvm.compiler.hotspot.nodes.G1ReferentFieldReadBarrier) VerifyHeapNode(org.graalvm.compiler.nodes.debug.VerifyHeapNode) LoadExceptionObjectNode(org.graalvm.compiler.nodes.java.LoadExceptionObjectNode) ArrayCopyWithSlowPathNode(org.graalvm.compiler.hotspot.replacements.arraycopy.ArrayCopyWithSlowPathNode) IdentityHashCodeNode(org.graalvm.compiler.hotspot.replacements.IdentityHashCodeNode) NewMultiArrayNode(org.graalvm.compiler.nodes.java.NewMultiArrayNode) InitializeKlassNode(org.graalvm.compiler.hotspot.nodes.aot.InitializeKlassNode) DynamicNewArrayNode(org.graalvm.compiler.nodes.java.DynamicNewArrayNode)

Aggregations

ComputeObjectAddressNode (org.graalvm.compiler.hotspot.nodes.ComputeObjectAddressNode)2 InitializeKlassNode (org.graalvm.compiler.hotspot.nodes.aot.InitializeKlassNode)2 ResolveConstantNode (org.graalvm.compiler.hotspot.nodes.aot.ResolveConstantNode)2 ResolveDynamicConstantNode (org.graalvm.compiler.hotspot.nodes.aot.ResolveDynamicConstantNode)2 ResolveMethodAndLoadCountersNode (org.graalvm.compiler.hotspot.nodes.aot.ResolveMethodAndLoadCountersNode)2 ProfileNode (org.graalvm.compiler.hotspot.nodes.profiling.ProfileNode)2 ClassGetHubNode (org.graalvm.compiler.hotspot.replacements.ClassGetHubNode)2 HubGetClassNode (org.graalvm.compiler.hotspot.replacements.HubGetClassNode)2 IdentityHashCodeNode (org.graalvm.compiler.hotspot.replacements.IdentityHashCodeNode)2 KlassLayoutHelperNode (org.graalvm.compiler.hotspot.replacements.KlassLayoutHelperNode)2 ArrayCopyNode (org.graalvm.compiler.hotspot.replacements.arraycopy.ArrayCopyNode)2 ArrayCopyWithSlowPathNode (org.graalvm.compiler.hotspot.replacements.arraycopy.ArrayCopyWithSlowPathNode)2 AbstractDeoptimizeNode (org.graalvm.compiler.nodes.AbstractDeoptimizeNode)2 ConstantNode (org.graalvm.compiler.nodes.ConstantNode)2 LogicNode (org.graalvm.compiler.nodes.LogicNode)2 SafepointNode (org.graalvm.compiler.nodes.SafepointNode)2 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)2 UnwindNode (org.graalvm.compiler.nodes.UnwindNode)2 ValueNode (org.graalvm.compiler.nodes.ValueNode)2 IntegerDivRemNode (org.graalvm.compiler.nodes.calc.IntegerDivRemNode)2