use of org.graalvm.compiler.nodes.memory.ReadNode in project graal by oracle.
the class PiNode method canonical.
public static ValueNode canonical(ValueNode object, Stamp stamp, GuardingNode guard) {
// Use most up to date stamp.
Stamp computedStamp = stamp.improveWith(object.stamp(NodeView.DEFAULT));
// The pi node does not give any additional information => skip it.
if (computedStamp.equals(object.stamp(NodeView.DEFAULT))) {
return object;
}
if (guard == null) {
// Try to merge the pi node with a load node.
if (object instanceof ReadNode && !object.hasMoreThanOneUsage()) {
ReadNode readNode = (ReadNode) object;
readNode.setStamp(readNode.stamp(NodeView.DEFAULT).improveWith(stamp));
return readNode;
}
} else {
for (Node n : guard.asNode().usages()) {
if (n instanceof PiNode) {
PiNode otherPi = (PiNode) n;
if (object == otherPi.object() && computedStamp.equals(otherPi.stamp(NodeView.DEFAULT))) {
/*
* Two PiNodes with the same guard and same result, so return the one with
* the more precise piStamp.
*/
Stamp newStamp = stamp.join(otherPi.piStamp);
if (newStamp.equals(otherPi.piStamp)) {
return otherPi;
}
}
}
}
}
return null;
}
use of org.graalvm.compiler.nodes.memory.ReadNode in project graal by oracle.
the class OffHeapUnsafeAccessTest method assertExactlyOneArrayLoad.
private void assertExactlyOneArrayLoad(JavaKind elementKind) {
int total = 0;
for (ReadNode read : lastCompiledGraph.getNodes().filter(ReadNode.class)) {
if (read.getLocationIdentity().equals(NamedLocationIdentity.getArrayLocation(elementKind))) {
total++;
}
}
Assert.assertEquals(1, total);
}
use of org.graalvm.compiler.nodes.memory.ReadNode 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.ReadNode in project graal by oracle.
the class DefaultJavaLoweringProvider method lowerUnsafeLoadNode.
/**
* @param tool utility for performing the lowering
*/
protected void lowerUnsafeLoadNode(RawLoadNode load, LoweringTool tool) {
StructuredGraph graph = load.graph();
if (load instanceof GuardedUnsafeLoadNode) {
GuardedUnsafeLoadNode guardedLoad = (GuardedUnsafeLoadNode) load;
GuardingNode guard = guardedLoad.getGuard();
if (guard == null) {
// can float freely if the guard folded away
ReadNode memoryRead = createUnsafeRead(graph, load, null);
memoryRead.setForceFixed(false);
graph.replaceFixedWithFixed(load, memoryRead);
} else {
// must be guarded, but flows below the guard
ReadNode memoryRead = createUnsafeRead(graph, load, guard);
graph.replaceFixedWithFixed(load, memoryRead);
}
} else {
// never had a guarding condition so it must be fixed, creation of the read will force
// it to be fixed
ReadNode memoryRead = createUnsafeRead(graph, load, null);
graph.replaceFixedWithFixed(load, memoryRead);
}
}
use of org.graalvm.compiler.nodes.memory.ReadNode in project graal by oracle.
the class DefaultJavaLoweringProvider method lowerJavaReadNode.
protected void lowerJavaReadNode(JavaReadNode read) {
StructuredGraph graph = read.graph();
JavaKind valueKind = read.getReadKind();
Stamp loadStamp = loadStamp(read.stamp(NodeView.DEFAULT), valueKind, read.isCompressible());
ReadNode memoryRead = graph.add(new ReadNode(read.getAddress(), read.getLocationIdentity(), loadStamp, read.getBarrierType()));
GuardingNode guard = read.getGuard();
ValueNode readValue = implicitLoadConvert(graph, valueKind, memoryRead, read.isCompressible());
if (guard == null) {
// An unsafe read must not float otherwise it may float above
// a test guaranteeing the read is safe.
memoryRead.setForceFixed(true);
} else {
memoryRead.setGuard(guard);
}
read.replaceAtUsages(readValue);
graph.replaceFixed(read, memoryRead);
}
Aggregations