Search in sources :

Example 31 with AddressNode

use of org.graalvm.compiler.nodes.memory.address.AddressNode in project graal by oracle.

the class LoadVMThreadLocalNode method lower.

@Override
public void lower(LoweringTool tool) {
    assert threadLocalInfo.offset >= 0;
    ConstantNode offset = ConstantNode.forIntegerKind(FrameAccess.getWordKind(), threadLocalInfo.offset, holder.graph());
    AddressNode address = graph().unique(new OffsetAddressNode(holder, offset));
    FixedAccessNode read;
    if (SubstrateOptions.MultiThreaded.getValue()) {
        read = new CInterfaceReadNode(address, threadLocalInfo.locationIdentity, stamp(NodeView.DEFAULT), barrierType, threadLocalInfo.name);
    } else {
        read = new JavaReadNode(threadLocalInfo.storageKind, address, threadLocalInfo.locationIdentity, barrierType, true);
    }
    read = graph().add(read);
    graph().replaceFixedWithFixed(this, read);
    if (!SubstrateOptions.MultiThreaded.getValue()) {
        tool.getLowerer().lower(read, tool);
    }
}
Also used : FixedAccessNode(org.graalvm.compiler.nodes.memory.FixedAccessNode) JavaReadNode(org.graalvm.compiler.nodes.extended.JavaReadNode) ConstantNode(org.graalvm.compiler.nodes.ConstantNode) OffsetAddressNode(org.graalvm.compiler.nodes.memory.address.OffsetAddressNode) CInterfaceReadNode(com.oracle.svm.core.graal.nodes.CInterfaceReadNode) AddressNode(org.graalvm.compiler.nodes.memory.address.AddressNode) OffsetAddressNode(org.graalvm.compiler.nodes.memory.address.OffsetAddressNode)

Example 32 with AddressNode

use of org.graalvm.compiler.nodes.memory.address.AddressNode in project graal by oracle.

the class DefaultHotSpotLoweringProvider method lowerHubGetClassNode.

private void lowerHubGetClassNode(HubGetClassNode n, LoweringTool tool) {
    if (tool.getLoweringStage() == LoweringTool.StandardLoweringStage.HIGH_TIER) {
        return;
    }
    ValueNode hub = n.getHub();
    GraalHotSpotVMConfig vmConfig = runtime.getVMConfig();
    StructuredGraph graph = n.graph();
    assert !hub.isConstant() || GraalOptions.ImmutableCode.getValue(graph.getOptions());
    AddressNode mirrorAddress = createOffsetAddress(graph, hub, vmConfig.classMirrorOffset);
    FloatingReadNode read = graph.unique(new FloatingReadNode(mirrorAddress, CLASS_MIRROR_LOCATION, null, vmConfig.classMirrorIsHandle ? StampFactory.forKind(target.wordJavaKind) : n.stamp(NodeView.DEFAULT), null, BarrierType.NONE));
    if (vmConfig.classMirrorIsHandle) {
        AddressNode address = createOffsetAddress(graph, read, 0);
        read = graph.unique(new FloatingReadNode(address, CLASS_MIRROR_HANDLE_LOCATION, null, n.stamp(NodeView.DEFAULT), null, BarrierType.NONE));
    }
    n.replaceAtUsagesAndDelete(read);
}
Also used : StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) FloatingReadNode(org.graalvm.compiler.nodes.memory.FloatingReadNode) ValueNode(org.graalvm.compiler.nodes.ValueNode) GetObjectAddressNode(org.graalvm.compiler.hotspot.nodes.GetObjectAddressNode) ComputeObjectAddressNode(org.graalvm.compiler.hotspot.nodes.ComputeObjectAddressNode) AddressNode(org.graalvm.compiler.nodes.memory.address.AddressNode) GraalHotSpotVMConfig(org.graalvm.compiler.hotspot.GraalHotSpotVMConfig)

Example 33 with AddressNode

use of org.graalvm.compiler.nodes.memory.address.AddressNode in project graal by oracle.

the class DefaultHotSpotLoweringProvider method lowerInvoke.

private void lowerInvoke(Invoke invoke, LoweringTool tool, StructuredGraph graph) {
    if (invoke.callTarget() instanceof MethodCallTargetNode) {
        MethodCallTargetNode callTarget = (MethodCallTargetNode) invoke.callTarget();
        NodeInputList<ValueNode> parameters = callTarget.arguments();
        ValueNode receiver = parameters.size() <= 0 ? null : parameters.get(0);
        if (!callTarget.isStatic() && receiver.stamp(NodeView.DEFAULT) instanceof ObjectStamp && !StampTool.isPointerNonNull(receiver)) {
            ValueNode nonNullReceiver = createNullCheckedValue(receiver, invoke.asNode(), tool);
            parameters.set(0, nonNullReceiver);
            receiver = nonNullReceiver;
        }
        JavaType[] signature = callTarget.targetMethod().getSignature().toParameterTypes(callTarget.isStatic() ? null : callTarget.targetMethod().getDeclaringClass());
        LoweredCallTargetNode loweredCallTarget = null;
        OptionValues options = graph.getOptions();
        if (InlineVTableStubs.getValue(options) && callTarget.invokeKind().isIndirect() && (AlwaysInlineVTableStubs.getValue(options) || invoke.isPolymorphic())) {
            HotSpotResolvedJavaMethod hsMethod = (HotSpotResolvedJavaMethod) callTarget.targetMethod();
            ResolvedJavaType receiverType = invoke.getReceiverType();
            if (hsMethod.isInVirtualMethodTable(receiverType)) {
                JavaKind wordKind = runtime.getTarget().wordJavaKind;
                ValueNode hub = createReadHub(graph, receiver, tool);
                ReadNode metaspaceMethod = createReadVirtualMethod(graph, hub, hsMethod, receiverType);
                // We use LocationNode.ANY_LOCATION for the reads that access the
                // compiled code entry as HotSpot does not guarantee they are final
                // values.
                int methodCompiledEntryOffset = runtime.getVMConfig().methodCompiledEntryOffset;
                AddressNode address = createOffsetAddress(graph, metaspaceMethod, methodCompiledEntryOffset);
                ReadNode compiledEntry = graph.add(new ReadNode(address, any(), StampFactory.forKind(wordKind), BarrierType.NONE));
                loweredCallTarget = graph.add(new HotSpotIndirectCallTargetNode(metaspaceMethod, compiledEntry, parameters.toArray(new ValueNode[parameters.size()]), callTarget.returnStamp(), signature, callTarget.targetMethod(), HotSpotCallingConventionType.JavaCall, callTarget.invokeKind()));
                graph.addBeforeFixed(invoke.asNode(), metaspaceMethod);
                graph.addAfterFixed(metaspaceMethod, compiledEntry);
            }
        }
        if (loweredCallTarget == null) {
            loweredCallTarget = graph.add(new HotSpotDirectCallTargetNode(parameters.toArray(new ValueNode[parameters.size()]), callTarget.returnStamp(), signature, callTarget.targetMethod(), HotSpotCallingConventionType.JavaCall, callTarget.invokeKind()));
        }
        callTarget.replaceAndDelete(loweredCallTarget);
    }
}
Also used : HotSpotDirectCallTargetNode(org.graalvm.compiler.hotspot.nodes.HotSpotDirectCallTargetNode) HotSpotResolvedJavaMethod(jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod) ObjectStamp(org.graalvm.compiler.core.common.type.ObjectStamp) OptionValues(org.graalvm.compiler.options.OptionValues) HotSpotIndirectCallTargetNode(org.graalvm.compiler.hotspot.nodes.HotSpotIndirectCallTargetNode) ResolvedJavaType(jdk.vm.ci.meta.ResolvedJavaType) ResolvedJavaType(jdk.vm.ci.meta.ResolvedJavaType) JavaType(jdk.vm.ci.meta.JavaType) MethodCallTargetNode(org.graalvm.compiler.nodes.java.MethodCallTargetNode) ValueNode(org.graalvm.compiler.nodes.ValueNode) GetObjectAddressNode(org.graalvm.compiler.hotspot.nodes.GetObjectAddressNode) ComputeObjectAddressNode(org.graalvm.compiler.hotspot.nodes.ComputeObjectAddressNode) AddressNode(org.graalvm.compiler.nodes.memory.address.AddressNode) FloatingReadNode(org.graalvm.compiler.nodes.memory.FloatingReadNode) ReadNode(org.graalvm.compiler.nodes.memory.ReadNode) LoweredCallTargetNode(org.graalvm.compiler.nodes.LoweredCallTargetNode) JavaKind(jdk.vm.ci.meta.JavaKind)

Example 34 with AddressNode

use of org.graalvm.compiler.nodes.memory.address.AddressNode in project graal by oracle.

the class DefaultHotSpotLoweringProvider method lowerClassGetHubNode.

private void lowerClassGetHubNode(ClassGetHubNode n, LoweringTool tool) {
    if (tool.getLoweringStage() == LoweringTool.StandardLoweringStage.HIGH_TIER) {
        return;
    }
    StructuredGraph graph = n.graph();
    assert !n.getValue().isConstant();
    AddressNode address = createOffsetAddress(graph, n.getValue(), runtime.getVMConfig().klassOffset);
    FloatingReadNode read = graph.unique(new FloatingReadNode(address, CLASS_KLASS_LOCATION, null, n.stamp(NodeView.DEFAULT), null, BarrierType.NONE));
    n.replaceAtUsagesAndDelete(read);
}
Also used : StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) FloatingReadNode(org.graalvm.compiler.nodes.memory.FloatingReadNode) GetObjectAddressNode(org.graalvm.compiler.hotspot.nodes.GetObjectAddressNode) ComputeObjectAddressNode(org.graalvm.compiler.hotspot.nodes.ComputeObjectAddressNode) AddressNode(org.graalvm.compiler.nodes.memory.address.AddressNode)

Example 35 with AddressNode

use of org.graalvm.compiler.nodes.memory.address.AddressNode in project graal by oracle.

the class DefaultHotSpotLoweringProvider method lowerKlassLayoutHelperNode.

private void lowerKlassLayoutHelperNode(KlassLayoutHelperNode n, LoweringTool tool) {
    if (tool.getLoweringStage() == LoweringTool.StandardLoweringStage.HIGH_TIER) {
        return;
    }
    StructuredGraph graph = n.graph();
    assert !n.getHub().isConstant();
    AddressNode address = createOffsetAddress(graph, n.getHub(), runtime.getVMConfig().klassLayoutHelperOffset);
    n.replaceAtUsagesAndDelete(graph.unique(new FloatingReadNode(address, KLASS_LAYOUT_HELPER_LOCATION, null, n.stamp(NodeView.DEFAULT), null, BarrierType.NONE)));
}
Also used : StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) FloatingReadNode(org.graalvm.compiler.nodes.memory.FloatingReadNode) GetObjectAddressNode(org.graalvm.compiler.hotspot.nodes.GetObjectAddressNode) ComputeObjectAddressNode(org.graalvm.compiler.hotspot.nodes.ComputeObjectAddressNode) AddressNode(org.graalvm.compiler.nodes.memory.address.AddressNode)

Aggregations

AddressNode (org.graalvm.compiler.nodes.memory.address.AddressNode)43 ValueNode (org.graalvm.compiler.nodes.ValueNode)35 OffsetAddressNode (org.graalvm.compiler.nodes.memory.address.OffsetAddressNode)25 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)16 JavaKind (jdk.vm.ci.meta.JavaKind)13 ReadNode (org.graalvm.compiler.nodes.memory.ReadNode)12 Stamp (org.graalvm.compiler.core.common.type.Stamp)9 FloatingReadNode (org.graalvm.compiler.nodes.memory.FloatingReadNode)9 ComputeObjectAddressNode (org.graalvm.compiler.hotspot.nodes.ComputeObjectAddressNode)8 GetObjectAddressNode (org.graalvm.compiler.hotspot.nodes.GetObjectAddressNode)8 AMD64AddressNode (org.graalvm.compiler.core.amd64.AMD64AddressNode)7 ObjectStamp (org.graalvm.compiler.core.common.type.ObjectStamp)7 GraalCompilerTest (org.graalvm.compiler.core.test.GraalCompilerTest)7 JavaReadNode (org.graalvm.compiler.nodes.extended.JavaReadNode)7 WriteNode (org.graalvm.compiler.nodes.memory.WriteNode)7 Test (org.junit.Test)7 LeftShiftNode (org.graalvm.compiler.nodes.calc.LeftShiftNode)6 JavaWriteNode (org.graalvm.compiler.nodes.extended.JavaWriteNode)6 AtomicReadAndWriteNode (org.graalvm.compiler.nodes.java.AtomicReadAndWriteNode)6 LoweredAtomicReadAndWriteNode (org.graalvm.compiler.nodes.java.LoweredAtomicReadAndWriteNode)6