Search in sources :

Example 1 with OrderedReadNode

use of org.graalvm.compiler.nodes.memory.OrderedReadNode 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;
    BarrierType barrierType = barrierSet.fieldLoadBarrierType(field, getStorageKind(field));
    if (loadField.ordersMemoryAccesses()) {
        memoryRead = graph.add(new OrderedReadNode(address, loadStamp, barrierType, loadField.getMemoryOrder()));
    } else {
        memoryRead = graph.add(new ReadNode(address, fieldLocationIdentity(field), loadStamp, barrierType));
    }
    ValueNode readValue = implicitLoadConvert(graph, getStorageKind(field), memoryRead);
    loadField.replaceAtUsages(readValue);
    graph.replaceFixed(loadField, memoryRead);
}
Also used : StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) ObjectStamp(org.graalvm.compiler.core.common.type.ObjectStamp) AbstractPointerStamp(org.graalvm.compiler.core.common.type.AbstractPointerStamp) Stamp(org.graalvm.compiler.core.common.type.Stamp) IntegerStamp(org.graalvm.compiler.core.common.type.IntegerStamp) ValueNode(org.graalvm.compiler.nodes.ValueNode) OrderedReadNode(org.graalvm.compiler.nodes.memory.OrderedReadNode) GetObjectAddressNode(org.graalvm.compiler.nodes.GetObjectAddressNode) IndexAddressNode(org.graalvm.compiler.nodes.memory.address.IndexAddressNode) ComputeObjectAddressNode(org.graalvm.compiler.nodes.ComputeObjectAddressNode) OffsetAddressNode(org.graalvm.compiler.nodes.memory.address.OffsetAddressNode) AddressNode(org.graalvm.compiler.nodes.memory.address.AddressNode) OrderedReadNode(org.graalvm.compiler.nodes.memory.OrderedReadNode) JavaReadNode(org.graalvm.compiler.nodes.extended.JavaReadNode) ReadNode(org.graalvm.compiler.nodes.memory.ReadNode) BarrierType(org.graalvm.compiler.nodes.memory.OnHeapMemoryAccess.BarrierType) ResolvedJavaField(jdk.vm.ci.meta.ResolvedJavaField)

Example 2 with OrderedReadNode

use of org.graalvm.compiler.nodes.memory.OrderedReadNode 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;
    if (read.ordersMemoryAccesses()) {
        memoryRead = graph.add(new OrderedReadNode(read.getAddress(), loadStamp, read.getBarrierType(), read.getMemoryOrder()));
    } else {
        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) AbstractPointerStamp(org.graalvm.compiler.core.common.type.AbstractPointerStamp) Stamp(org.graalvm.compiler.core.common.type.Stamp) IntegerStamp(org.graalvm.compiler.core.common.type.IntegerStamp) OrderedReadNode(org.graalvm.compiler.nodes.memory.OrderedReadNode) ValueNode(org.graalvm.compiler.nodes.ValueNode) OrderedReadNode(org.graalvm.compiler.nodes.memory.OrderedReadNode) 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 OrderedReadNode

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

the class DefaultJavaLoweringProvider method createUnsafeRead.

protected ReadNode createUnsafeRead(StructuredGraph graph, RawLoadNode load, GuardingNode guard) {
    boolean compressible = load.accessKind() == JavaKind.Object;
    JavaKind readKind = load.accessKind();
    Stamp loadStamp = loadStamp(load.stamp(NodeView.DEFAULT), readKind, compressible);
    AddressNode address = createUnsafeAddress(graph, load.object(), load.offset());
    ReadNode memoryRead;
    if (load.ordersMemoryAccesses()) {
        memoryRead = new OrderedReadNode(address, loadStamp, barrierSet.readBarrierType(load), load.getMemoryOrder());
    } else {
        memoryRead = new ReadNode(address, load.getLocationIdentity(), loadStamp, barrierSet.readBarrierType(load));
    }
    memoryRead = graph.add(memoryRead);
    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);
    }
    ValueNode readValue = performBooleanCoercionIfNecessary(implicitLoadConvert(graph, readKind, memoryRead, compressible), readKind);
    load.replaceAtUsages(readValue);
    return memoryRead;
}
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) IntegerStamp(org.graalvm.compiler.core.common.type.IntegerStamp) OrderedReadNode(org.graalvm.compiler.nodes.memory.OrderedReadNode) ValueNode(org.graalvm.compiler.nodes.ValueNode) GetObjectAddressNode(org.graalvm.compiler.nodes.GetObjectAddressNode) IndexAddressNode(org.graalvm.compiler.nodes.memory.address.IndexAddressNode) ComputeObjectAddressNode(org.graalvm.compiler.nodes.ComputeObjectAddressNode) OffsetAddressNode(org.graalvm.compiler.nodes.memory.address.OffsetAddressNode) AddressNode(org.graalvm.compiler.nodes.memory.address.AddressNode) OrderedReadNode(org.graalvm.compiler.nodes.memory.OrderedReadNode) JavaReadNode(org.graalvm.compiler.nodes.extended.JavaReadNode) ReadNode(org.graalvm.compiler.nodes.memory.ReadNode) JavaKind(jdk.vm.ci.meta.JavaKind)

Aggregations

AbstractPointerStamp (org.graalvm.compiler.core.common.type.AbstractPointerStamp)3 IntegerStamp (org.graalvm.compiler.core.common.type.IntegerStamp)3 ObjectStamp (org.graalvm.compiler.core.common.type.ObjectStamp)3 Stamp (org.graalvm.compiler.core.common.type.Stamp)3 ValueNode (org.graalvm.compiler.nodes.ValueNode)3 JavaReadNode (org.graalvm.compiler.nodes.extended.JavaReadNode)3 OrderedReadNode (org.graalvm.compiler.nodes.memory.OrderedReadNode)3 ReadNode (org.graalvm.compiler.nodes.memory.ReadNode)3 JavaKind (jdk.vm.ci.meta.JavaKind)2 ComputeObjectAddressNode (org.graalvm.compiler.nodes.ComputeObjectAddressNode)2 GetObjectAddressNode (org.graalvm.compiler.nodes.GetObjectAddressNode)2 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)2 AddressNode (org.graalvm.compiler.nodes.memory.address.AddressNode)2 IndexAddressNode (org.graalvm.compiler.nodes.memory.address.IndexAddressNode)2 OffsetAddressNode (org.graalvm.compiler.nodes.memory.address.OffsetAddressNode)2 ResolvedJavaField (jdk.vm.ci.meta.ResolvedJavaField)1 GuardingNode (org.graalvm.compiler.nodes.extended.GuardingNode)1 BarrierType (org.graalvm.compiler.nodes.memory.OnHeapMemoryAccess.BarrierType)1