Search in sources :

Example 21 with AddNode

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

the class SPARCAddressLowering method lower.

private AddressNode lower(ValueNode base, long displacement) {
    if (base instanceof AddNode) {
        AddNode add = (AddNode) base;
        JavaConstant immX = asImmediate(add.getX());
        if (immX != null && SPARCAssembler.isSimm13(displacement + immX.asLong())) {
            return lower(add.getY(), displacement + immX.asLong());
        }
        JavaConstant immY = asImmediate(add.getY());
        if (immY != null && SPARCAssembler.isSimm13(displacement + immY.asLong())) {
            return lower(add.getX(), displacement + immY.asLong());
        }
        if (displacement == 0) {
            return lower(add.getX(), add.getY());
        }
    }
    assert SPARCAssembler.isSimm13(displacement);
    return base.graph().unique(new SPARCImmediateAddressNode(base, (int) displacement));
}
Also used : JavaConstant(jdk.vm.ci.meta.JavaConstant) AddNode(org.graalvm.compiler.nodes.calc.AddNode)

Example 22 with AddNode

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

the class DefaultHotSpotLoweringProvider method lowerComputeObjectAddressNode.

private static void lowerComputeObjectAddressNode(ComputeObjectAddressNode n) {
    /*
         * Lower the node into a ComputeObjectAddress node and an Add but ensure that it's below any
         * potential safepoints and above it's uses.
         */
    for (Node use : n.usages().snapshot()) {
        if (use instanceof FixedNode) {
            FixedNode fixed = (FixedNode) use;
            StructuredGraph graph = n.graph();
            GetObjectAddressNode address = graph.add(new GetObjectAddressNode(n.getObject()));
            graph.addBeforeFixed(fixed, address);
            AddNode add = graph.addOrUnique(new AddNode(address, n.getOffset()));
            use.replaceFirstInput(n, add);
        } else {
            throw GraalError.shouldNotReachHere("Unexpected floating use of ComputeObjectAddressNode " + n);
        }
    }
    GraphUtil.unlinkFixedNode(n);
    n.safeDelete();
}
Also used : StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) RawLoadNode(org.graalvm.compiler.nodes.extended.RawLoadNode) GetObjectAddressNode(org.graalvm.compiler.hotspot.nodes.GetObjectAddressNode) MonitorIdNode(org.graalvm.compiler.nodes.java.MonitorIdNode) MethodCallTargetNode(org.graalvm.compiler.nodes.java.MethodCallTargetNode) OSRLocalNode(org.graalvm.compiler.nodes.extended.OSRLocalNode) RawMonitorEnterNode(org.graalvm.compiler.nodes.java.RawMonitorEnterNode) AbstractDeoptimizeNode(org.graalvm.compiler.nodes.AbstractDeoptimizeNode) StringToBytesNode(org.graalvm.compiler.nodes.debug.StringToBytesNode) DynamicNewArrayNode(org.graalvm.compiler.nodes.java.DynamicNewArrayNode) LoadExceptionObjectNode(org.graalvm.compiler.nodes.java.LoadExceptionObjectNode) WriteNode(org.graalvm.compiler.nodes.memory.WriteNode) LoadMethodNode(org.graalvm.compiler.nodes.extended.LoadMethodNode) ConstantNode(org.graalvm.compiler.nodes.ConstantNode) FloatingReadNode(org.graalvm.compiler.nodes.memory.FloatingReadNode) BeginLockScopeNode(org.graalvm.compiler.hotspot.nodes.BeginLockScopeNode) InitializeKlassNode(org.graalvm.compiler.hotspot.nodes.aot.InitializeKlassNode) IdentityHashCodeNode(org.graalvm.compiler.hotspot.replacements.IdentityHashCodeNode) FixedNode(org.graalvm.compiler.nodes.FixedNode) ResolveMethodAndLoadCountersNode(org.graalvm.compiler.hotspot.nodes.aot.ResolveMethodAndLoadCountersNode) OSRStartNode(org.graalvm.compiler.nodes.extended.OSRStartNode) HotSpotDirectCallTargetNode(org.graalvm.compiler.hotspot.nodes.HotSpotDirectCallTargetNode) SafepointNode(org.graalvm.compiler.nodes.SafepointNode) VerifyHeapNode(org.graalvm.compiler.nodes.debug.VerifyHeapNode) ForeignCallNode(org.graalvm.compiler.nodes.extended.ForeignCallNode) NewInstanceNode(org.graalvm.compiler.nodes.java.NewInstanceNode) DynamicNewInstanceNode(org.graalvm.compiler.nodes.java.DynamicNewInstanceNode) ArrayCopyWithSlowPathNode(org.graalvm.compiler.hotspot.replacements.arraycopy.ArrayCopyWithSlowPathNode) KlassLayoutHelperNode(org.graalvm.compiler.hotspot.replacements.KlassLayoutHelperNode) ClassGetHubNode(org.graalvm.compiler.hotspot.replacements.ClassGetHubNode) HotSpotCompressionNode(org.graalvm.compiler.hotspot.nodes.HotSpotCompressionNode) OSRLockNode(org.graalvm.compiler.nodes.extended.OSRLockNode) AssertionNode(org.graalvm.compiler.replacements.nodes.AssertionNode) IntegerDivRemNode(org.graalvm.compiler.nodes.calc.IntegerDivRemNode) NewMultiArrayNode(org.graalvm.compiler.nodes.java.NewMultiArrayNode) ResolveDynamicConstantNode(org.graalvm.compiler.hotspot.nodes.aot.ResolveDynamicConstantNode) ProfileNode(org.graalvm.compiler.hotspot.nodes.profiling.ProfileNode) AbstractBeginNode(org.graalvm.compiler.nodes.AbstractBeginNode) LogicNode(org.graalvm.compiler.nodes.LogicNode) ValueNode(org.graalvm.compiler.nodes.ValueNode) HotSpotIndirectCallTargetNode(org.graalvm.compiler.hotspot.nodes.HotSpotIndirectCallTargetNode) ArrayCopyNode(org.graalvm.compiler.hotspot.replacements.arraycopy.ArrayCopyNode) HubGetClassNode(org.graalvm.compiler.hotspot.replacements.HubGetClassNode) OSRMonitorEnterNode(org.graalvm.compiler.nodes.extended.OSRMonitorEnterNode) MonitorExitNode(org.graalvm.compiler.nodes.java.MonitorExitNode) IsNullNode(org.graalvm.compiler.nodes.calc.IsNullNode) StoreHubNode(org.graalvm.compiler.nodes.extended.StoreHubNode) NewArrayNode(org.graalvm.compiler.nodes.java.NewArrayNode) ResolveConstantNode(org.graalvm.compiler.hotspot.nodes.aot.ResolveConstantNode) FloatingNode(org.graalvm.compiler.nodes.calc.FloatingNode) StartNode(org.graalvm.compiler.nodes.StartNode) RemNode(org.graalvm.compiler.nodes.calc.RemNode) ClassIsAssignableFromNode(org.graalvm.compiler.nodes.java.ClassIsAssignableFromNode) ReadNode(org.graalvm.compiler.nodes.memory.ReadNode) InstanceOfDynamicNode(org.graalvm.compiler.nodes.java.InstanceOfDynamicNode) AddNode(org.graalvm.compiler.nodes.calc.AddNode) LoadHubNode(org.graalvm.compiler.nodes.extended.LoadHubNode) ComputeObjectAddressNode(org.graalvm.compiler.hotspot.nodes.ComputeObjectAddressNode) InstanceOfNode(org.graalvm.compiler.nodes.java.InstanceOfNode) LoweredCallTargetNode(org.graalvm.compiler.nodes.LoweredCallTargetNode) ParameterNode(org.graalvm.compiler.nodes.ParameterNode) GuardedUnsafeLoadNode(org.graalvm.compiler.nodes.extended.GuardedUnsafeLoadNode) AddressNode(org.graalvm.compiler.nodes.memory.address.AddressNode) UnwindNode(org.graalvm.compiler.nodes.UnwindNode) GetClassNode(org.graalvm.compiler.nodes.extended.GetClassNode) BytecodeExceptionNode(org.graalvm.compiler.nodes.extended.BytecodeExceptionNode) Node(org.graalvm.compiler.graph.Node) FixedNode(org.graalvm.compiler.nodes.FixedNode) AddNode(org.graalvm.compiler.nodes.calc.AddNode) GetObjectAddressNode(org.graalvm.compiler.hotspot.nodes.GetObjectAddressNode)

Example 23 with AddNode

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

the class HotSpotGraphBuilderPlugins method readMetaspaceConstantPoolElement.

/**
 * Emits a node representing an element in a metaspace {@code ConstantPool}.
 *
 * @param constantPoolOop value of the {@code constantPoolOop} field in a ConstantPool value
 */
private static boolean readMetaspaceConstantPoolElement(GraphBuilderContext b, ValueNode constantPoolOop, ValueNode index, JavaKind elementKind, WordTypes wordTypes, GraalHotSpotVMConfig config) {
    ValueNode constants = getMetaspaceConstantPool(b, constantPoolOop, wordTypes, config);
    int shift = CodeUtil.log2(wordTypes.getWordKind().getByteCount());
    ValueNode scaledIndex = b.add(new LeftShiftNode(IntegerConvertNode.convert(index, StampFactory.forKind(JavaKind.Long), NodeView.DEFAULT), b.add(ConstantNode.forInt(shift))));
    ValueNode offset = b.add(new AddNode(scaledIndex, b.add(ConstantNode.forLong(config.constantPoolSize))));
    AddressNode elementAddress = b.add(new OffsetAddressNode(constants, offset));
    boolean notCompressible = false;
    ValueNode elementValue = WordOperationPlugin.readOp(b, elementKind, elementAddress, NamedLocationIdentity.getArrayLocation(elementKind), BarrierType.NONE, notCompressible);
    b.addPush(elementKind, elementValue);
    return true;
}
Also used : OffsetAddressNode(org.graalvm.compiler.nodes.memory.address.OffsetAddressNode) ValueNode(org.graalvm.compiler.nodes.ValueNode) OffsetAddressNode(org.graalvm.compiler.nodes.memory.address.OffsetAddressNode) AddressNode(org.graalvm.compiler.nodes.memory.address.AddressNode) LeftShiftNode(org.graalvm.compiler.nodes.calc.LeftShiftNode) AddNode(org.graalvm.compiler.nodes.calc.AddNode)

Example 24 with AddNode

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

the class SchedulingTest method testValueProxyInputs.

@Test
public void testValueProxyInputs() {
    StructuredGraph graph = parseEager("testValueProxyInputsSnippet", AllowAssumptions.YES);
    for (FrameState fs : graph.getNodes().filter(FrameState.class).snapshot()) {
        fs.replaceAtUsages(null);
        GraphUtil.killWithUnusedFloatingInputs(fs);
    }
    SchedulePhase schedulePhase = new SchedulePhase(SchedulingStrategy.LATEST);
    schedulePhase.apply(graph);
    ScheduleResult schedule = graph.getLastSchedule();
    NodeMap<Block> nodeToBlock = schedule.getCFG().getNodeToBlock();
    assertTrue(graph.getNodes().filter(LoopExitNode.class).count() == 1);
    LoopExitNode loopExit = graph.getNodes().filter(LoopExitNode.class).first();
    List<Node> list = schedule.nodesFor(nodeToBlock.get(loopExit));
    for (BinaryArithmeticNode<?> node : graph.getNodes().filter(BinaryArithmeticNode.class)) {
        if (!(node instanceof AddNode)) {
            assertTrue(node.toString(), nodeToBlock.get(node) == nodeToBlock.get(loopExit));
            assertTrue(list.indexOf(node) + " < " + list.indexOf(loopExit) + ", " + node + ", " + loopExit, list.indexOf(node) < list.indexOf(loopExit));
        }
    }
}
Also used : SchedulePhase(org.graalvm.compiler.phases.schedule.SchedulePhase) ScheduleResult(org.graalvm.compiler.nodes.StructuredGraph.ScheduleResult) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) LoopExitNode(org.graalvm.compiler.nodes.LoopExitNode) AddNode(org.graalvm.compiler.nodes.calc.AddNode) LoopExitNode(org.graalvm.compiler.nodes.LoopExitNode) BinaryArithmeticNode(org.graalvm.compiler.nodes.calc.BinaryArithmeticNode) Node(org.graalvm.compiler.graph.Node) Block(org.graalvm.compiler.nodes.cfg.Block) FrameState(org.graalvm.compiler.nodes.FrameState) AddNode(org.graalvm.compiler.nodes.calc.AddNode) Test(org.junit.Test)

Example 25 with AddNode

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

the class SchedulingTest2 method testValueProxyInputs.

@Test
public void testValueProxyInputs() {
    StructuredGraph graph = parseEager("testSnippet", AllowAssumptions.YES);
    DebugContext debug = graph.getDebug();
    ReturnNode returnNode = graph.getNodes(ReturnNode.TYPE).first();
    BeginNode beginNode = graph.add(new BeginNode());
    returnNode.replaceAtPredecessor(beginNode);
    beginNode.setNext(returnNode);
    debug.dump(DebugContext.BASIC_LEVEL, graph, "Graph");
    SchedulePhase schedulePhase = new SchedulePhase(SchedulingStrategy.EARLIEST_WITH_GUARD_ORDER);
    schedulePhase.apply(graph);
    ScheduleResult schedule = graph.getLastSchedule();
    BlockMap<List<Node>> blockToNodesMap = schedule.getBlockToNodesMap();
    NodeMap<Block> nodeToBlock = schedule.getNodeToBlockMap();
    assertDeepEquals(2, schedule.getCFG().getBlocks().length);
    for (BinaryArithmeticNode<?> node : graph.getNodes().filter(BinaryArithmeticNode.class)) {
        if (node instanceof AddNode) {
            assertTrue(node.toString() + " expected: " + nodeToBlock.get(beginNode) + " but was: " + nodeToBlock.get(node), nodeToBlock.get(node) != nodeToBlock.get(beginNode));
        }
    }
    for (FrameState fs : graph.getNodes(FrameState.TYPE)) {
        Block block = nodeToBlock.get(fs);
        assertTrue(fs.toString(), block == schedule.getCFG().getStartBlock());
        for (Node usage : fs.usages()) {
            if (usage instanceof StateSplit && ((StateSplit) usage).stateAfter() == fs) {
                assertTrue(usage.toString(), nodeToBlock.get(usage) == block);
                if (usage != block.getBeginNode()) {
                    List<Node> map = blockToNodesMap.get(block);
                    assertTrue(map.indexOf(fs) + " < " + map.indexOf(usage), map.indexOf(fs) < map.indexOf(usage));
                }
            }
        }
    }
    PhaseContext context = new PhaseContext(getProviders());
    new LoweringPhase(new CanonicalizerPhase(), LoweringTool.StandardLoweringStage.HIGH_TIER).apply(graph, context);
    new LoweringPhase(new CanonicalizerPhase(), LoweringTool.StandardLoweringStage.MID_TIER).apply(graph, context);
    MidTierContext midContext = new MidTierContext(getProviders(), getTargetProvider(), OptimisticOptimizations.ALL, graph.getProfilingInfo());
    new GuardLoweringPhase().apply(graph, midContext);
    FrameStateAssignmentPhase phase = new FrameStateAssignmentPhase();
    phase.apply(graph);
    schedulePhase.apply(graph);
    schedule = graph.getLastSchedule();
    blockToNodesMap = schedule.getBlockToNodesMap();
    nodeToBlock = schedule.getNodeToBlockMap();
    for (FrameState fs : graph.getNodes(FrameState.TYPE)) {
        Block block = nodeToBlock.get(fs);
        assertTrue(fs.toString(), block == schedule.getCFG().getStartBlock());
        for (Node usage : fs.usages()) {
            if ((usage instanceof StateSplit && ((StateSplit) usage).stateAfter() == fs) || (usage instanceof DeoptDuring && ((DeoptDuring) usage).stateDuring() == fs)) {
                assertTrue(usage.toString(), nodeToBlock.get(usage) == block);
                if (usage != block.getBeginNode()) {
                    List<Node> map = blockToNodesMap.get(block);
                    assertTrue(map.indexOf(fs) + " < " + map.indexOf(usage), map.indexOf(fs) < map.indexOf(usage));
                }
            }
        }
    }
}
Also used : FrameStateAssignmentPhase(org.graalvm.compiler.phases.common.FrameStateAssignmentPhase) SchedulePhase(org.graalvm.compiler.phases.schedule.SchedulePhase) ScheduleResult(org.graalvm.compiler.nodes.StructuredGraph.ScheduleResult) AddNode(org.graalvm.compiler.nodes.calc.AddNode) BeginNode(org.graalvm.compiler.nodes.BeginNode) ReturnNode(org.graalvm.compiler.nodes.ReturnNode) BinaryArithmeticNode(org.graalvm.compiler.nodes.calc.BinaryArithmeticNode) Node(org.graalvm.compiler.graph.Node) GuardLoweringPhase(org.graalvm.compiler.phases.common.GuardLoweringPhase) LoweringPhase(org.graalvm.compiler.phases.common.LoweringPhase) DebugContext(org.graalvm.compiler.debug.DebugContext) FrameState(org.graalvm.compiler.nodes.FrameState) PhaseContext(org.graalvm.compiler.phases.tiers.PhaseContext) ReturnNode(org.graalvm.compiler.nodes.ReturnNode) MidTierContext(org.graalvm.compiler.phases.tiers.MidTierContext) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) BeginNode(org.graalvm.compiler.nodes.BeginNode) DeoptDuring(org.graalvm.compiler.nodes.DeoptimizingNode.DeoptDuring) Block(org.graalvm.compiler.nodes.cfg.Block) List(java.util.List) CanonicalizerPhase(org.graalvm.compiler.phases.common.CanonicalizerPhase) AddNode(org.graalvm.compiler.nodes.calc.AddNode) GuardLoweringPhase(org.graalvm.compiler.phases.common.GuardLoweringPhase) StateSplit(org.graalvm.compiler.nodes.StateSplit) Test(org.junit.Test)

Aggregations

AddNode (org.graalvm.compiler.nodes.calc.AddNode)27 ValueNode (org.graalvm.compiler.nodes.ValueNode)17 ConstantNode (org.graalvm.compiler.nodes.ConstantNode)7 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)6 LeftShiftNode (org.graalvm.compiler.nodes.calc.LeftShiftNode)6 OffsetAddressNode (org.graalvm.compiler.nodes.memory.address.OffsetAddressNode)5 IntegerStamp (org.graalvm.compiler.core.common.type.IntegerStamp)4 Node (org.graalvm.compiler.graph.Node)4 PhiNode (org.graalvm.compiler.nodes.PhiNode)4 AddressNode (org.graalvm.compiler.nodes.memory.address.AddressNode)4 Test (org.junit.Test)4 JavaConstant (jdk.vm.ci.meta.JavaConstant)3 GetObjectAddressNode (org.graalvm.compiler.hotspot.nodes.GetObjectAddressNode)3 LoopBeginNode (org.graalvm.compiler.nodes.LoopBeginNode)3 Block (org.graalvm.compiler.nodes.cfg.Block)3 SchedulePhase (org.graalvm.compiler.phases.schedule.SchedulePhase)3 AMD64AddressNode (org.graalvm.compiler.core.amd64.AMD64AddressNode)2 Stamp (org.graalvm.compiler.core.common.type.Stamp)2 FrameState (org.graalvm.compiler.nodes.FrameState)2 NodeView (org.graalvm.compiler.nodes.NodeView)2