Search in sources :

Example 96 with ValueNode

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

the class EarlyReadEliminationTest method testBadLoop.

@Test
public void testBadLoop() {
    ValueNode result = getReturn("testBadLoopSnippet", false).result();
    assertDeepEquals(0, result.graph().getNodes().filter(LoadFieldNode.class).count());
    assertTrue(result instanceof ProxyNode);
    assertTrue(((ProxyNode) result).value() instanceof ValuePhiNode);
}
Also used : ProxyNode(org.graalvm.compiler.nodes.ProxyNode) ValuePhiNode(org.graalvm.compiler.nodes.ValuePhiNode) ValueNode(org.graalvm.compiler.nodes.ValueNode) Test(org.junit.Test) GraalCompilerTest(org.graalvm.compiler.core.test.GraalCompilerTest)

Example 97 with ValueNode

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

the class EarlyReadEliminationTest method testSimpleLoop.

@Test
public void testSimpleLoop() {
    // Test without lowering.
    ValueNode result = getReturn("testSimpleLoopSnippet", false).result();
    assertTrue(result.graph().getNodes().filter(LoadFieldNode.class).isEmpty());
    assertDeepEquals(result.graph().getParameter(1), result);
    // Now test with lowering.
    result = getReturn("testSimpleLoopSnippet", true).result();
    assertTrue(result.graph().getNodes().filter(ReadNode.class).isEmpty());
    assertDeepEquals(result.graph().getParameter(1), result);
}
Also used : ValueNode(org.graalvm.compiler.nodes.ValueNode) Test(org.junit.Test) GraalCompilerTest(org.graalvm.compiler.core.test.GraalCompilerTest)

Example 98 with ValueNode

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

the class EarlyReadEliminationTest method testMaterialized.

@Test
public void testMaterialized() {
    ValueNode result = getReturn("testMaterializedSnippet", false).result();
    assertTrue(result.graph().getNodes().filter(LoadFieldNode.class).isEmpty());
    assertDeepEquals(result.graph().getParameter(0), result);
}
Also used : ValueNode(org.graalvm.compiler.nodes.ValueNode) Test(org.junit.Test) GraalCompilerTest(org.graalvm.compiler.core.test.GraalCompilerTest)

Example 99 with ValueNode

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

the class LongNodeChainTest method longAddChain.

private void longAddChain(boolean reverse) {
    HighTierContext context = getDefaultHighTierContext();
    OptionValues options = getInitialOptions();
    StructuredGraph graph = new StructuredGraph.Builder(options, DebugContext.create(options, DebugHandlersFactory.LOADER)).build();
    ValueNode constant = graph.unique(ConstantNode.forPrimitive(JavaConstant.INT_1));
    ValueNode value = null;
    if (reverse) {
        // Make sure the constant's stamp is not used to infer the add node's stamp.
        OpaqueNode opaque = graph.unique(new OpaqueNode(constant));
        constant = opaque;
        AddNode addNode = graph.unique(new AddNode(constant, constant));
        value = addNode;
        for (int i = 1; i < N; ++i) {
            AddNode newAddNode = graph.addWithoutUnique(new AddNode(constant, constant));
            addNode.setY(newAddNode);
            addNode = newAddNode;
        }
        opaque.replaceAndDelete(opaque.getValue());
    } else {
        value = constant;
        for (int i = 0; i < N; ++i) {
            value = graph.unique(new AddNode(constant, value));
        }
    }
    ReturnNode returnNode = graph.add(new ReturnNode(value));
    graph.start().setNext(returnNode);
    for (SchedulingStrategy s : Strategies) {
        new SchedulePhase(s).apply(graph);
    }
    new CanonicalizerPhase().apply(graph, context);
    JavaConstant asConstant = (JavaConstant) returnNode.result().asConstant();
    Assert.assertEquals(N + 1, asConstant.asInt());
}
Also used : SchedulePhase(org.graalvm.compiler.phases.schedule.SchedulePhase) OptionValues(org.graalvm.compiler.options.OptionValues) JavaConstant(jdk.vm.ci.meta.JavaConstant) OpaqueNode(org.graalvm.compiler.nodes.debug.OpaqueNode) ReturnNode(org.graalvm.compiler.nodes.ReturnNode) SchedulingStrategy(org.graalvm.compiler.phases.schedule.SchedulePhase.SchedulingStrategy) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) ValueNode(org.graalvm.compiler.nodes.ValueNode) CanonicalizerPhase(org.graalvm.compiler.phases.common.CanonicalizerPhase) HighTierContext(org.graalvm.compiler.phases.tiers.HighTierContext) AddNode(org.graalvm.compiler.nodes.calc.AddNode)

Example 100 with ValueNode

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

the class PointsToStats method formatSource.

private static String formatSource(TypeFlow<?> flow) {
    Object source = flow.getSource();
    if (source instanceof ValueNode) {
        ValueNode node = (ValueNode) source;
        NodeSourcePosition nodeSource = node.getNodeSourcePosition();
        if (nodeSource != null) {
            return formatMethod(nodeSource.getMethod()) + ":" + nodeSource.getBCI();
        } else if (flow.graphRef() != null) {
            return formatMethod(flow.graphRef().getMethod());
        } else {
            return "<unknown-source>";
        }
    } else if (source instanceof AnalysisType) {
        return formatType((AnalysisType) source);
    } else if (source instanceof AnalysisField) {
        return formatField((AnalysisField) source);
    } else if (source == null) {
        return "<no-source>";
    } else {
        return source.getClass().getSimpleName();
    }
}
Also used : AnalysisType(com.oracle.graal.pointsto.meta.AnalysisType) ValueNode(org.graalvm.compiler.nodes.ValueNode) AnalysisField(com.oracle.graal.pointsto.meta.AnalysisField) NodeSourcePosition(org.graalvm.compiler.graph.NodeSourcePosition)

Aggregations

ValueNode (org.graalvm.compiler.nodes.ValueNode)482 ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)104 GraphBuilderContext (org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext)77 InvocationPlugin (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin)76 ConstantNode (org.graalvm.compiler.nodes.ConstantNode)69 ResolvedJavaType (jdk.vm.ci.meta.ResolvedJavaType)67 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)66 Registration (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.Registration)60 Receiver (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.Receiver)52 Node (org.graalvm.compiler.graph.Node)50 JavaKind (jdk.vm.ci.meta.JavaKind)48 Stamp (org.graalvm.compiler.core.common.type.Stamp)48 LogicNode (org.graalvm.compiler.nodes.LogicNode)48 VirtualObjectNode (org.graalvm.compiler.nodes.virtual.VirtualObjectNode)42 FixedWithNextNode (org.graalvm.compiler.nodes.FixedWithNextNode)38 FixedNode (org.graalvm.compiler.nodes.FixedNode)37 AddressNode (org.graalvm.compiler.nodes.memory.address.AddressNode)37 NodeView (org.graalvm.compiler.nodes.NodeView)36 PhiNode (org.graalvm.compiler.nodes.PhiNode)36 Test (org.junit.Test)36