use of org.graalvm.compiler.truffle.test.nodes.RootTestNode 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 org.graalvm.compiler.truffle.test.nodes.RootTestNode 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 org.graalvm.compiler.truffle.test.nodes.RootTestNode 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);
}
use of org.graalvm.compiler.truffle.test.nodes.RootTestNode in project graal by oracle.
the class SimplePartialEvaluationTest method synchronizedExceptionMerge.
@Test
public void synchronizedExceptionMerge() {
/*
* Multiple non-inlineable methods with exception edges called from a synchronized method
* lead to a complicated Graal graph that involves the BytecodeFrame.UNWIND_BCI. This test
* checks that partial evaluation handles that case correctly.
*/
FrameDescriptor fd = new FrameDescriptor();
AbstractTestNode result = new SynchronizedExceptionMergeNode();
RootNode rootNode = new RootTestNode(fd, "synchronizedExceptionMerge", result);
OptimizedCallTarget compilable = compileHelper("synchronizedExceptionMerge", rootNode, new Object[0]);
Assert.assertEquals(42, compilable.call(new Object[0]));
}
use of org.graalvm.compiler.truffle.test.nodes.RootTestNode in project graal by oracle.
the class SimplePartialEvaluationTest method intrinsicVirtual.
@Test
public void intrinsicVirtual() {
/*
* The intrinsic for String.equals() is inlined late during Truffle partial evaluation,
* because we call equals() on a value that has the static type Object, but during partial
* evaluation the more precise type String is known.
*/
FrameDescriptor fd = new FrameDescriptor();
AbstractTestNode result = new ObjectEqualsNode("abc", "abf");
RootNode rootNode = new RootTestNode(fd, "intrinsicVirtual", result);
OptimizedCallTarget compilable = compileHelper("intrinsicVirtual", rootNode, new Object[0]);
Assert.assertEquals(42, compilable.call(new Object[0]));
}
Aggregations