use of com.oracle.truffle.api.frame.FrameDescriptor in project graal by oracle.
the class CompilationFinalWeakReferencePartialEvaluationTest method compilationFinalWeakReferenceTestGC.
/**
* {@link WeakReference} constant-folded and embedded in compiled code.
*/
@Test
public void compilationFinalWeakReferenceTestGC() {
String name = "compilationFinalWeakReferenceTestGC";
FrameDescriptor fd = new FrameDescriptor();
IntSupplier data = generateTestData();
AbstractTestNode result = new CompilationFinalWeakReferenceTestGCNode(data);
RootTestNode rootNode = new RootTestNode(fd, name, result);
OptimizedCallTarget callTarget = compileHelper(name, rootNode, new Object[] { data });
Assert.assertEquals(42, (int) callTarget.call(new Object[] { data }));
Assert.assertEquals(-1, (int) callTarget.call(new Object[] { null }));
callTarget = compileHelper(name, rootNode, new Object[] { data });
assertTrue(callTarget.isValid());
assert data != null;
clearDebugScopeTL();
WeakReference<IntSupplier> witness = new WeakReference<>(data);
data = null;
boolean cleared = false;
for (int i = 1; i <= 5 && !cleared; i++) {
System.gc();
cleared = witness.get() == null;
}
assertTrue("Test data should have been garbage collected at this point", cleared);
// Compiled code had the collected reference embedded so it had to be invalidated
assertFalse(callTarget.isValid());
Assert.assertEquals(0xdead, (int) callTarget.call(new Object[] { null }));
}
use of com.oracle.truffle.api.frame.FrameDescriptor in project graal by oracle.
the class CompilerAssertsTest method compilationNonConstantTest.
@Test
public void compilationNonConstantTest() {
FrameDescriptor descriptor = new FrameDescriptor();
CompilationConstantTestNode result = new CompilationConstantTestNode(new NonConstantTestNode(5));
RootTestNode rootNode = new RootTestNode(descriptor, "compilationConstant", result);
try {
compileHelper("compilationConstant", rootNode, new Object[0]);
Assert.fail("Expected bailout exception because expression is not compilation constant");
} catch (BailoutException e) {
// Bailout exception expected.
}
}
use of com.oracle.truffle.api.frame.FrameDescriptor in project graal by oracle.
the class ControlFlowExceptionPartialEvaluationTest method catchControlFlowExceptionWithLoopExplosion.
@Test
public void catchControlFlowExceptionWithLoopExplosion() {
FrameDescriptor fd = new FrameDescriptor();
AbstractTestNode result = new CatchControlFlowExceptionTestNode(new BlockTestNode(new ThrowControlFlowExceptionTestNode()));
assertPartialEvalEquals("constant42", new RootTestNode(fd, "catchControlFlowExceptionWithLoopExplosion", result));
}
use of com.oracle.truffle.api.frame.FrameDescriptor in project graal by oracle.
the class ControlFlowExceptionPartialEvaluationTest method catchControlFlowException.
@Test
public void catchControlFlowException() {
FrameDescriptor fd = new FrameDescriptor();
AbstractTestNode result = new CatchControlFlowExceptionTestNode(new ThrowControlFlowExceptionTestNode());
assertPartialEvalEquals("constant42", new RootTestNode(fd, "catchControlFlowException", result));
}
use of com.oracle.truffle.api.frame.FrameDescriptor in project graal by oracle.
the class ControlFlowExceptionPartialEvaluationTest method catchSlowPathAndControlFlowException.
@Test
public void catchSlowPathAndControlFlowException() {
FrameDescriptor fd = new FrameDescriptor();
AbstractTestNode result = new CatchSlowPathAndControlFlowExceptionTestNode(new ThrowControlFlowExceptionTestNode());
assertPartialEvalEquals("constant42", new RootTestNode(fd, "catchSlowPathAndControlFlowException", result));
}
Aggregations