Search in sources :

Example 1 with PrefetchAllocateNode

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

Aggregations

Stamp (org.graalvm.compiler.core.common.type.Stamp)1 Node (org.graalvm.compiler.graph.Node)1 PrefetchAllocateNode (org.graalvm.compiler.nodes.PrefetchAllocateNode)1 ValueNode (org.graalvm.compiler.nodes.ValueNode)1 JavaReadNode (org.graalvm.compiler.nodes.extended.JavaReadNode)1 AbstractWriteNode (org.graalvm.compiler.nodes.memory.AbstractWriteNode)1 FloatingReadNode (org.graalvm.compiler.nodes.memory.FloatingReadNode)1 ReadNode (org.graalvm.compiler.nodes.memory.ReadNode)1 AddressNode (org.graalvm.compiler.nodes.memory.address.AddressNode)1 OffsetAddressNode (org.graalvm.compiler.nodes.memory.address.OffsetAddressNode)1