Search in sources :

Example 1 with ObjectHashCodeNode

use of org.graalvm.compiler.truffle.test.nodes.ObjectHashCodeNode 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)1 RootNode (com.oracle.truffle.api.nodes.RootNode)1 OptimizedCallTarget (org.graalvm.compiler.truffle.runtime.OptimizedCallTarget)1 AbstractTestNode (org.graalvm.compiler.truffle.test.nodes.AbstractTestNode)1 ObjectHashCodeNode (org.graalvm.compiler.truffle.test.nodes.ObjectHashCodeNode)1 RootTestNode (org.graalvm.compiler.truffle.test.nodes.RootTestNode)1 Test (org.junit.Test)1