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);
}
}
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);
}
}
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);
}
}
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;
}
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;
}
Aggregations