use of org.graalvm.compiler.nodes.memory.address.AddressNode 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.memory.address.AddressNode 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()));
LogicCompareAndSwapNode atomicNode = graph.add(new LogicCompareAndSwapNode(address, cas.getLocationIdentity(), expectedValue, newValue, compareAndSwapBarrierType(cas)));
atomicNode.setStateAfter(cas.stateAfter());
graph.replaceFixedWithFixed(cas, atomicNode);
}
use of org.graalvm.compiler.nodes.memory.address.AddressNode in project graal by oracle.
the class DefaultJavaLoweringProvider method lowerStoreIndexedNode.
protected void lowerStoreIndexedNode(StoreIndexedNode storeIndexed, LoweringTool tool) {
StructuredGraph graph = storeIndexed.graph();
ValueNode value = storeIndexed.value();
ValueNode array = storeIndexed.array();
array = this.createNullCheckedValue(array, storeIndexed, tool);
GuardingNode boundsCheck = getBoundsCheck(storeIndexed, array, tool);
JavaKind elementKind = storeIndexed.elementKind();
LogicNode condition = null;
if (elementKind == JavaKind.Object && !StampTool.isPointerAlwaysNull(value)) {
/* Array store check. */
TypeReference arrayType = StampTool.typeReferenceOrNull(array);
if (arrayType != null && arrayType.isExact()) {
ResolvedJavaType elementType = arrayType.getType().getComponentType();
if (!elementType.isJavaLangObject()) {
TypeReference typeReference = TypeReference.createTrusted(storeIndexed.graph().getAssumptions(), elementType);
LogicNode typeTest = graph.addOrUniqueWithInputs(InstanceOfNode.create(typeReference, value));
condition = LogicNode.or(graph.unique(IsNullNode.create(value)), typeTest, GraalDirectives.UNLIKELY_PROBABILITY);
}
} else {
/*
* The guard on the read hub should be the null check of the array that was
* introduced earlier.
*/
ValueNode arrayClass = createReadHub(graph, array, tool);
ValueNode componentHub = createReadArrayComponentHub(graph, arrayClass, storeIndexed);
LogicNode typeTest = graph.unique(InstanceOfDynamicNode.create(graph.getAssumptions(), tool.getConstantReflection(), componentHub, value, false));
condition = LogicNode.or(graph.unique(IsNullNode.create(value)), typeTest, GraalDirectives.UNLIKELY_PROBABILITY);
}
}
AddressNode address = createArrayIndexAddress(graph, array, elementKind, storeIndexed.index(), boundsCheck);
WriteNode memoryWrite = graph.add(new WriteNode(address, NamedLocationIdentity.getArrayLocation(elementKind), implicitStoreConvert(graph, elementKind, value), arrayStoreBarrierType(storeIndexed.elementKind())));
memoryWrite.setGuard(boundsCheck);
if (condition != null) {
tool.createGuard(storeIndexed, condition, DeoptimizationReason.ArrayStoreException, DeoptimizationAction.InvalidateReprofile);
}
memoryWrite.setStateAfter(storeIndexed.stateAfter());
graph.replaceFixedWithFixed(storeIndexed, memoryWrite);
}
use of org.graalvm.compiler.nodes.memory.address.AddressNode 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.memory.address.AddressNode in project graal by oracle.
the class AArch64ReadNode method replace.
/**
* replace a ReadNode with an AArch64-specific variant which knows how to merge a downstream
* zero or sign extend into the read operation.
*
* @param readNode
*/
public static void replace(ReadNode readNode) {
assert readNode.getUsageCount() == 1;
assert readNode.getUsageAt(0) instanceof ZeroExtendNode || readNode.getUsageAt(0) instanceof SignExtendNode;
ValueNode usage = (ValueNode) readNode.getUsageAt(0);
boolean isSigned = usage instanceof SignExtendNode;
IntegerStamp accessStamp = ((IntegerStamp) readNode.getAccessStamp());
AddressNode address = readNode.getAddress();
LocationIdentity location = readNode.getLocationIdentity();
Stamp stamp = usage.stamp(NodeView.DEFAULT);
GuardingNode guard = readNode.getGuard();
BarrierType barrierType = readNode.getBarrierType();
boolean nullCheck = readNode.getNullCheck();
FrameState stateBefore = readNode.stateBefore();
AArch64ReadNode clone = new AArch64ReadNode(address, location, stamp, guard, barrierType, nullCheck, stateBefore, accessStamp, isSigned);
StructuredGraph graph = readNode.graph();
graph.add(clone);
// splice out the extend node
usage.replaceAtUsagesAndDelete(readNode);
// swap the clone for the read
graph.replaceFixedWithFixed(readNode, clone);
}
Aggregations