Search in sources :

Example 1 with JavaReadNode

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

the class AddressLoweringByUsePhase method run.

@Override
protected void run(StructuredGraph graph) {
    // first replace address nodes hanging off known usages
    for (Node node : graph.getNodes()) {
        AddressNode address;
        AddressNode lowered;
        if (node instanceof ReadNode) {
            ReadNode readNode = (ReadNode) node;
            Stamp stamp = readNode.stamp(NodeView.DEFAULT);
            address = readNode.getAddress();
            lowered = lowering.lower(readNode, stamp, address);
        } else if (node instanceof JavaReadNode) {
            JavaReadNode javaReadNode = (JavaReadNode) node;
            Stamp stamp = javaReadNode.stamp(NodeView.DEFAULT);
            address = javaReadNode.getAddress();
            lowered = lowering.lower(javaReadNode, stamp, address);
        } else if (node instanceof FloatingReadNode) {
            FloatingReadNode floatingReadNode = (FloatingReadNode) node;
            Stamp stamp = floatingReadNode.stamp(NodeView.DEFAULT);
            address = floatingReadNode.getAddress();
            lowered = lowering.lower(floatingReadNode, stamp, address);
        } else if (node instanceof AbstractWriteNode) {
            AbstractWriteNode abstractWriteNode = (AbstractWriteNode) node;
            Stamp stamp = abstractWriteNode.value().stamp(NodeView.DEFAULT);
            address = abstractWriteNode.getAddress();
            lowered = lowering.lower(abstractWriteNode, stamp, address);
        } else if (node instanceof PrefetchAllocateNode) {
            PrefetchAllocateNode prefetchAllocateNode = (PrefetchAllocateNode) node;
            Stamp stamp = StampFactory.forKind(JavaKind.Object);
            address = (AddressNode) prefetchAllocateNode.inputs().first();
            lowered = lowering.lower(prefetchAllocateNode, stamp, address);
        } else {
            continue;
        }
        // in which case we want to use it not delete it!
        if (lowered != address) {
            // replace original with lowered at this usage only
            // n.b. lowered is added unique so repeat lowerings will elide
            node.replaceFirstInput(address, lowered);
            // if that was the last reference we can kill the old (dead) node
            if (address.hasNoUsages()) {
                GraphUtil.killWithUnusedFloatingInputs(address);
            }
        }
    }
    // now replace any remaining unlowered address nodes
    for (Node node : graph.getNodes()) {
        AddressNode lowered;
        if (node instanceof OffsetAddressNode) {
            AddressNode address = (AddressNode) node;
            lowered = lowering.lower(address);
        } else {
            continue;
        }
        // will always be a new AddresNode
        node.replaceAtUsages(lowered);
        GraphUtil.killWithUnusedFloatingInputs(node);
    }
}
Also used : JavaReadNode(org.graalvm.compiler.nodes.extended.JavaReadNode) Stamp(org.graalvm.compiler.core.common.type.Stamp) OffsetAddressNode(org.graalvm.compiler.nodes.memory.address.OffsetAddressNode) AbstractWriteNode(org.graalvm.compiler.nodes.memory.AbstractWriteNode) FloatingReadNode(org.graalvm.compiler.nodes.memory.FloatingReadNode) ReadNode(org.graalvm.compiler.nodes.memory.ReadNode) AddressNode(org.graalvm.compiler.nodes.memory.address.AddressNode) OffsetAddressNode(org.graalvm.compiler.nodes.memory.address.OffsetAddressNode) ValueNode(org.graalvm.compiler.nodes.ValueNode) PrefetchAllocateNode(org.graalvm.compiler.nodes.PrefetchAllocateNode) Node(org.graalvm.compiler.graph.Node) JavaReadNode(org.graalvm.compiler.nodes.extended.JavaReadNode) FloatingReadNode(org.graalvm.compiler.nodes.memory.FloatingReadNode) AddressNode(org.graalvm.compiler.nodes.memory.address.AddressNode) OffsetAddressNode(org.graalvm.compiler.nodes.memory.address.OffsetAddressNode) FloatingReadNode(org.graalvm.compiler.nodes.memory.FloatingReadNode) ReadNode(org.graalvm.compiler.nodes.memory.ReadNode) JavaReadNode(org.graalvm.compiler.nodes.extended.JavaReadNode) AbstractWriteNode(org.graalvm.compiler.nodes.memory.AbstractWriteNode) PrefetchAllocateNode(org.graalvm.compiler.nodes.PrefetchAllocateNode)

Example 2 with JavaReadNode

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

the class DefaultJavaLoweringProvider method lowerJavaReadNode.

protected void lowerJavaReadNode(JavaReadNode read) {
    StructuredGraph graph = read.graph();
    JavaKind valueKind = read.getReadKind();
    Stamp loadStamp = loadStamp(read.stamp(NodeView.DEFAULT), valueKind, read.isCompressible());
    ReadNode memoryRead = graph.add(new ReadNode(read.getAddress(), read.getLocationIdentity(), loadStamp, read.getBarrierType()));
    GuardingNode guard = read.getGuard();
    ValueNode readValue = implicitLoadConvert(graph, valueKind, memoryRead, read.isCompressible());
    if (guard == null) {
        // An unsafe read must not float otherwise it may float above
        // a test guaranteeing the read is safe.
        memoryRead.setForceFixed(true);
    } else {
        memoryRead.setGuard(guard);
    }
    read.replaceAtUsages(readValue);
    graph.replaceFixed(read, memoryRead);
}
Also used : StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) ObjectStamp(org.graalvm.compiler.core.common.type.ObjectStamp) Stamp(org.graalvm.compiler.core.common.type.Stamp) IntegerStamp(org.graalvm.compiler.core.common.type.IntegerStamp) ValueNode(org.graalvm.compiler.nodes.ValueNode) JavaReadNode(org.graalvm.compiler.nodes.extended.JavaReadNode) ReadNode(org.graalvm.compiler.nodes.memory.ReadNode) GuardingNode(org.graalvm.compiler.nodes.extended.GuardingNode) JavaKind(jdk.vm.ci.meta.JavaKind)

Example 3 with JavaReadNode

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

the class ObjectAccessTest method assertRead.

private static void assertRead(StructuredGraph graph, JavaKind kind, boolean indexConvert, LocationIdentity locationIdentity) {
    JavaReadNode read = (JavaReadNode) graph.start().next();
    Assert.assertEquals(kind.getStackKind(), read.stamp(NodeView.DEFAULT).getStackKind());
    OffsetAddressNode address = (OffsetAddressNode) read.getAddress();
    Assert.assertEquals(graph.getParameter(0), address.getBase());
    Assert.assertEquals(locationIdentity, read.getLocationIdentity());
    if (indexConvert) {
        SignExtendNode convert = (SignExtendNode) address.getOffset();
        Assert.assertEquals(convert.getInputBits(), 32);
        Assert.assertEquals(convert.getResultBits(), 64);
        Assert.assertEquals(graph.getParameter(1), convert.getValue());
    } else {
        Assert.assertEquals(graph.getParameter(1), address.getOffset());
    }
    ReturnNode ret = (ReturnNode) read.next();
    Assert.assertEquals(read, ret.result());
}
Also used : JavaReadNode(org.graalvm.compiler.nodes.extended.JavaReadNode) ReturnNode(org.graalvm.compiler.nodes.ReturnNode) OffsetAddressNode(org.graalvm.compiler.nodes.memory.address.OffsetAddressNode) SignExtendNode(org.graalvm.compiler.nodes.calc.SignExtendNode)

Example 4 with JavaReadNode

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

the class PointerTest method assertRead.

private void assertRead(StructuredGraph graph, JavaKind kind, boolean indexConvert, LocationIdentity locationIdentity) {
    WordCastNode cast = (WordCastNode) graph.start().next();
    JavaReadNode read = (JavaReadNode) cast.next();
    Assert.assertEquals(kind.getStackKind(), read.stamp(NodeView.DEFAULT).getStackKind());
    OffsetAddressNode address = (OffsetAddressNode) read.getAddress();
    Assert.assertEquals(cast, address.getBase());
    Assert.assertEquals(graph.getParameter(0), cast.getInput());
    Assert.assertEquals(target.wordJavaKind, cast.stamp(NodeView.DEFAULT).getStackKind());
    Assert.assertEquals(locationIdentity, read.getLocationIdentity());
    if (indexConvert) {
        SignExtendNode convert = (SignExtendNode) address.getOffset();
        Assert.assertEquals(convert.getInputBits(), 32);
        Assert.assertEquals(convert.getResultBits(), 64);
        Assert.assertEquals(graph.getParameter(1), convert.getValue());
    } else {
        Assert.assertEquals(graph.getParameter(1), address.getOffset());
    }
    ReturnNode ret = (ReturnNode) read.next();
    Assert.assertEquals(read, ret.result());
}
Also used : JavaReadNode(org.graalvm.compiler.nodes.extended.JavaReadNode) ReturnNode(org.graalvm.compiler.nodes.ReturnNode) WordCastNode(org.graalvm.compiler.word.WordCastNode) OffsetAddressNode(org.graalvm.compiler.nodes.memory.address.OffsetAddressNode) SignExtendNode(org.graalvm.compiler.nodes.calc.SignExtendNode)

Example 5 with JavaReadNode

use of org.graalvm.compiler.nodes.extended.JavaReadNode 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)

Aggregations

JavaReadNode (org.graalvm.compiler.nodes.extended.JavaReadNode)5 OffsetAddressNode (org.graalvm.compiler.nodes.memory.address.OffsetAddressNode)4 Stamp (org.graalvm.compiler.core.common.type.Stamp)2 ReturnNode (org.graalvm.compiler.nodes.ReturnNode)2 ValueNode (org.graalvm.compiler.nodes.ValueNode)2 SignExtendNode (org.graalvm.compiler.nodes.calc.SignExtendNode)2 ReadNode (org.graalvm.compiler.nodes.memory.ReadNode)2 AddressNode (org.graalvm.compiler.nodes.memory.address.AddressNode)2 CInterfaceReadNode (com.oracle.svm.core.graal.nodes.CInterfaceReadNode)1 JavaKind (jdk.vm.ci.meta.JavaKind)1 IntegerStamp (org.graalvm.compiler.core.common.type.IntegerStamp)1 ObjectStamp (org.graalvm.compiler.core.common.type.ObjectStamp)1 Node (org.graalvm.compiler.graph.Node)1 ConstantNode (org.graalvm.compiler.nodes.ConstantNode)1 PrefetchAllocateNode (org.graalvm.compiler.nodes.PrefetchAllocateNode)1 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)1 GuardingNode (org.graalvm.compiler.nodes.extended.GuardingNode)1 AbstractWriteNode (org.graalvm.compiler.nodes.memory.AbstractWriteNode)1 FixedAccessNode (org.graalvm.compiler.nodes.memory.FixedAccessNode)1 FloatingReadNode (org.graalvm.compiler.nodes.memory.FloatingReadNode)1