use of org.graalvm.compiler.nodes.memory.MemoryMap 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;
}
Aggregations