Search in sources :

Example 26 with FrameDescriptor

use of com.oracle.truffle.api.frame.FrameDescriptor 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 27 with FrameDescriptor

use of com.oracle.truffle.api.frame.FrameDescriptor 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 28 with FrameDescriptor

use of com.oracle.truffle.api.frame.FrameDescriptor 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 29 with FrameDescriptor

use of com.oracle.truffle.api.frame.FrameDescriptor 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 30 with FrameDescriptor

use of com.oracle.truffle.api.frame.FrameDescriptor 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

FrameDescriptor (com.oracle.truffle.api.frame.FrameDescriptor)72 Test (org.junit.Test)61 RootTestNode (org.graalvm.compiler.truffle.test.nodes.RootTestNode)50 AbstractTestNode (org.graalvm.compiler.truffle.test.nodes.AbstractTestNode)43 OptimizedCallTarget (org.graalvm.compiler.truffle.runtime.OptimizedCallTarget)14 ConstantTestNode (org.graalvm.compiler.truffle.test.nodes.ConstantTestNode)14 RootNode (com.oracle.truffle.api.nodes.RootNode)12 VirtualFrame (com.oracle.truffle.api.frame.VirtualFrame)9 FrameSlot (com.oracle.truffle.api.frame.FrameSlot)7 AddTestNode (org.graalvm.compiler.truffle.test.nodes.AddTestNode)7 BlockTestNode (org.graalvm.compiler.truffle.test.nodes.BlockTestNode)6 Assumption (com.oracle.truffle.api.Assumption)5 CallTarget (com.oracle.truffle.api.CallTarget)5 TruffleRuntime (com.oracle.truffle.api.TruffleRuntime)3 LoadLocalTestNode (org.graalvm.compiler.truffle.test.nodes.LoadLocalTestNode)3 NestedExplodedLoopTestNode (org.graalvm.compiler.truffle.test.nodes.NestedExplodedLoopTestNode)3 StoreLocalTestNode (org.graalvm.compiler.truffle.test.nodes.StoreLocalTestNode)3 RootCallTarget (com.oracle.truffle.api.RootCallTarget)2 WeakReference (java.lang.ref.WeakReference)2 List (java.util.List)2