Search in sources :

Example 1 with MemoryMap

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;
}
Also used : MemoryMap(org.graalvm.compiler.nodes.memory.MemoryMap) MemoryNode(org.graalvm.compiler.nodes.memory.MemoryNode) MemoryPhiNode(org.graalvm.compiler.nodes.memory.MemoryPhiNode) LocationIdentity(org.graalvm.word.LocationIdentity) MemoryCheckpoint(org.graalvm.compiler.nodes.memory.MemoryCheckpoint)

Aggregations

MemoryCheckpoint (org.graalvm.compiler.nodes.memory.MemoryCheckpoint)1 MemoryMap (org.graalvm.compiler.nodes.memory.MemoryMap)1 MemoryNode (org.graalvm.compiler.nodes.memory.MemoryNode)1 MemoryPhiNode (org.graalvm.compiler.nodes.memory.MemoryPhiNode)1 LocationIdentity (org.graalvm.word.LocationIdentity)1