use of org.graalvm.compiler.truffle.test.nodes.RootTestNode in project graal by oracle.
the class AssumptionPartialEvaluationTest method assumptionBranchCutoff.
/**
* Tests whether a valid {@link Assumption} cuts off a non-executed branch.
*/
@Test
public void assumptionBranchCutoff() {
Assumption assumption = Truffle.getRuntime().createAssumption();
AssumptionCutsBranchTestNode result = new AssumptionCutsBranchTestNode(assumption);
RootTestNode rootNode = new RootTestNode(new FrameDescriptor(), "cutoffBranch", result);
OptimizedCallTarget compilable = compileHelper("cutoffBranch", rootNode, new Object[0]);
for (int i = 0; i < 100000; i++) {
Assert.assertEquals(0, compilable.call(new Object[0]));
}
Assert.assertNull(result.getChildNode());
}
use of org.graalvm.compiler.truffle.test.nodes.RootTestNode in project graal by oracle.
the class SimplePartialEvaluationTest method longSequenceConstants.
@Test
public void longSequenceConstants() {
FrameDescriptor fd = new FrameDescriptor();
int length = 40;
AbstractTestNode[] children = new AbstractTestNode[length];
for (int i = 0; i < children.length; ++i) {
children[i] = new ConstantTestNode(42);
}
AbstractTestNode result = new BlockTestNode(children);
assertPartialEvalEquals("constant42", new RootTestNode(fd, "longSequenceConstants", result));
}
use of org.graalvm.compiler.truffle.test.nodes.RootTestNode in project graal by oracle.
the class SimplePartialEvaluationTest method intrinsicStringHashCodeNonFinal.
@Test
public void intrinsicStringHashCodeNonFinal() {
/*
* The intrinsic for String.hashcode() does not trigger on non-constant strings, so the
* method String.hashCode() must be inlined during partial evaluation (so there must not be
* an invoke after partial evaluation).
*/
FrameDescriptor fd = new FrameDescriptor();
AbstractTestNode result = new StringHashCodeNonFinalNode("*");
assertPartialEvalNoInvokes(new RootTestNode(fd, "intrinsicStringHashCodeNonFinal", result));
}
use of org.graalvm.compiler.truffle.test.nodes.RootTestNode 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 org.graalvm.compiler.truffle.test.nodes.RootTestNode 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));
}
Aggregations