Search in sources :

Example 1 with MembarNode

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

the class BytecodeParser method genGetField.

private void genGetField(ResolvedJavaField resolvedField, ValueNode receiver) {
    if (!parsingIntrinsic() && GeneratePIC.getValue(getOptions())) {
        graph.recordField(resolvedField);
    }
    for (NodePlugin plugin : graphBuilderConfig.getPlugins().getNodePlugins()) {
        if (plugin.handleLoadField(this, receiver, resolvedField)) {
            return;
        }
    }
    ValueNode fieldRead = append(genLoadField(receiver, resolvedField));
    if (resolvedField.getDeclaringClass().getName().equals("Ljava/lang/ref/Reference;") && resolvedField.getName().equals("referent")) {
        LocationIdentity referentIdentity = new FieldLocationIdentity(resolvedField);
        append(new MembarNode(0, referentIdentity));
    }
    JavaKind fieldKind = resolvedField.getJavaKind();
    if (resolvedField.isVolatile() && fieldRead instanceof LoadFieldNode) {
        StateSplitProxyNode readProxy = append(genVolatileFieldReadProxy(fieldRead));
        frameState.push(fieldKind, readProxy);
        readProxy.setStateAfter(frameState.create(stream.nextBCI(), readProxy));
    } else {
        frameState.push(fieldKind, fieldRead);
    }
}
Also used : FieldLocationIdentity(org.graalvm.compiler.nodes.FieldLocationIdentity) NodePlugin(org.graalvm.compiler.nodes.graphbuilderconf.NodePlugin) StateSplitProxyNode(org.graalvm.compiler.nodes.extended.StateSplitProxyNode) ValueNode(org.graalvm.compiler.nodes.ValueNode) FieldLocationIdentity(org.graalvm.compiler.nodes.FieldLocationIdentity) LocationIdentity(org.graalvm.word.LocationIdentity) MembarNode(org.graalvm.compiler.nodes.extended.MembarNode) LoadFieldNode(org.graalvm.compiler.nodes.java.LoadFieldNode) JavaKind(jdk.vm.ci.meta.JavaKind)

Example 2 with MembarNode

use of org.graalvm.compiler.nodes.extended.MembarNode 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 3 with MembarNode

use of org.graalvm.compiler.nodes.extended.MembarNode 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;
    WriteNode memoryWrite = graph.add(new WriteNode(address, fieldLocationIdentity(field), value, fieldStoreBarrierType(storeField.field())));
    memoryWrite.setStateAfter(storeField.stateAfter());
    graph.replaceFixedWithFixed(storeField, memoryWrite);
    if (storeField.isVolatile()) {
        MembarNode preMembar = graph.add(new MembarNode(JMM_PRE_VOLATILE_WRITE));
        graph.addBeforeFixed(memoryWrite, preMembar);
        MembarNode postMembar = graph.add(new MembarNode(JMM_POST_VOLATILE_WRITE));
        graph.addAfterFixed(memoryWrite, postMembar);
    }
}
Also used : StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) ValueNode(org.graalvm.compiler.nodes.ValueNode) OffsetAddressNode(org.graalvm.compiler.nodes.memory.address.OffsetAddressNode) AddressNode(org.graalvm.compiler.nodes.memory.address.AddressNode) MembarNode(org.graalvm.compiler.nodes.extended.MembarNode) 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) ResolvedJavaField(jdk.vm.ci.meta.ResolvedJavaField)

Example 4 with MembarNode

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

the class VMThreadMTFeature method handleGet.

private boolean handleGet(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode threadNode, boolean isVolatile) {
    VMThreadLocalInfo threadLocalInfo = threadLocalCollector.findInfo(b, receiver.get());
    if (isVolatile) {
        b.add(new MembarNode(MemoryBarriers.JMM_PRE_VOLATILE_READ));
    }
    b.addPush(targetMethod.getSignature().getReturnKind(), new LoadVMThreadLocalNode(b.getMetaAccess(), threadLocalInfo, threadNode, BarrierType.NONE));
    if (isVolatile) {
        b.add(new MembarNode(MemoryBarriers.JMM_POST_VOLATILE_READ));
    }
    return true;
}
Also used : MembarNode(org.graalvm.compiler.nodes.extended.MembarNode) VMThreadLocalInfo(com.oracle.svm.core.threadlocal.VMThreadLocalInfo) LoadVMThreadLocalNode(com.oracle.svm.core.graal.thread.LoadVMThreadLocalNode)

Example 5 with MembarNode

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

the class VMThreadMTFeature method handleSet.

private boolean handleSet(GraphBuilderContext b, Receiver receiver, ValueNode threadNode, ValueNode valueNode, boolean isVolatile) {
    VMThreadLocalInfo threadLocalInfo = threadLocalCollector.findInfo(b, receiver.get());
    if (isVolatile) {
        b.add(new MembarNode(MemoryBarriers.JMM_PRE_VOLATILE_WRITE));
    }
    b.add(new StoreVMThreadLocalNode(threadLocalInfo, threadNode, valueNode, BarrierType.NONE));
    if (isVolatile) {
        b.add(new MembarNode(MemoryBarriers.JMM_POST_VOLATILE_WRITE));
    }
    return true;
}
Also used : StoreVMThreadLocalNode(com.oracle.svm.core.graal.thread.StoreVMThreadLocalNode) MembarNode(org.graalvm.compiler.nodes.extended.MembarNode) VMThreadLocalInfo(com.oracle.svm.core.threadlocal.VMThreadLocalInfo)

Aggregations

MembarNode (org.graalvm.compiler.nodes.extended.MembarNode)5 ValueNode (org.graalvm.compiler.nodes.ValueNode)3 VMThreadLocalInfo (com.oracle.svm.core.threadlocal.VMThreadLocalInfo)2 ResolvedJavaField (jdk.vm.ci.meta.ResolvedJavaField)2 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)2 AddressNode (org.graalvm.compiler.nodes.memory.address.AddressNode)2 OffsetAddressNode (org.graalvm.compiler.nodes.memory.address.OffsetAddressNode)2 LoadVMThreadLocalNode (com.oracle.svm.core.graal.thread.LoadVMThreadLocalNode)1 StoreVMThreadLocalNode (com.oracle.svm.core.graal.thread.StoreVMThreadLocalNode)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 Stamp (org.graalvm.compiler.core.common.type.Stamp)1 FieldLocationIdentity (org.graalvm.compiler.nodes.FieldLocationIdentity)1 JavaReadNode (org.graalvm.compiler.nodes.extended.JavaReadNode)1 JavaWriteNode (org.graalvm.compiler.nodes.extended.JavaWriteNode)1 StateSplitProxyNode (org.graalvm.compiler.nodes.extended.StateSplitProxyNode)1 NodePlugin (org.graalvm.compiler.nodes.graphbuilderconf.NodePlugin)1 AtomicReadAndWriteNode (org.graalvm.compiler.nodes.java.AtomicReadAndWriteNode)1 LoadFieldNode (org.graalvm.compiler.nodes.java.LoadFieldNode)1