Search in sources :

Example 1 with BarrierType

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

the class G1BarrierSet method addWriteBarriers.

private void addWriteBarriers(FixedAccessNode node, ValueNode writtenValue, ValueNode expectedValue, boolean doLoad, boolean nullCheck) {
    BarrierType barrierType = node.getBarrierType();
    switch(barrierType) {
        case NONE:
            // nothing to do
            break;
        case FIELD:
        case ARRAY:
        case UNKNOWN:
            if (isObjectValue(writtenValue)) {
                StructuredGraph graph = node.graph();
                boolean init = node.getLocationIdentity().isInit();
                if (!init) {
                    // The pre barrier does nothing if the value being read is null, so it can
                    // be explicitly skipped when this is an initializing store.
                    addG1PreWriteBarrier(node, node.getAddress(), expectedValue, doLoad, nullCheck, graph);
                }
                if (writeRequiresPostBarrier(node, writtenValue)) {
                    // Use a precise barrier for everything that might be an array write. Being
                    // too precise with the barriers does not cause any correctness issues.
                    boolean precise = barrierType != BarrierType.FIELD;
                    addG1PostWriteBarrier(node, node.getAddress(), writtenValue, precise, graph);
                }
            }
            break;
        default:
            throw new GraalError("unexpected barrier type: " + barrierType);
    }
}
Also used : StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) GraalError(org.graalvm.compiler.debug.GraalError) BarrierType(org.graalvm.compiler.nodes.memory.OnHeapMemoryAccess.BarrierType)

Example 2 with BarrierType

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

the class DefaultJavaLoweringProvider method lowerAtomicReadAndAddNode.

protected void lowerAtomicReadAndAddNode(AtomicReadAndAddNode n) {
    StructuredGraph graph = n.graph();
    JavaKind valueKind = n.getValueKind();
    ValueNode delta = implicitStoreConvert(graph, valueKind, n.delta());
    AddressNode address = graph.unique(new OffsetAddressNode(n.object(), n.offset()));
    BarrierType barrierType = barrierSet.guessStoreBarrierType(n.object(), delta);
    LIRKind lirAccessKind = LIRKind.fromJavaKind(target.arch, valueKind);
    LoweredAtomicReadAndAddNode memoryRead = graph.add(new LoweredAtomicReadAndAddNode(address, n.getKilledLocationIdentity(), delta, lirAccessKind, barrierType));
    memoryRead.setStateAfter(n.stateAfter());
    ValueNode readValue = implicitLoadConvert(graph, valueKind, memoryRead);
    n.stateAfter().replaceFirstInput(n, memoryRead);
    n.replaceAtUsages(readValue);
    graph.replaceFixedWithFixed(n, memoryRead);
}
Also used : StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) OffsetAddressNode(org.graalvm.compiler.nodes.memory.address.OffsetAddressNode) LoweredAtomicReadAndAddNode(org.graalvm.compiler.nodes.java.LoweredAtomicReadAndAddNode) 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) LIRKind(org.graalvm.compiler.core.common.LIRKind) BarrierType(org.graalvm.compiler.nodes.memory.OnHeapMemoryAccess.BarrierType) JavaKind(jdk.vm.ci.meta.JavaKind)

Example 3 with BarrierType

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

the class DefaultJavaLoweringProvider method lowerCompareAndSwapNode.

protected void lowerCompareAndSwapNode(UnsafeCompareAndSwapNode cas) {
    StructuredGraph graph = cas.graph();
    JavaKind valueKind = cas.getValueKind();
    ValueNode expectedValue = implicitStoreConvert(graph, valueKind, cas.expected());
    ValueNode newValue = implicitStoreConvert(graph, valueKind, cas.newValue());
    AddressNode address = graph.unique(new OffsetAddressNode(cas.object(), cas.offset()));
    BarrierType barrierType = barrierSet.guessStoreBarrierType(cas.object(), newValue);
    LogicCompareAndSwapNode atomicNode = graph.add(new LogicCompareAndSwapNode(address, expectedValue, newValue, cas.getKilledLocationIdentity(), barrierType, cas.getMemoryOrder()));
    atomicNode.setStateAfter(cas.stateAfter());
    graph.replaceFixedWithFixed(cas, atomicNode);
}
Also used : LogicCompareAndSwapNode(org.graalvm.compiler.nodes.java.LogicCompareAndSwapNode) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) OffsetAddressNode(org.graalvm.compiler.nodes.memory.address.OffsetAddressNode) 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) BarrierType(org.graalvm.compiler.nodes.memory.OnHeapMemoryAccess.BarrierType) JavaKind(jdk.vm.ci.meta.JavaKind)

Example 4 with BarrierType

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

the class DefaultJavaLoweringProvider method lowerStoreFieldNode.

protected void lowerStoreFieldNode(StoreFieldNode storeField, LoweringTool tool) {
    StructuredGraph graph = storeField.graph();
    ResolvedJavaField field = storeField.field();
    ValueNode object = storeField.isStatic() ? staticFieldBase(graph, field) : storeField.object();
    object = createNullCheckedValue(object, storeField, tool);
    ValueNode value = implicitStoreConvert(graph, getStorageKind(storeField.field()), storeField.value());
    AddressNode address = createFieldAddress(graph, object, field);
    assert address != null;
    BarrierType barrierType = barrierSet.fieldStoreBarrierType(field, getStorageKind(field));
    WriteNode memoryWrite;
    if (storeField.ordersMemoryAccesses()) {
        memoryWrite = graph.add(new OrderedWriteNode(address, fieldLocationIdentity(field), value, barrierType, storeField.getMemoryOrder()));
    } else {
        memoryWrite = graph.add(new WriteNode(address, fieldLocationIdentity(field), value, barrierType));
    }
    memoryWrite.setStateAfter(storeField.stateAfter());
    graph.replaceFixedWithFixed(storeField, memoryWrite);
}
Also used : StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) OrderedWriteNode(org.graalvm.compiler.nodes.memory.OrderedWriteNode) 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) OrderedWriteNode(org.graalvm.compiler.nodes.memory.OrderedWriteNode) WriteNode(org.graalvm.compiler.nodes.memory.WriteNode) AtomicReadAndWriteNode(org.graalvm.compiler.nodes.java.AtomicReadAndWriteNode) JavaWriteNode(org.graalvm.compiler.nodes.extended.JavaWriteNode) LoweredAtomicReadAndWriteNode(org.graalvm.compiler.nodes.java.LoweredAtomicReadAndWriteNode) BarrierType(org.graalvm.compiler.nodes.memory.OnHeapMemoryAccess.BarrierType) ResolvedJavaField(jdk.vm.ci.meta.ResolvedJavaField)

Example 5 with BarrierType

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

Aggregations

BarrierType (org.graalvm.compiler.nodes.memory.OnHeapMemoryAccess.BarrierType)13 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)9 ValueNode (org.graalvm.compiler.nodes.ValueNode)9 AddressNode (org.graalvm.compiler.nodes.memory.address.AddressNode)9 OffsetAddressNode (org.graalvm.compiler.nodes.memory.address.OffsetAddressNode)9 ComputeObjectAddressNode (org.graalvm.compiler.nodes.ComputeObjectAddressNode)8 GetObjectAddressNode (org.graalvm.compiler.nodes.GetObjectAddressNode)8 IndexAddressNode (org.graalvm.compiler.nodes.memory.address.IndexAddressNode)8 JavaKind (jdk.vm.ci.meta.JavaKind)7 JavaWriteNode (org.graalvm.compiler.nodes.extended.JavaWriteNode)4 LoweredAtomicReadAndWriteNode (org.graalvm.compiler.nodes.java.LoweredAtomicReadAndWriteNode)4 ResolvedJavaField (jdk.vm.ci.meta.ResolvedJavaField)3 AtomicReadAndWriteNode (org.graalvm.compiler.nodes.java.AtomicReadAndWriteNode)3 OrderedWriteNode (org.graalvm.compiler.nodes.memory.OrderedWriteNode)3 WriteNode (org.graalvm.compiler.nodes.memory.WriteNode)3 ResolvedJavaType (jdk.vm.ci.meta.ResolvedJavaType)2 LIRKind (org.graalvm.compiler.core.common.LIRKind)2 GraalError (org.graalvm.compiler.debug.GraalError)2 JavaReadNode (org.graalvm.compiler.nodes.extended.JavaReadNode)2 ArrayList (java.util.ArrayList)1