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));
}
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));
}
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));
}
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));
}
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);
}
Aggregations