Search in sources :

Example 31 with LocationIdentity

use of org.graalvm.word.LocationIdentity in project graal by oracle.

the class FloatingReadPhase method processLoop.

private EconomicSet<LocationIdentity> processLoop(HIRLoop loop, EconomicMap<LoopBeginNode, EconomicSet<LocationIdentity>> modifiedInLoops) {
    LoopBeginNode loopBegin = (LoopBeginNode) loop.getHeader().getBeginNode();
    EconomicSet<LocationIdentity> result = modifiedInLoops.get(loopBegin);
    if (result != null) {
        return result;
    }
    result = EconomicSet.create(Equivalence.DEFAULT);
    for (Loop<Block> inner : loop.getChildren()) {
        result.addAll(processLoop((HIRLoop) inner, modifiedInLoops));
    }
    for (Block b : loop.getBlocks()) {
        if (b.getLoop() == loop) {
            processBlock(b, result);
        }
    }
    modifiedInLoops.put(loopBegin, result);
    return result;
}
Also used : LoopBeginNode(org.graalvm.compiler.nodes.LoopBeginNode) LocationIdentity(org.graalvm.word.LocationIdentity) Block(org.graalvm.compiler.nodes.cfg.Block) HIRLoop(org.graalvm.compiler.nodes.cfg.HIRLoop)

Example 32 with LocationIdentity

use of org.graalvm.word.LocationIdentity in project graal by oracle.

the class LoweringPhase method checkPostNodeLowering.

/**
 * Checks that lowering of a given node did not introduce any new {@link Lowerable} nodes that
 * could be lowered in the current {@link LoweringPhase}. Such nodes must be recursively lowered
 * as part of lowering {@code node}.
 *
 * @param node a node that was just lowered
 * @param preLoweringMark the graph mark before {@code node} was lowered
 * @param unscheduledUsages set of {@code node}'s usages that were unscheduled before it was
 *            lowered
 * @throws AssertionError if the check fails
 */
private static boolean checkPostNodeLowering(Node node, LoweringToolImpl loweringTool, Mark preLoweringMark, Collection<Node> unscheduledUsages) {
    StructuredGraph graph = (StructuredGraph) node.graph();
    Mark postLoweringMark = graph.getMark();
    NodeIterable<Node> newNodesAfterLowering = graph.getNewNodes(preLoweringMark);
    if (node instanceof FloatingNode) {
        if (!unscheduledUsages.isEmpty()) {
            for (Node n : newNodesAfterLowering) {
                assert !(n instanceof FixedNode) : node.graph() + ": cannot lower floatable node " + node + " as it introduces fixed node(s) but has the following unscheduled usages: " + unscheduledUsages;
            }
        }
    }
    for (Node n : newNodesAfterLowering) {
        if (n instanceof Lowerable) {
            ((Lowerable) n).lower(loweringTool);
            Mark mark = graph.getMark();
            assert postLoweringMark.equals(mark) : graph + ": lowering of " + node + " produced lowerable " + n + " that should have been recursively lowered as it introduces these new nodes: " + graph.getNewNodes(postLoweringMark).snapshot();
        }
        if (graph.isAfterFloatingReadPhase() && n instanceof MemoryCheckpoint && !(node instanceof MemoryCheckpoint) && !(node instanceof ControlSinkNode)) {
            /*
                 * The lowering introduced a MemoryCheckpoint but the current node isn't a
                 * checkpoint. This is only OK if the locations involved don't affect the memory
                 * graph or if the new kill location doesn't connect into the existing graph.
                 */
            boolean isAny = false;
            if (n instanceof MemoryCheckpoint.Single) {
                isAny = ((MemoryCheckpoint.Single) n).getLocationIdentity().isAny();
            } else {
                for (LocationIdentity ident : ((MemoryCheckpoint.Multi) n).getLocationIdentities()) {
                    if (ident.isAny()) {
                        isAny = true;
                    }
                }
            }
            if (isAny && n instanceof FixedWithNextNode) {
                /*
                     * Check if the next kill location leads directly to a ControlSinkNode in the
                     * new part of the graph. This is a fairly conservative test that could be made
                     * more general if required.
                     */
                FixedWithNextNode cur = (FixedWithNextNode) n;
                while (cur != null && graph.isNew(preLoweringMark, cur)) {
                    if (cur.next() instanceof ControlSinkNode) {
                        isAny = false;
                        break;
                    }
                    if (cur.next() instanceof FixedWithNextNode) {
                        cur = (FixedWithNextNode) cur.next();
                    } else {
                        break;
                    }
                }
            }
            assert !isAny : node + " " + n;
        }
    }
    return true;
}
Also used : FixedWithNextNode(org.graalvm.compiler.nodes.FixedWithNextNode) BeginNode(org.graalvm.compiler.nodes.BeginNode) AbstractBeginNode(org.graalvm.compiler.nodes.AbstractBeginNode) FixedGuardNode(org.graalvm.compiler.nodes.FixedGuardNode) LogicNode(org.graalvm.compiler.nodes.LogicNode) ValueNode(org.graalvm.compiler.nodes.ValueNode) GuardedNode(org.graalvm.compiler.nodes.extended.GuardedNode) GuardingNode(org.graalvm.compiler.nodes.extended.GuardingNode) ControlSinkNode(org.graalvm.compiler.nodes.ControlSinkNode) GuardNode(org.graalvm.compiler.nodes.GuardNode) FloatingNode(org.graalvm.compiler.nodes.calc.FloatingNode) AnchoringNode(org.graalvm.compiler.nodes.extended.AnchoringNode) FixedNode(org.graalvm.compiler.nodes.FixedNode) Node(org.graalvm.compiler.graph.Node) FixedWithNextNode(org.graalvm.compiler.nodes.FixedWithNextNode) PhiNode(org.graalvm.compiler.nodes.PhiNode) ProxyNode(org.graalvm.compiler.nodes.ProxyNode) Mark(org.graalvm.compiler.graph.Graph.Mark) FixedNode(org.graalvm.compiler.nodes.FixedNode) ControlSinkNode(org.graalvm.compiler.nodes.ControlSinkNode) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) MemoryCheckpoint(org.graalvm.compiler.nodes.memory.MemoryCheckpoint) FloatingNode(org.graalvm.compiler.nodes.calc.FloatingNode) LocationIdentity(org.graalvm.word.LocationIdentity) Lowerable(org.graalvm.compiler.nodes.spi.Lowerable)

Aggregations

LocationIdentity (org.graalvm.word.LocationIdentity)32 ValueNode (org.graalvm.compiler.nodes.ValueNode)12 FieldLocationIdentity (org.graalvm.compiler.nodes.FieldLocationIdentity)11 NamedLocationIdentity (org.graalvm.compiler.nodes.NamedLocationIdentity)11 JavaKind (jdk.vm.ci.meta.JavaKind)10 MemoryCheckpoint (org.graalvm.compiler.nodes.memory.MemoryCheckpoint)10 ResolvedJavaType (jdk.vm.ci.meta.ResolvedJavaType)6 Stamp (org.graalvm.compiler.core.common.type.Stamp)5 AbstractBeginNode (org.graalvm.compiler.nodes.AbstractBeginNode)5 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)5 AddressNode (org.graalvm.compiler.nodes.memory.address.AddressNode)4 CInterfaceLocationIdentity (com.oracle.svm.core.c.struct.CInterfaceLocationIdentity)3 ResolvedJavaField (jdk.vm.ci.meta.ResolvedJavaField)3 Node (org.graalvm.compiler.graph.Node)3 AbstractMergeNode (org.graalvm.compiler.nodes.AbstractMergeNode)3 StructFieldInfo (com.oracle.svm.hosted.c.info.StructFieldInfo)2 JavaConstant (jdk.vm.ci.meta.JavaConstant)2 ForeignCallDescriptor (org.graalvm.compiler.core.common.spi.ForeignCallDescriptor)2 KlassPointerStamp (org.graalvm.compiler.hotspot.nodes.type.KlassPointerStamp)2 FixedNode (org.graalvm.compiler.nodes.FixedNode)2