Search in sources :

Example 21 with ParameterNode

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

the class GraalCompilerTest method bindArguments.

protected void bindArguments(StructuredGraph graph, Object[] argsToBind) {
    ResolvedJavaMethod m = graph.method();
    Object receiver = isStatic(m.getModifiers()) ? null : this;
    Object[] args = argsWithReceiver(receiver, argsToBind);
    JavaType[] parameterTypes = m.toParameterTypes();
    assert parameterTypes.length == args.length;
    for (ParameterNode param : graph.getNodes(ParameterNode.TYPE)) {
        JavaConstant c = getSnippetReflection().forBoxed(parameterTypes[param.index()].getJavaKind(), args[param.index()]);
        ConstantNode replacement = ConstantNode.forConstant(c, getMetaAccess(), graph);
        param.replaceAtUsages(replacement);
    }
}
Also used : ResolvedJavaType(jdk.vm.ci.meta.ResolvedJavaType) JavaType(jdk.vm.ci.meta.JavaType) ConstantNode(org.graalvm.compiler.nodes.ConstantNode) ParameterNode(org.graalvm.compiler.nodes.ParameterNode) JavaConstant(jdk.vm.ci.meta.JavaConstant) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod)

Example 22 with ParameterNode

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

the class GuardPrioritiesTest method unknownTest.

@Test
public void unknownTest() {
    assumeTrue("GuardPriorities must be turned one", GraalOptions.GuardPriorities.getValue(getInitialOptions()));
    StructuredGraph graph = prepareGraph("unknownCondition");
    new SchedulePhase(SchedulePhase.SchedulingStrategy.EARLIEST_WITH_GUARD_ORDER).apply(graph);
    for (GuardNode g1 : graph.getNodes(GuardNode.TYPE)) {
        for (GuardNode g2 : graph.getNodes(GuardNode.TYPE)) {
            if (g1.getSpeculation().isNull() ^ g2.getSpeculation().isNull()) {
                GuardNode withSpeculation = g1.getSpeculation().isNull() ? g2 : g1;
                GuardNode withoutSpeculation = g1.getSpeculation().isNull() ? g1 : g2;
                if (withoutSpeculation.isNegated() && withoutSpeculation.getCondition() instanceof IsNullNode) {
                    IsNullNode isNullNode = (IsNullNode) withoutSpeculation.getCondition();
                    if (isNullNode.getValue() instanceof ParameterNode && ((ParameterNode) isNullNode.getValue()).index() == 1) {
                        // this is the null check before the speculative guard, it's the only
                        // one that should be above
                        assertOrderedAfterLastSchedule(graph, withoutSpeculation, withSpeculation);
                        continue;
                    }
                }
                assertOrderedAfterLastSchedule(graph, withSpeculation, withoutSpeculation);
            }
        }
    }
}
Also used : SchedulePhase(org.graalvm.compiler.phases.schedule.SchedulePhase) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) ParameterNode(org.graalvm.compiler.nodes.ParameterNode) IsNullNode(org.graalvm.compiler.nodes.calc.IsNullNode) GuardNode(org.graalvm.compiler.nodes.GuardNode) Test(org.junit.Test)

Example 23 with ParameterNode

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

the class CompareCanonicalizerTest method testIntegerTest.

@Test
public void testIntegerTest() {
    for (int i = 1; i <= 4; i++) {
        StructuredGraph graph = getCanonicalizedGraph("integerTest" + i);
        ReturnNode returnNode = (ReturnNode) graph.start().next();
        ConditionalNode conditional = (ConditionalNode) returnNode.result();
        IntegerTestNode test = (IntegerTestNode) conditional.condition();
        ParameterNode param0 = graph.getParameter(0);
        ParameterNode param1 = graph.getParameter(1);
        assertTrue((test.getX() == param0 && test.getY() == param1) || (test.getX() == param1 && test.getY() == param0));
    }
}
Also used : ReturnNode(org.graalvm.compiler.nodes.ReturnNode) ConditionalNode(org.graalvm.compiler.nodes.calc.ConditionalNode) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) ParameterNode(org.graalvm.compiler.nodes.ParameterNode) IntegerTestNode(org.graalvm.compiler.nodes.calc.IntegerTestNode) Test(org.junit.Test)

Example 24 with ParameterNode

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

the class ReinterpretStampDoubleToLongTest method run.

@Test
public void run() {
    ParameterNode param = new ParameterNode(0, StampPair.createSingle(inputStamp));
    ValueNode reinterpret = ReinterpretNode.create(JavaKind.Long, param, NodeView.DEFAULT);
    IntegerStamp resultStamp = (IntegerStamp) reinterpret.stamp(NodeView.DEFAULT);
    Assert.assertEquals(Long.SIZE, resultStamp.getBits());
    for (long result : interestingLongs) {
        double input = Double.longBitsToDouble(result);
        if (inputStamp.contains(input) && !resultStamp.contains(result)) {
            Assert.fail(String.format("value %f (0x%x) is in input stamp, but not in result stamp (%s)", input, result, resultStamp));
        }
    }
}
Also used : ParameterNode(org.graalvm.compiler.nodes.ParameterNode) IntegerStamp(org.graalvm.compiler.core.common.type.IntegerStamp) ValueNode(org.graalvm.compiler.nodes.ValueNode) Test(org.junit.Test)

Example 25 with ParameterNode

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

the class ReinterpretStampFloatToIntTest method run.

@Test
public void run() {
    ParameterNode param = new ParameterNode(0, StampPair.createSingle(inputStamp));
    ValueNode reinterpret = ReinterpretNode.create(JavaKind.Int, param, NodeView.DEFAULT);
    reinterpret.inferStamp();
    IntegerStamp resultStamp = (IntegerStamp) reinterpret.stamp(NodeView.DEFAULT);
    Assert.assertEquals(Integer.SIZE, resultStamp.getBits());
    for (int result : interestingInts) {
        float input = Float.intBitsToFloat(result);
        if (inputStamp.contains(input) && !resultStamp.contains(result)) {
            Assert.fail(String.format("value %f (0x%x) is in input stamp, but not in result stamp (%s)", input, result, resultStamp));
        }
    }
}
Also used : ParameterNode(org.graalvm.compiler.nodes.ParameterNode) IntegerStamp(org.graalvm.compiler.core.common.type.IntegerStamp) ValueNode(org.graalvm.compiler.nodes.ValueNode) Test(org.junit.Test)

Aggregations

ParameterNode (org.graalvm.compiler.nodes.ParameterNode)46 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)19 ValueNode (org.graalvm.compiler.nodes.ValueNode)19 Node (org.graalvm.compiler.graph.Node)13 ConstantNode (org.graalvm.compiler.nodes.ConstantNode)13 ReturnNode (org.graalvm.compiler.nodes.ReturnNode)13 Test (org.junit.Test)10 ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)9 ResolvedJavaType (jdk.vm.ci.meta.ResolvedJavaType)8 DebugContext (org.graalvm.compiler.debug.DebugContext)7 FixedWithNextNode (org.graalvm.compiler.nodes.FixedWithNextNode)7 FrameState (org.graalvm.compiler.nodes.FrameState)7 InvokeWithExceptionNode (org.graalvm.compiler.nodes.InvokeWithExceptionNode)7 FixedNode (org.graalvm.compiler.nodes.FixedNode)6 CanonicalizerPhase (org.graalvm.compiler.phases.common.CanonicalizerPhase)6 AbstractMergeNode (org.graalvm.compiler.nodes.AbstractMergeNode)5 InvokeNode (org.graalvm.compiler.nodes.InvokeNode)5 PhiNode (org.graalvm.compiler.nodes.PhiNode)5 ArrayList (java.util.ArrayList)4 JavaConstant (jdk.vm.ci.meta.JavaConstant)4