Search in sources :

Example 11 with AbstractTestNode

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

the class SimplePartialEvaluationTest method explodeLoopUntilReturnWithThrow.

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

Example 12 with AbstractTestNode

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

the class SimplePartialEvaluationTest method intrinsicStringHashCodeFinal.

@Test
public void intrinsicStringHashCodeFinal() {
    /* The intrinsic for String.hashcode() triggers on constant strings. */
    FrameDescriptor fd = new FrameDescriptor();
    AbstractTestNode result = new StringHashCodeFinalNode("*");
    /* The hash code of "*" is 42. */
    assertPartialEvalEquals("constant42", new RootTestNode(fd, "intrinsicStringHashCodeFinal", result));
}
Also used : FrameDescriptor(com.oracle.truffle.api.frame.FrameDescriptor) AbstractTestNode(org.graalvm.compiler.truffle.test.nodes.AbstractTestNode) StringHashCodeFinalNode(org.graalvm.compiler.truffle.test.nodes.StringHashCodeFinalNode) RootTestNode(org.graalvm.compiler.truffle.test.nodes.RootTestNode) Test(org.junit.Test)

Example 13 with AbstractTestNode

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

the class SimplePartialEvaluationTest method sequenceConstants.

@Test
public void sequenceConstants() {
    FrameDescriptor fd = new FrameDescriptor();
    AbstractTestNode result = new BlockTestNode(new AbstractTestNode[] { new ConstantTestNode(40), new ConstantTestNode(42) });
    assertPartialEvalEquals("constant42", new RootTestNode(fd, "sequenceConstants", 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) RootTestNode(org.graalvm.compiler.truffle.test.nodes.RootTestNode) Test(org.junit.Test)

Example 14 with AbstractTestNode

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

the class SimplePartialEvaluationTest method twoMergesLoopExplosion.

@Test
public void twoMergesLoopExplosion() {
    FrameDescriptor fd = new FrameDescriptor();
    AbstractTestNode result = new AddTestNode(new TwoMergesExplodedLoopTestNode(5), new ConstantTestNode(37));
    assertPartialEvalEquals("constant42", new RootTestNode(fd, "twoMergesLoopExplosion", 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) TwoMergesExplodedLoopTestNode(org.graalvm.compiler.truffle.test.nodes.TwoMergesExplodedLoopTestNode) RootTestNode(org.graalvm.compiler.truffle.test.nodes.RootTestNode) AddTestNode(org.graalvm.compiler.truffle.test.nodes.AddTestNode) Test(org.junit.Test)

Example 15 with AbstractTestNode

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

the class SimplePartialEvaluationTest method intrinsicHashCode.

@Test
public void intrinsicHashCode() {
    /*
         * The intrinsic for Object.hashCode() is inlined late during Truffle partial evaluation,
         * because we call hashCode() on a value whose exact type Object is only known during
         * partial evaluation.
         */
    FrameDescriptor fd = new FrameDescriptor();
    Object testObject = new Object();
    AbstractTestNode result = new ObjectHashCodeNode(testObject);
    RootNode rootNode = new RootTestNode(fd, "intrinsicHashCode", result);
    OptimizedCallTarget compilable = compileHelper("intrinsicHashCode", rootNode, new Object[0]);
    int actual = (Integer) compilable.call(new Object[0]);
    int expected = testObject.hashCode();
    Assert.assertEquals(expected, actual);
}
Also used : FrameDescriptor(com.oracle.truffle.api.frame.FrameDescriptor) RootNode(com.oracle.truffle.api.nodes.RootNode) AbstractTestNode(org.graalvm.compiler.truffle.test.nodes.AbstractTestNode) ObjectHashCodeNode(org.graalvm.compiler.truffle.test.nodes.ObjectHashCodeNode) OptimizedCallTarget(org.graalvm.compiler.truffle.runtime.OptimizedCallTarget) RootTestNode(org.graalvm.compiler.truffle.test.nodes.RootTestNode) Test(org.junit.Test)

Aggregations

AbstractTestNode (org.graalvm.compiler.truffle.test.nodes.AbstractTestNode)46 Test (org.junit.Test)45 FrameDescriptor (com.oracle.truffle.api.frame.FrameDescriptor)43 RootTestNode (org.graalvm.compiler.truffle.test.nodes.RootTestNode)43 ConstantTestNode (org.graalvm.compiler.truffle.test.nodes.ConstantTestNode)13 OptimizedCallTarget (org.graalvm.compiler.truffle.runtime.OptimizedCallTarget)11 RootNode (com.oracle.truffle.api.nodes.RootNode)9 AddTestNode (org.graalvm.compiler.truffle.test.nodes.AddTestNode)7 BlockTestNode (org.graalvm.compiler.truffle.test.nodes.BlockTestNode)6 VirtualFrame (com.oracle.truffle.api.frame.VirtualFrame)5 LoadLocalTestNode (org.graalvm.compiler.truffle.test.nodes.LoadLocalTestNode)4 NestedExplodedLoopTestNode (org.graalvm.compiler.truffle.test.nodes.NestedExplodedLoopTestNode)3 StoreLocalTestNode (org.graalvm.compiler.truffle.test.nodes.StoreLocalTestNode)3 Assumption (com.oracle.truffle.api.Assumption)2 CallTarget (com.oracle.truffle.api.CallTarget)2 WeakReference (java.lang.ref.WeakReference)2 IntSupplier (java.util.function.IntSupplier)2 LoopTestNode (org.graalvm.compiler.truffle.test.nodes.LoopTestNode)2 TwoMergesExplodedLoopTestNode (org.graalvm.compiler.truffle.test.nodes.TwoMergesExplodedLoopTestNode)2 Ignore (org.junit.Ignore)2