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