Search in sources :

Example 6 with ConstantTestNode

use of org.graalvm.compiler.truffle.test.nodes.ConstantTestNode in project graal by oracle.

the class SimplePartialEvaluationTest method addConstants.

@Test
public void addConstants() {
    FrameDescriptor fd = new FrameDescriptor();
    AbstractTestNode result = new AddTestNode(new ConstantTestNode(40), new ConstantTestNode(2));
    assertPartialEvalEquals("constant42", new RootTestNode(fd, "addConstants", result));
}
Also used : FrameDescriptor(com.oracle.truffle.api.frame.FrameDescriptor) AbstractTestNode(org.graalvm.compiler.truffle.test.nodes.AbstractTestNode) ConstantTestNode(org.graalvm.compiler.truffle.test.nodes.ConstantTestNode) RootTestNode(org.graalvm.compiler.truffle.test.nodes.RootTestNode) AddTestNode(org.graalvm.compiler.truffle.test.nodes.AddTestNode) Test(org.junit.Test)

Example 7 with ConstantTestNode

use of org.graalvm.compiler.truffle.test.nodes.ConstantTestNode in project graal by oracle.

the class SimplePartialEvaluationTest method constantValue.

@Test
public void constantValue() {
    FrameDescriptor fd = new FrameDescriptor();
    AbstractTestNode result = new ConstantTestNode(42);
    assertPartialEvalEquals("constant42", new RootTestNode(fd, "constantValue", result));
}
Also used : FrameDescriptor(com.oracle.truffle.api.frame.FrameDescriptor) AbstractTestNode(org.graalvm.compiler.truffle.test.nodes.AbstractTestNode) ConstantTestNode(org.graalvm.compiler.truffle.test.nodes.ConstantTestNode) RootTestNode(org.graalvm.compiler.truffle.test.nodes.RootTestNode) Test(org.junit.Test)

Example 8 with ConstantTestNode

use of org.graalvm.compiler.truffle.test.nodes.ConstantTestNode in project graal by oracle.

the class SimplePartialEvaluationTest method neverPartOfCompilationTest.

@Test
public void neverPartOfCompilationTest() {
    FrameDescriptor fd = new FrameDescriptor();
    AbstractTestNode firstTree = new NeverPartOfCompilationTestNode(new ConstantTestNode(1), 2);
    assertPartialEvalEquals("constant42", new RootTestNode(fd, "neverPartOfCompilationTest", firstTree));
    AbstractTestNode secondTree = new NeverPartOfCompilationTestNode(new ConstantTestNode(1), 1);
    try {
        assertPartialEvalEquals("constant42", new RootTestNode(fd, "neverPartOfCompilationTest", secondTree));
        Assert.fail("Expected verification error!");
    } catch (SourceStackTraceBailoutException t) {
        // Expected verification error occurred.
        StackTraceElement[] trace = t.getStackTrace();
        assertStack(trace[0], "org.graalvm.compiler.truffle.test.nodes.NeverPartOfCompilationTestNode", "execute", "NeverPartOfCompilationTestNode.java");
        if (!truffleCompiler.getPartialEvaluator().getConfigForParsing().trackNodeSourcePosition() && !GraalOptions.TrackNodeSourcePosition.getValue(getInitialOptions())) {
            assertStack(trace[1], "org.graalvm.compiler.truffle.test.nodes.RootTestNode", "execute", "RootTestNode.java");
        } else {
        // When NodeSourcePosition tracking is enabled, a smaller stack trace is produced
        }
    }
}
Also used : FrameDescriptor(com.oracle.truffle.api.frame.FrameDescriptor) SourceStackTraceBailoutException(org.graalvm.compiler.code.SourceStackTraceBailoutException) AbstractTestNode(org.graalvm.compiler.truffle.test.nodes.AbstractTestNode) ConstantTestNode(org.graalvm.compiler.truffle.test.nodes.ConstantTestNode) NeverPartOfCompilationTestNode(org.graalvm.compiler.truffle.test.nodes.NeverPartOfCompilationTestNode) RootTestNode(org.graalvm.compiler.truffle.test.nodes.RootTestNode) Test(org.junit.Test)

Example 9 with ConstantTestNode

use of org.graalvm.compiler.truffle.test.nodes.ConstantTestNode in project graal by oracle.

the class SimplePartialEvaluationTest method mixLocalAndAdd.

@Test
public void mixLocalAndAdd() {
    FrameDescriptor fd = new FrameDescriptor();
    AbstractTestNode result = new BlockTestNode(new AbstractTestNode[] { new StoreLocalTestNode("x", fd, new ConstantTestNode(40)), new StoreLocalTestNode("x", fd, new AddTestNode(new LoadLocalTestNode("x", fd), new ConstantTestNode(2))), new LoadLocalTestNode("x", fd) });
    assertPartialEvalEquals("constant42", new RootTestNode(fd, "mixLocalAndAdd", result));
}
Also used : FrameDescriptor(com.oracle.truffle.api.frame.FrameDescriptor) BlockTestNode(org.graalvm.compiler.truffle.test.nodes.BlockTestNode) AbstractTestNode(org.graalvm.compiler.truffle.test.nodes.AbstractTestNode) ConstantTestNode(org.graalvm.compiler.truffle.test.nodes.ConstantTestNode) StoreLocalTestNode(org.graalvm.compiler.truffle.test.nodes.StoreLocalTestNode) LoadLocalTestNode(org.graalvm.compiler.truffle.test.nodes.LoadLocalTestNode) RootTestNode(org.graalvm.compiler.truffle.test.nodes.RootTestNode) AddTestNode(org.graalvm.compiler.truffle.test.nodes.AddTestNode) Test(org.junit.Test)

Example 10 with ConstantTestNode

use of org.graalvm.compiler.truffle.test.nodes.ConstantTestNode in project graal by oracle.

the class SimplePartialEvaluationTest method longAddConstants.

@Test
public void longAddConstants() {
    FrameDescriptor fd = new FrameDescriptor();
    AbstractTestNode result = new ConstantTestNode(2);
    for (int i = 0; i < 20; ++i) {
        result = new AddTestNode(result, new ConstantTestNode(2));
    }
    assertPartialEvalEquals("constant42", new RootTestNode(fd, "longAddConstants", result));
}
Also used : FrameDescriptor(com.oracle.truffle.api.frame.FrameDescriptor) AbstractTestNode(org.graalvm.compiler.truffle.test.nodes.AbstractTestNode) ConstantTestNode(org.graalvm.compiler.truffle.test.nodes.ConstantTestNode) RootTestNode(org.graalvm.compiler.truffle.test.nodes.RootTestNode) AddTestNode(org.graalvm.compiler.truffle.test.nodes.AddTestNode) Test(org.junit.Test)

Aggregations

FrameDescriptor (com.oracle.truffle.api.frame.FrameDescriptor)14 ConstantTestNode (org.graalvm.compiler.truffle.test.nodes.ConstantTestNode)14 RootTestNode (org.graalvm.compiler.truffle.test.nodes.RootTestNode)14 Test (org.junit.Test)14 AbstractTestNode (org.graalvm.compiler.truffle.test.nodes.AbstractTestNode)13 AddTestNode (org.graalvm.compiler.truffle.test.nodes.AddTestNode)7 BlockTestNode (org.graalvm.compiler.truffle.test.nodes.BlockTestNode)6 LoadLocalTestNode (org.graalvm.compiler.truffle.test.nodes.LoadLocalTestNode)4 StoreLocalTestNode (org.graalvm.compiler.truffle.test.nodes.StoreLocalTestNode)4 NestedExplodedLoopTestNode (org.graalvm.compiler.truffle.test.nodes.NestedExplodedLoopTestNode)3 TwoMergesExplodedLoopTestNode (org.graalvm.compiler.truffle.test.nodes.TwoMergesExplodedLoopTestNode)3 LoopTestNode (org.graalvm.compiler.truffle.test.nodes.LoopTestNode)2 Assumption (com.oracle.truffle.api.Assumption)1 CallTarget (com.oracle.truffle.api.CallTarget)1 CompilerDirectives (com.oracle.truffle.api.CompilerDirectives)1 Truffle (com.oracle.truffle.api.Truffle)1 VirtualFrame (com.oracle.truffle.api.frame.VirtualFrame)1 DirectCallNode (com.oracle.truffle.api.nodes.DirectCallNode)1 LoopNode (com.oracle.truffle.api.nodes.LoopNode)1 Node (com.oracle.truffle.api.nodes.Node)1