use of org.graalvm.compiler.nodes.memory.MemoryPhiNode in project graal by oracle.
the class FloatingReadPhase method mergeMemoryMaps.
public static MemoryMapImpl mergeMemoryMaps(AbstractMergeNode merge, List<? extends MemoryMap> states) {
MemoryMapImpl newState = new MemoryMapImpl();
EconomicSet<LocationIdentity> keys = EconomicSet.create(Equivalence.DEFAULT);
for (MemoryMap other : states) {
keys.addAll(other.getLocations());
}
assert checkNoImmutableLocations(keys);
for (LocationIdentity key : keys) {
int mergedStatesCount = 0;
boolean isPhi = false;
MemoryNode merged = null;
for (MemoryMap state : states) {
MemoryNode last = state.getLastLocationAccess(key);
if (isPhi) {
((MemoryPhiNode) merged).addInput(ValueNodeUtil.asNode(last));
} else {
if (merged == last) {
// nothing to do
} else if (merged == null) {
merged = last;
} else {
MemoryPhiNode phi = merge.graph().addWithoutUnique(new MemoryPhiNode(merge, key));
for (int j = 0; j < mergedStatesCount; j++) {
phi.addInput(ValueNodeUtil.asNode(merged));
}
phi.addInput(ValueNodeUtil.asNode(last));
merged = phi;
isPhi = true;
}
}
mergedStatesCount++;
}
newState.lastMemorySnapshot.put(key, merged);
}
return newState;
}
use of org.graalvm.compiler.nodes.memory.MemoryPhiNode in project graal by oracle.
the class MemoryScheduleVerification method processBlock.
@Override
protected EconomicSet<FloatingReadNode> processBlock(Block block, EconomicSet<FloatingReadNode> currentState) {
AbstractBeginNode beginNode = block.getBeginNode();
if (beginNode instanceof AbstractMergeNode) {
AbstractMergeNode abstractMergeNode = (AbstractMergeNode) beginNode;
for (PhiNode phi : abstractMergeNode.phis()) {
if (phi instanceof MemoryPhiNode) {
MemoryPhiNode memoryPhiNode = (MemoryPhiNode) phi;
addFloatingReadUsages(currentState, memoryPhiNode);
}
}
}
for (Node n : blockToNodesMap.get(block)) {
if (n instanceof MemoryCheckpoint) {
if (n instanceof MemoryCheckpoint.Single) {
MemoryCheckpoint.Single single = (MemoryCheckpoint.Single) n;
processLocation(n, single.getLocationIdentity(), currentState);
} else if (n instanceof MemoryCheckpoint.Multi) {
MemoryCheckpoint.Multi multi = (MemoryCheckpoint.Multi) n;
for (LocationIdentity location : multi.getLocationIdentities()) {
processLocation(n, location, currentState);
}
}
addFloatingReadUsages(currentState, n);
} else if (n instanceof MemoryNode) {
addFloatingReadUsages(currentState, n);
} else if (n instanceof FloatingReadNode) {
FloatingReadNode floatingReadNode = (FloatingReadNode) n;
if (floatingReadNode.getLastLocationAccess() != null && floatingReadNode.getLocationIdentity().isMutable()) {
if (currentState.contains(floatingReadNode)) {
// Floating read was found in the state.
currentState.remove(floatingReadNode);
} else {
throw new RuntimeException("Floating read node " + n + " was not found in the state, i.e., it was killed by a memory check point before its place in the schedule. Block=" + block + ", block begin: " + block.getBeginNode() + " block loop: " + block.getLoop() + ", " + blockToNodesMap.get(block).get(0));
}
}
}
}
return currentState;
}
Aggregations