Search in sources :

Example 6 with FloatingReadNode

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

the class ReadAfterCheckCastTest method test.

@SuppressWarnings("try")
private void test(final String snippet) {
    DebugContext debug = getDebugContext();
    try (DebugContext.Scope s = debug.scope("ReadAfterCheckCastTest", new DebugDumpScope(snippet))) {
        // check shape of graph, with lots of assumptions. will probably fail if graph
        // structure changes significantly
        StructuredGraph graph = parseEager(snippet, AllowAssumptions.YES);
        PhaseContext context = new PhaseContext(getProviders());
        CanonicalizerPhase canonicalizer = new CanonicalizerPhase();
        new LoweringPhase(canonicalizer, LoweringTool.StandardLoweringStage.HIGH_TIER).apply(graph, context);
        new FloatingReadPhase().apply(graph);
        canonicalizer.apply(graph, context);
        debug.dump(DebugContext.BASIC_LEVEL, graph, "After lowering");
        for (FloatingReadNode node : graph.getNodes(ParameterNode.TYPE).first().usages().filter(FloatingReadNode.class)) {
            // Checking that the parameter a is not directly used for the access to field
            // x10 (because x10 must be guarded by the checkcast).
            Assert.assertTrue(node.getLocationIdentity().isImmutable());
        }
    } catch (Throwable e) {
        throw debug.handle(e);
    }
}
Also used : PhaseContext(org.graalvm.compiler.phases.tiers.PhaseContext) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) DebugDumpScope(org.graalvm.compiler.debug.DebugDumpScope) FloatingReadNode(org.graalvm.compiler.nodes.memory.FloatingReadNode) LoweringPhase(org.graalvm.compiler.phases.common.LoweringPhase) CanonicalizerPhase(org.graalvm.compiler.phases.common.CanonicalizerPhase) DebugContext(org.graalvm.compiler.debug.DebugContext) FloatingReadPhase(org.graalvm.compiler.phases.common.FloatingReadPhase)

Example 7 with FloatingReadNode

use of org.graalvm.compiler.nodes.memory.FloatingReadNode 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;
}
Also used : MemoryNode(org.graalvm.compiler.nodes.memory.MemoryNode) MemoryPhiNode(org.graalvm.compiler.nodes.memory.MemoryPhiNode) PhiNode(org.graalvm.compiler.nodes.PhiNode) MemoryPhiNode(org.graalvm.compiler.nodes.memory.MemoryPhiNode) LoopBeginNode(org.graalvm.compiler.nodes.LoopBeginNode) MemoryPhiNode(org.graalvm.compiler.nodes.memory.MemoryPhiNode) AbstractBeginNode(org.graalvm.compiler.nodes.AbstractBeginNode) FloatingReadNode(org.graalvm.compiler.nodes.memory.FloatingReadNode) MemoryNode(org.graalvm.compiler.nodes.memory.MemoryNode) AbstractMergeNode(org.graalvm.compiler.nodes.AbstractMergeNode) Node(org.graalvm.compiler.graph.Node) PhiNode(org.graalvm.compiler.nodes.PhiNode) AbstractMergeNode(org.graalvm.compiler.nodes.AbstractMergeNode) AbstractBeginNode(org.graalvm.compiler.nodes.AbstractBeginNode) MemoryCheckpoint(org.graalvm.compiler.nodes.memory.MemoryCheckpoint) FloatingReadNode(org.graalvm.compiler.nodes.memory.FloatingReadNode) LocationIdentity(org.graalvm.word.LocationIdentity)

Example 8 with FloatingReadNode

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

the class FloatingReadTest method test.

@SuppressWarnings("try")
private void test(final String snippet) {
    DebugContext debug = getDebugContext();
    try (DebugContext.Scope s = debug.scope("FloatingReadTest", new DebugDumpScope(snippet))) {
        StructuredGraph graph = parseEager(snippet, AllowAssumptions.YES);
        PhaseContext context = new PhaseContext(getProviders());
        new LoweringPhase(new CanonicalizerPhase(), LoweringTool.StandardLoweringStage.HIGH_TIER).apply(graph, context);
        new FloatingReadPhase().apply(graph);
        ReturnNode returnNode = null;
        MonitorExit monitorexit = null;
        for (Node n : graph.getNodes()) {
            if (n instanceof ReturnNode) {
                assert returnNode == null;
                returnNode = (ReturnNode) n;
            } else if (n instanceof MonitorExit) {
                monitorexit = (MonitorExit) n;
            }
        }
        debug.dump(DebugContext.BASIC_LEVEL, graph, "After lowering");
        Assert.assertNotNull(returnNode);
        Assert.assertNotNull(monitorexit);
        Assert.assertTrue(returnNode.result() instanceof FloatingReadNode);
        FloatingReadNode read = (FloatingReadNode) returnNode.result();
        assertOrderedAfterSchedule(graph, read, (Node) monitorexit);
    } catch (Throwable e) {
        throw debug.handle(e);
    }
}
Also used : DebugDumpScope(org.graalvm.compiler.debug.DebugDumpScope) ReturnNode(org.graalvm.compiler.nodes.ReturnNode) FloatingReadNode(org.graalvm.compiler.nodes.memory.FloatingReadNode) Node(org.graalvm.compiler.graph.Node) LoweringPhase(org.graalvm.compiler.phases.common.LoweringPhase) DebugContext(org.graalvm.compiler.debug.DebugContext) FloatingReadPhase(org.graalvm.compiler.phases.common.FloatingReadPhase) PhaseContext(org.graalvm.compiler.phases.tiers.PhaseContext) ReturnNode(org.graalvm.compiler.nodes.ReturnNode) MonitorExit(org.graalvm.compiler.nodes.extended.MonitorExit) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) FloatingReadNode(org.graalvm.compiler.nodes.memory.FloatingReadNode) CanonicalizerPhase(org.graalvm.compiler.phases.common.CanonicalizerPhase)

Example 9 with FloatingReadNode

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

the class DefaultHotSpotLoweringProvider method lowerHubGetClassNode.

private void lowerHubGetClassNode(HubGetClassNode n, LoweringTool tool) {
    if (tool.getLoweringStage() == LoweringTool.StandardLoweringStage.HIGH_TIER) {
        return;
    }
    ValueNode hub = n.getHub();
    GraalHotSpotVMConfig vmConfig = runtime.getVMConfig();
    StructuredGraph graph = n.graph();
    assert !hub.isConstant() || GraalOptions.ImmutableCode.getValue(graph.getOptions());
    AddressNode mirrorAddress = createOffsetAddress(graph, hub, vmConfig.classMirrorOffset);
    FloatingReadNode read = graph.unique(new FloatingReadNode(mirrorAddress, CLASS_MIRROR_LOCATION, null, vmConfig.classMirrorIsHandle ? StampFactory.forKind(target.wordJavaKind) : n.stamp(NodeView.DEFAULT), null, BarrierType.NONE));
    if (vmConfig.classMirrorIsHandle) {
        AddressNode address = createOffsetAddress(graph, read, 0);
        read = graph.unique(new FloatingReadNode(address, CLASS_MIRROR_HANDLE_LOCATION, null, n.stamp(NodeView.DEFAULT), null, BarrierType.NONE));
    }
    n.replaceAtUsagesAndDelete(read);
}
Also used : StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) FloatingReadNode(org.graalvm.compiler.nodes.memory.FloatingReadNode) ValueNode(org.graalvm.compiler.nodes.ValueNode) GetObjectAddressNode(org.graalvm.compiler.hotspot.nodes.GetObjectAddressNode) ComputeObjectAddressNode(org.graalvm.compiler.hotspot.nodes.ComputeObjectAddressNode) AddressNode(org.graalvm.compiler.nodes.memory.address.AddressNode) GraalHotSpotVMConfig(org.graalvm.compiler.hotspot.GraalHotSpotVMConfig)

Example 10 with FloatingReadNode

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

the class DefaultHotSpotLoweringProvider method lowerClassGetHubNode.

private void lowerClassGetHubNode(ClassGetHubNode n, LoweringTool tool) {
    if (tool.getLoweringStage() == LoweringTool.StandardLoweringStage.HIGH_TIER) {
        return;
    }
    StructuredGraph graph = n.graph();
    assert !n.getValue().isConstant();
    AddressNode address = createOffsetAddress(graph, n.getValue(), runtime.getVMConfig().klassOffset);
    FloatingReadNode read = graph.unique(new FloatingReadNode(address, CLASS_KLASS_LOCATION, null, n.stamp(NodeView.DEFAULT), null, BarrierType.NONE));
    n.replaceAtUsagesAndDelete(read);
}
Also used : StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) FloatingReadNode(org.graalvm.compiler.nodes.memory.FloatingReadNode) GetObjectAddressNode(org.graalvm.compiler.hotspot.nodes.GetObjectAddressNode) ComputeObjectAddressNode(org.graalvm.compiler.hotspot.nodes.ComputeObjectAddressNode) AddressNode(org.graalvm.compiler.nodes.memory.address.AddressNode)

Aggregations

FloatingReadNode (org.graalvm.compiler.nodes.memory.FloatingReadNode)16 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)9 Node (org.graalvm.compiler.graph.Node)6 AddressNode (org.graalvm.compiler.nodes.memory.address.AddressNode)6 ComputeObjectAddressNode (org.graalvm.compiler.hotspot.nodes.ComputeObjectAddressNode)4 GetObjectAddressNode (org.graalvm.compiler.hotspot.nodes.GetObjectAddressNode)4 ReturnNode (org.graalvm.compiler.nodes.ReturnNode)4 ValueNode (org.graalvm.compiler.nodes.ValueNode)4 WriteNode (org.graalvm.compiler.nodes.memory.WriteNode)4 CanonicalizerPhase (org.graalvm.compiler.phases.common.CanonicalizerPhase)3 FloatingReadPhase (org.graalvm.compiler.phases.common.FloatingReadPhase)3 LoweringPhase (org.graalvm.compiler.phases.common.LoweringPhase)3 PhaseContext (org.graalvm.compiler.phases.tiers.PhaseContext)3 Stamp (org.graalvm.compiler.core.common.type.Stamp)2 DebugContext (org.graalvm.compiler.debug.DebugContext)2 DebugDumpScope (org.graalvm.compiler.debug.DebugDumpScope)2 KlassPointerStamp (org.graalvm.compiler.hotspot.nodes.type.KlassPointerStamp)2 StartNode (org.graalvm.compiler.nodes.StartNode)2 ReadNode (org.graalvm.compiler.nodes.memory.ReadNode)2 OffsetAddressNode (org.graalvm.compiler.nodes.memory.address.OffsetAddressNode)2