Search in sources :

Example 6 with ReadNode

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

the class PiNode method canonical.

public static ValueNode canonical(ValueNode object, Stamp stamp, GuardingNode guard) {
    // Use most up to date stamp.
    Stamp computedStamp = stamp.improveWith(object.stamp(NodeView.DEFAULT));
    // The pi node does not give any additional information => skip it.
    if (computedStamp.equals(object.stamp(NodeView.DEFAULT))) {
        return object;
    }
    if (guard == null) {
        // Try to merge the pi node with a load node.
        if (object instanceof ReadNode && !object.hasMoreThanOneUsage()) {
            ReadNode readNode = (ReadNode) object;
            readNode.setStamp(readNode.stamp(NodeView.DEFAULT).improveWith(stamp));
            return readNode;
        }
    } else {
        for (Node n : guard.asNode().usages()) {
            if (n instanceof PiNode) {
                PiNode otherPi = (PiNode) n;
                if (object == otherPi.object() && computedStamp.equals(otherPi.stamp(NodeView.DEFAULT))) {
                    /*
                         * Two PiNodes with the same guard and same result, so return the one with
                         * the more precise piStamp.
                         */
                    Stamp newStamp = stamp.join(otherPi.piStamp);
                    if (newStamp.equals(otherPi.piStamp)) {
                        return otherPi;
                    }
                }
            }
        }
    }
    return null;
}
Also used : ObjectStamp(org.graalvm.compiler.core.common.type.ObjectStamp) AbstractPointerStamp(org.graalvm.compiler.core.common.type.AbstractPointerStamp) Stamp(org.graalvm.compiler.core.common.type.Stamp) ReadNode(org.graalvm.compiler.nodes.memory.ReadNode) VirtualObjectNode(org.graalvm.compiler.nodes.virtual.VirtualObjectNode) Node(org.graalvm.compiler.graph.Node) GuardingNode(org.graalvm.compiler.nodes.extended.GuardingNode) ReadNode(org.graalvm.compiler.nodes.memory.ReadNode)

Example 7 with ReadNode

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

the class OffHeapUnsafeAccessTest method assertExactlyOneArrayLoad.

private void assertExactlyOneArrayLoad(JavaKind elementKind) {
    int total = 0;
    for (ReadNode read : lastCompiledGraph.getNodes().filter(ReadNode.class)) {
        if (read.getLocationIdentity().equals(NamedLocationIdentity.getArrayLocation(elementKind))) {
            total++;
        }
    }
    Assert.assertEquals(1, total);
}
Also used : ReadNode(org.graalvm.compiler.nodes.memory.ReadNode)

Example 8 with ReadNode

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

the class DefaultJavaLoweringProvider method lowerLoadFieldNode.

protected void lowerLoadFieldNode(LoadFieldNode loadField, LoweringTool tool) {
    assert loadField.getStackKind() != JavaKind.Illegal;
    StructuredGraph graph = loadField.graph();
    ResolvedJavaField field = loadField.field();
    ValueNode object = loadField.isStatic() ? staticFieldBase(graph, field) : loadField.object();
    object = createNullCheckedValue(object, loadField, tool);
    Stamp loadStamp = loadStamp(loadField.stamp(NodeView.DEFAULT), getStorageKind(field));
    AddressNode address = createFieldAddress(graph, object, field);
    assert address != null : "Field that is loaded must not be eliminated: " + field.getDeclaringClass().toJavaName(true) + "." + field.getName();
    ReadNode memoryRead = graph.add(new ReadNode(address, fieldLocationIdentity(field), loadStamp, fieldLoadBarrierType(field)));
    ValueNode readValue = implicitLoadConvert(graph, getStorageKind(field), memoryRead);
    loadField.replaceAtUsages(readValue);
    graph.replaceFixed(loadField, memoryRead);
    if (loadField.isVolatile()) {
        MembarNode preMembar = graph.add(new MembarNode(JMM_PRE_VOLATILE_READ));
        graph.addBeforeFixed(memoryRead, preMembar);
        MembarNode postMembar = graph.add(new MembarNode(JMM_POST_VOLATILE_READ));
        graph.addAfterFixed(memoryRead, postMembar);
    }
}
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) OffsetAddressNode(org.graalvm.compiler.nodes.memory.address.OffsetAddressNode) AddressNode(org.graalvm.compiler.nodes.memory.address.AddressNode) JavaReadNode(org.graalvm.compiler.nodes.extended.JavaReadNode) ReadNode(org.graalvm.compiler.nodes.memory.ReadNode) MembarNode(org.graalvm.compiler.nodes.extended.MembarNode) ResolvedJavaField(jdk.vm.ci.meta.ResolvedJavaField)

Example 9 with ReadNode

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

the class DefaultJavaLoweringProvider method lowerUnsafeLoadNode.

/**
 * @param tool utility for performing the lowering
 */
protected void lowerUnsafeLoadNode(RawLoadNode load, LoweringTool tool) {
    StructuredGraph graph = load.graph();
    if (load instanceof GuardedUnsafeLoadNode) {
        GuardedUnsafeLoadNode guardedLoad = (GuardedUnsafeLoadNode) load;
        GuardingNode guard = guardedLoad.getGuard();
        if (guard == null) {
            // can float freely if the guard folded away
            ReadNode memoryRead = createUnsafeRead(graph, load, null);
            memoryRead.setForceFixed(false);
            graph.replaceFixedWithFixed(load, memoryRead);
        } else {
            // must be guarded, but flows below the guard
            ReadNode memoryRead = createUnsafeRead(graph, load, guard);
            graph.replaceFixedWithFixed(load, memoryRead);
        }
    } else {
        // never had a guarding condition so it must be fixed, creation of the read will force
        // it to be fixed
        ReadNode memoryRead = createUnsafeRead(graph, load, null);
        graph.replaceFixedWithFixed(load, memoryRead);
    }
}
Also used : StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) GuardedUnsafeLoadNode(org.graalvm.compiler.nodes.extended.GuardedUnsafeLoadNode) JavaReadNode(org.graalvm.compiler.nodes.extended.JavaReadNode) ReadNode(org.graalvm.compiler.nodes.memory.ReadNode) GuardingNode(org.graalvm.compiler.nodes.extended.GuardingNode)

Example 10 with ReadNode

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

Aggregations

ReadNode (org.graalvm.compiler.nodes.memory.ReadNode)22 ValueNode (org.graalvm.compiler.nodes.ValueNode)14 AddressNode (org.graalvm.compiler.nodes.memory.address.AddressNode)13 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)11 OffsetAddressNode (org.graalvm.compiler.nodes.memory.address.OffsetAddressNode)10 ObjectStamp (org.graalvm.compiler.core.common.type.ObjectStamp)9 Stamp (org.graalvm.compiler.core.common.type.Stamp)9 JavaReadNode (org.graalvm.compiler.nodes.extended.JavaReadNode)8 JavaKind (jdk.vm.ci.meta.JavaKind)7 FloatingReadNode (org.graalvm.compiler.nodes.memory.FloatingReadNode)6 IntegerStamp (org.graalvm.compiler.core.common.type.IntegerStamp)5 ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)4 GuardingNode (org.graalvm.compiler.nodes.extended.GuardingNode)4 ResolvedJavaType (jdk.vm.ci.meta.ResolvedJavaType)3 Node (org.graalvm.compiler.graph.Node)3 ComputeObjectAddressNode (org.graalvm.compiler.hotspot.nodes.ComputeObjectAddressNode)3 GetObjectAddressNode (org.graalvm.compiler.hotspot.nodes.GetObjectAddressNode)3 GraphBuilderContext (org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext)3 Registration (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.Registration)3 WriteNode (org.graalvm.compiler.nodes.memory.WriteNode)3