use of com.oracle.truffle.api.nodes.RootNode in project graal by oracle.
the class SimplePartialEvaluationTest method inliningNullCheck2.
@Test
public void inliningNullCheck2() {
FrameDescriptor fd = new FrameDescriptor();
AbstractTestNode result = new InliningNullCheckNode2();
RootNode rootNode = new RootTestNode(fd, "inliningNullCheck2", result);
OptimizedCallTarget compilable = compileHelper("inliningNullCheck2", rootNode, new Object[0]);
Assert.assertEquals(42, compilable.call(new Object[0]));
}
use of com.oracle.truffle.api.nodes.RootNode in project graal by oracle.
the class SimplePartialEvaluationTest method inliningNullCheck1.
@Test
public void inliningNullCheck1() {
FrameDescriptor fd = new FrameDescriptor();
AbstractTestNode result = new InliningNullCheckNode1();
RootNode rootNode = new RootTestNode(fd, "inliningNullCheck1", result);
OptimizedCallTarget compilable = compileHelper("inliningNullCheck1", rootNode, new Object[0]);
Assert.assertEquals(42, compilable.call(new Object[0]));
}
use of com.oracle.truffle.api.nodes.RootNode in project graal by oracle.
the class SimplePartialEvaluationTest method intrinsicStatic.
@Test
public void intrinsicStatic() {
/*
* The intrinsic for String.equals() is inlined early during bytecode parsing, because we
* call equals() on a value that has the static type String.
*/
FrameDescriptor fd = new FrameDescriptor();
AbstractTestNode result = new StringEqualsNode("abc", "abf");
RootNode rootNode = new RootTestNode(fd, "intrinsicStatic", result);
OptimizedCallTarget compilable = compileHelper("intrinsicStatic", rootNode, new Object[0]);
Assert.assertEquals(42, compilable.call(new Object[0]));
}
use of com.oracle.truffle.api.nodes.RootNode in project graal by oracle.
the class TruffleBoundaryExceptionsTest method testExceptionOnTruffleBoundaryWithNoCatch.
@Test
public void testExceptionOnTruffleBoundaryWithNoCatch() {
final int compilationThreshold = TruffleCompilerOptions.getValue(TruffleCompilationThreshold);
class DeoptCountingExceptionOverBoundaryRootNode extends RootNode {
protected DeoptCountingExceptionOverBoundaryRootNode() {
super(null);
}
int deopCounter = 0;
@Override
public Object execute(VirtualFrame frame) {
boolean startedCompiled = CompilerDirectives.inCompiledCode();
throwExceptionBoundary();
if (startedCompiled && CompilerDirectives.inInterpreter()) {
deopCounter++;
}
return null;
}
@CompilerDirectives.TruffleBoundary
public void throwExceptionBoundary() {
throw new RuntimeException();
}
}
final OptimizedCallTarget outerTarget = (OptimizedCallTarget) runtime.createCallTarget(new DeoptCountingExceptionOverBoundaryRootNode());
for (int i = 0; i < compilationThreshold; i++) {
try {
outerTarget.call();
} catch (RuntimeException e) {
// do nothing
}
}
assertCompiled(outerTarget);
final int execCount = 10;
for (int i = 0; i < execCount; i++) {
try {
outerTarget.call();
} catch (RuntimeException e) {
// do nothing
}
}
int deopCount = ((DeoptCountingExceptionOverBoundaryRootNode) outerTarget.getRootNode()).deopCounter;
Assert.assertEquals("Incorrect number of deops detected!", 0, deopCount);
}
use of com.oracle.truffle.api.nodes.RootNode in project graal by oracle.
the class TruffleBoundaryExceptionsTest method testExceptionOnTruffleBoundaryWithNoTransferToInterpreter.
@Test
public void testExceptionOnTruffleBoundaryWithNoTransferToInterpreter() {
final int compilationThreshold = TruffleCompilerOptions.getValue(TruffleCompilationThreshold);
class DeoptCountingExceptionOverBoundaryRootNode extends RootNode {
protected DeoptCountingExceptionOverBoundaryRootNode() {
super(null);
}
int deopCounter = 0;
int catchCounter = 0;
@Override
public Object execute(VirtualFrame frame) {
boolean startedCompiled = CompilerDirectives.inCompiledCode();
try {
throwExceptionBoundary();
} catch (RuntimeException e) {
catchCounter++;
}
if (startedCompiled && CompilerDirectives.inInterpreter()) {
deopCounter++;
}
return null;
}
@CompilerDirectives.TruffleBoundary(transferToInterpreterOnException = false)
public void throwExceptionBoundary() {
throw new RuntimeException();
}
}
final OptimizedCallTarget outerTarget = (OptimizedCallTarget) runtime.createCallTarget(new DeoptCountingExceptionOverBoundaryRootNode());
for (int i = 0; i < compilationThreshold; i++) {
outerTarget.call();
}
assertCompiled(outerTarget);
final int execCount = 10;
for (int i = 0; i < execCount; i++) {
outerTarget.call();
}
final int totalExecutions = compilationThreshold + execCount;
int catchCount = ((DeoptCountingExceptionOverBoundaryRootNode) outerTarget.getRootNode()).catchCounter;
Assert.assertEquals("Incorrect number of catch block executions", totalExecutions, catchCount);
int deopCount = ((DeoptCountingExceptionOverBoundaryRootNode) outerTarget.getRootNode()).deopCounter;
Assert.assertEquals("Incorrect number of deops detected!", 0, deopCount);
}
Aggregations