Search in sources :

Example 36 with FixedNode

use of org.graalvm.compiler.nodes.FixedNode in project graal by oracle.

the class GraphEffectList method addCounterAfter.

public void addCounterAfter(String group, String name, int increment, boolean addContext, FixedWithNextNode position) {
    FixedNode nextPosition = position.next();
    add("add counter after", graph -> DynamicCounterNode.addCounterBefore(group, name, increment, addContext, nextPosition));
}
Also used : FixedNode(org.graalvm.compiler.nodes.FixedNode)

Example 37 with FixedNode

use of org.graalvm.compiler.nodes.FixedNode in project graal by oracle.

the class PartialEscapeBlockState method materializeBefore.

/**
 * Materializes the given virtual object and produces the necessary effects in the effects list.
 * This transitively also materializes all other virtual objects that are reachable from the
 * entries.
 */
public void materializeBefore(FixedNode fixed, VirtualObjectNode virtual, GraphEffectList materializeEffects) {
    PartialEscapeClosure.COUNTER_MATERIALIZATIONS.increment(fixed.getDebug());
    List<AllocatedObjectNode> objects = new ArrayList<>(2);
    List<ValueNode> values = new ArrayList<>(8);
    List<List<MonitorIdNode>> locks = new ArrayList<>();
    List<ValueNode> otherAllocations = new ArrayList<>(2);
    List<Boolean> ensureVirtual = new ArrayList<>(2);
    materializeWithCommit(fixed, virtual, objects, locks, values, ensureVirtual, otherAllocations);
    materializeEffects.addVirtualizationDelta(-(objects.size() + otherAllocations.size()));
    materializeEffects.add("materializeBefore", new Effect() {

        @Override
        public void apply(StructuredGraph graph, ArrayList<Node> obsoleteNodes) {
            for (ValueNode alloc : otherAllocations) {
                ValueNode otherAllocation = graph.addOrUniqueWithInputs(alloc);
                if (otherAllocation instanceof FixedWithNextNode) {
                    graph.addBeforeFixed(fixed, (FixedWithNextNode) otherAllocation);
                } else {
                    assert otherAllocation instanceof FloatingNode;
                }
            }
            if (!objects.isEmpty()) {
                CommitAllocationNode commit;
                if (fixed.predecessor() instanceof CommitAllocationNode) {
                    commit = (CommitAllocationNode) fixed.predecessor();
                } else {
                    commit = graph.add(new CommitAllocationNode());
                    graph.addBeforeFixed(fixed, commit);
                }
                for (AllocatedObjectNode obj : objects) {
                    graph.addWithoutUnique(obj);
                    commit.getVirtualObjects().add(obj.getVirtualObject());
                    obj.setCommit(commit);
                }
                for (ValueNode value : values) {
                    commit.getValues().add(graph.addOrUniqueWithInputs(value));
                }
                for (List<MonitorIdNode> monitorIds : locks) {
                    commit.addLocks(monitorIds);
                }
                commit.getEnsureVirtual().addAll(ensureVirtual);
                assert commit.usages().filter(AllocatedObjectNode.class).count() == commit.getUsageCount();
                List<AllocatedObjectNode> materializedValues = commit.usages().filter(AllocatedObjectNode.class).snapshot();
                for (int i = 0; i < commit.getValues().size(); i++) {
                    if (materializedValues.contains(commit.getValues().get(i))) {
                        commit.getValues().set(i, ((AllocatedObjectNode) commit.getValues().get(i)).getVirtualObject());
                    }
                }
            }
        }
    });
}
Also used : FixedWithNextNode(org.graalvm.compiler.nodes.FixedWithNextNode) AllocatedObjectNode(org.graalvm.compiler.nodes.virtual.AllocatedObjectNode) FixedNode(org.graalvm.compiler.nodes.FixedNode) FloatingNode(org.graalvm.compiler.nodes.calc.FloatingNode) VirtualObjectNode(org.graalvm.compiler.nodes.virtual.VirtualObjectNode) AllocatedObjectNode(org.graalvm.compiler.nodes.virtual.AllocatedObjectNode) CommitAllocationNode(org.graalvm.compiler.nodes.virtual.CommitAllocationNode) ValueNode(org.graalvm.compiler.nodes.ValueNode) MonitorIdNode(org.graalvm.compiler.nodes.java.MonitorIdNode) Node(org.graalvm.compiler.graph.Node) FixedWithNextNode(org.graalvm.compiler.nodes.FixedWithNextNode) ArrayList(java.util.ArrayList) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) ValueNode(org.graalvm.compiler.nodes.ValueNode) FloatingNode(org.graalvm.compiler.nodes.calc.FloatingNode) ArrayList(java.util.ArrayList) List(java.util.List) Effect(org.graalvm.compiler.virtual.phases.ea.EffectList.Effect) CommitAllocationNode(org.graalvm.compiler.nodes.virtual.CommitAllocationNode)

Example 38 with FixedNode

use of org.graalvm.compiler.nodes.FixedNode in project graal by oracle.

the class PartialEscapeClosure method processNodeInternal.

private boolean processNodeInternal(Node node, BlockT state, GraphEffectList effects, FixedWithNextNode lastFixedNode) {
    FixedNode nextFixedNode = lastFixedNode == null ? null : lastFixedNode.next();
    VirtualUtil.trace(node.getOptions(), debug, "%s", node);
    if (requiresProcessing(node)) {
        if (processVirtualizable((ValueNode) node, nextFixedNode, state, effects) == false) {
            return false;
        }
        if (tool.isDeleted()) {
            VirtualUtil.trace(node.getOptions(), debug, "deleted virtualizable allocation %s", node);
            return true;
        }
    }
    if (hasVirtualInputs.isMarked(node) && node instanceof ValueNode) {
        if (node instanceof Virtualizable) {
            if (processVirtualizable((ValueNode) node, nextFixedNode, state, effects) == false) {
                return false;
            }
            if (tool.isDeleted()) {
                VirtualUtil.trace(node.getOptions(), debug, "deleted virtualizable node %s", node);
                return true;
            }
        }
        processNodeInputs((ValueNode) node, nextFixedNode, state, effects);
    }
    if (hasScalarReplacedInputs(node) && node instanceof ValueNode) {
        if (processNodeWithScalarReplacedInputs((ValueNode) node, nextFixedNode, state, effects)) {
            return true;
        }
    }
    return false;
}
Also used : ValueNode(org.graalvm.compiler.nodes.ValueNode) FixedNode(org.graalvm.compiler.nodes.FixedNode) Virtualizable(org.graalvm.compiler.nodes.spi.Virtualizable)

Example 39 with FixedNode

use of org.graalvm.compiler.nodes.FixedNode in project graal by oracle.

the class VirtualUtil method assertNonReachable.

public static boolean assertNonReachable(StructuredGraph graph, List<Node> obsoleteNodes) {
    // Helper code that determines the paths that keep obsolete nodes alive.
    // Nodes with support for GVN can be kept alive by GVN and are therefore not part of the
    // assertion.
    DebugContext debug = graph.getDebug();
    NodeFlood flood = graph.createNodeFlood();
    EconomicMap<Node, Node> path = EconomicMap.create(Equivalence.IDENTITY);
    flood.add(graph.start());
    for (Node current : flood) {
        if (current instanceof AbstractEndNode) {
            AbstractEndNode end = (AbstractEndNode) current;
            flood.add(end.merge());
            if (!path.containsKey(end.merge())) {
                path.put(end.merge(), end);
            }
        } else {
            for (Node successor : current.successors()) {
                flood.add(successor);
                if (!path.containsKey(successor)) {
                    path.put(successor, current);
                }
            }
        }
    }
    for (Node node : obsoleteNodes) {
        if (node instanceof FixedNode && !node.isDeleted()) {
            assert !flood.isMarked(node) : node;
        }
    }
    for (Node node : graph.getNodes()) {
        if (flood.isMarked(node)) {
            for (Node input : node.inputs()) {
                flood.add(input);
                if (!path.containsKey(input)) {
                    path.put(input, node);
                }
            }
        }
    }
    for (Node current : flood) {
        for (Node input : current.inputs()) {
            flood.add(input);
            if (!path.containsKey(input)) {
                path.put(input, current);
            }
        }
    }
    boolean success = true;
    for (Node node : obsoleteNodes) {
        if (!node.isDeleted() && flood.isMarked(node) && !node.getNodeClass().valueNumberable()) {
            TTY.println("offending node path:");
            Node current = node;
            TTY.print(current.toString());
            while (true) {
                current = path.get(current);
                if (current != null) {
                    TTY.print(" -> " + current.toString());
                    if (current instanceof FixedNode && !obsoleteNodes.contains(current)) {
                        break;
                    }
                }
            }
            success = false;
        }
    }
    if (!success) {
        TTY.println();
        debug.forceDump(graph, "assertNonReachable");
    }
    return success;
}
Also used : FixedNode(org.graalvm.compiler.nodes.FixedNode) AbstractEndNode(org.graalvm.compiler.nodes.AbstractEndNode) Node(org.graalvm.compiler.graph.Node) AbstractEndNode(org.graalvm.compiler.nodes.AbstractEndNode) DebugContext(org.graalvm.compiler.debug.DebugContext) FixedNode(org.graalvm.compiler.nodes.FixedNode) NodeFlood(org.graalvm.compiler.graph.NodeFlood)

Example 40 with FixedNode

use of org.graalvm.compiler.nodes.FixedNode in project graal by oracle.

the class PartialEscapeClosure method processNodeInputs.

/**
 * This replaces all inputs that point to virtual or materialized values with the actual value,
 * materializing if necessary. Also takes care of frame states, adding the necessary
 * {@link VirtualObjectState}.
 */
private void processNodeInputs(ValueNode node, FixedNode insertBefore, BlockT state, GraphEffectList effects) {
    VirtualUtil.trace(node.getOptions(), debug, "processing nodewithstate: %s", node);
    for (Node input : node.inputs()) {
        if (input instanceof ValueNode) {
            ValueNode alias = getAlias((ValueNode) input);
            if (alias instanceof VirtualObjectNode) {
                int id = ((VirtualObjectNode) alias).getObjectId();
                ensureMaterialized(state, id, insertBefore, effects, COUNTER_MATERIALIZATIONS_UNHANDLED);
                effects.replaceFirstInput(node, input, state.getObjectState(id).getMaterializedValue());
                VirtualUtil.trace(node.getOptions(), debug, "replacing input %s at %s", input, node);
            }
        }
    }
    if (node instanceof NodeWithState) {
        processNodeWithState((NodeWithState) node, state, effects);
    }
}
Also used : VirtualObjectNode(org.graalvm.compiler.nodes.virtual.VirtualObjectNode) ValuePhiNode(org.graalvm.compiler.nodes.ValuePhiNode) LoopBeginNode(org.graalvm.compiler.nodes.LoopBeginNode) CallTargetNode(org.graalvm.compiler.nodes.CallTargetNode) VirtualObjectNode(org.graalvm.compiler.nodes.virtual.VirtualObjectNode) ValueNode(org.graalvm.compiler.nodes.ValueNode) ControlSinkNode(org.graalvm.compiler.nodes.ControlSinkNode) ConstantNode(org.graalvm.compiler.nodes.ConstantNode) AllocatedObjectNode(org.graalvm.compiler.nodes.virtual.AllocatedObjectNode) FixedNode(org.graalvm.compiler.nodes.FixedNode) AbstractEndNode(org.graalvm.compiler.nodes.AbstractEndNode) ValueProxyNode(org.graalvm.compiler.nodes.ValueProxyNode) LoopExitNode(org.graalvm.compiler.nodes.LoopExitNode) Node(org.graalvm.compiler.graph.Node) FixedWithNextNode(org.graalvm.compiler.nodes.FixedWithNextNode) PhiNode(org.graalvm.compiler.nodes.PhiNode) ProxyNode(org.graalvm.compiler.nodes.ProxyNode) ValueNode(org.graalvm.compiler.nodes.ValueNode) NodeWithState(org.graalvm.compiler.nodes.spi.NodeWithState)

Aggregations

FixedNode (org.graalvm.compiler.nodes.FixedNode)87 Node (org.graalvm.compiler.graph.Node)41 FixedWithNextNode (org.graalvm.compiler.nodes.FixedWithNextNode)41 AbstractBeginNode (org.graalvm.compiler.nodes.AbstractBeginNode)39 AbstractMergeNode (org.graalvm.compiler.nodes.AbstractMergeNode)39 ValueNode (org.graalvm.compiler.nodes.ValueNode)34 LoopBeginNode (org.graalvm.compiler.nodes.LoopBeginNode)33 EndNode (org.graalvm.compiler.nodes.EndNode)27 AbstractEndNode (org.graalvm.compiler.nodes.AbstractEndNode)25 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)23 PhiNode (org.graalvm.compiler.nodes.PhiNode)22 ControlSplitNode (org.graalvm.compiler.nodes.ControlSplitNode)21 LoopExitNode (org.graalvm.compiler.nodes.LoopExitNode)21 LoopEndNode (org.graalvm.compiler.nodes.LoopEndNode)20 ControlSinkNode (org.graalvm.compiler.nodes.ControlSinkNode)17 MergeNode (org.graalvm.compiler.nodes.MergeNode)17 StartNode (org.graalvm.compiler.nodes.StartNode)17 ConstantNode (org.graalvm.compiler.nodes.ConstantNode)16 DeoptimizeNode (org.graalvm.compiler.nodes.DeoptimizeNode)13 ProxyNode (org.graalvm.compiler.nodes.ProxyNode)13