use of org.graalvm.compiler.truffle.common.TruffleCompilerOptions.TruffleOptionsOverrideScope in project graal by oracle.
the class PerformanceWarningTest method testHelper.
@SuppressWarnings("try")
private static void testHelper(RootNode rootNode, boolean expectException, String... outputStrings) {
GraalTruffleRuntime runtime = GraalTruffleRuntime.getRuntime();
OptimizedCallTarget target = (OptimizedCallTarget) runtime.createCallTarget(rootNode);
// Compile and capture output to TTY.
ByteArrayOutputStream outContent = new ByteArrayOutputStream();
boolean seenException = false;
try (TTY.Filter filter = new TTY.Filter(new LogStream(outContent))) {
try (TruffleOptionsOverrideScope scope = TruffleCompilerOptions.overrideOptions(TruffleCompilerOptions.TraceTrufflePerformanceWarnings, Boolean.TRUE);
TruffleOptionsOverrideScope scope2 = TruffleCompilerOptions.overrideOptions(TruffleCompilerOptions.TrufflePerformanceWarningsAreFatal, Boolean.TRUE)) {
OptionValues options = TruffleCompilerOptions.getOptions();
DebugContext debug = DebugContext.create(options, DebugHandlersFactory.LOADER);
try (DebugCloseable d = debug.disableIntercept();
DebugContext.Scope s = debug.scope("PerformanceWarningTest")) {
final OptimizedCallTarget compilable = target;
TruffleCompilerImpl compiler = (TruffleCompilerImpl) runtime.newTruffleCompiler();
CompilationIdentifier compilationId = compiler.getCompilationIdentifier(compilable);
TruffleInliningPlan inliningPlan = new TruffleInlining(compilable, new DefaultInliningPolicy());
compiler.compileAST(debug, compilable, inliningPlan, compilationId, null, null);
}
} catch (AssertionError e) {
seenException = true;
if (!expectException) {
throw new AssertionError("Unexpected exception caught", e);
}
}
}
if (expectException && !seenException) {
Assert.assertTrue("Expected exception not caught.", false);
}
// Check output on TTY.
String output = outContent.toString();
if (outputStrings == EMPTY_PERF_WARNINGS) {
Assert.assertEquals("", output);
} else {
for (String s : outputStrings) {
Assert.assertTrue(String.format("Root node class %s: \"%s\" not found in output \"%s\"", rootNode.getClass(), s, output), output.contains(s));
}
}
}
use of org.graalvm.compiler.truffle.common.TruffleCompilerOptions.TruffleOptionsOverrideScope in project graal by oracle.
the class OptimizedCallTargetTest method testCompileOnly4.
@Test
public void testCompileOnly4() {
// OSR should not trigger for compile-only includes
try (TruffleOptionsOverrideScope scope = TruffleCompilerOptions.overrideOptions(TruffleCompileOnly, "foobar")) {
final OSRRepeatingNode repeating = new OSRRepeatingNode(TruffleCompilerOptions.getValue(TruffleOSRCompilationThreshold));
final LoopNode loop = runtime.createLoopNode(repeating);
OptimizedCallTarget target = (OptimizedCallTarget) runtime.createCallTarget(new NamedRootNode("foobar") {
@Child
LoopNode loopChild = loop;
@Override
public Object execute(VirtualFrame frame) {
loopChild.executeLoop(frame);
return super.execute(frame);
}
});
target.call();
OptimizedCallTarget osrTarget = findOSRTarget(loop);
if (osrTarget != null) {
assertNotCompiled(osrTarget);
}
}
}
use of org.graalvm.compiler.truffle.common.TruffleCompilerOptions.TruffleOptionsOverrideScope in project graal by oracle.
the class OptimizedCallTargetTest method testCompileOnly1.
@Test
public void testCompileOnly1() {
final int compilationThreshold = TruffleCompilerOptions.getValue(TruffleCompilationThreshold);
try (TruffleOptionsOverrideScope scope = TruffleCompilerOptions.overrideOptions(TruffleCompileOnly, "foobar")) {
OptimizedCallTarget target = (OptimizedCallTarget) runtime.createCallTarget(new NamedRootNode("foobar"));
for (int i = 0; i < compilationThreshold; i++) {
assertNotCompiled(target);
target.call();
}
assertCompiled(target);
target = (OptimizedCallTarget) runtime.createCallTarget(new NamedRootNode("baz"));
for (int i = 0; i < compilationThreshold; i++) {
assertNotCompiled(target);
target.call();
}
assertNotCompiled(target);
}
}
use of org.graalvm.compiler.truffle.common.TruffleCompilerOptions.TruffleOptionsOverrideScope in project graal by oracle.
the class TruffleToTruffleCallExceptionHandlerTest method testExceptionOnceCompileExceptionHandler.
@Test
@SuppressWarnings("try")
@Ignore
public void testExceptionOnceCompileExceptionHandler() {
/*
* call the function at least once so the exception profile will record an exception and the
* partial evaluator will compile the exception handler edge
*/
try {
calleeWithException.callDirect(new Object());
Assert.fail();
} catch (Throwable t) {
Assert.assertTrue(t instanceof RuntimeException);
}
/*
* We disable truffle AST inlining to not inline the callee
*/
try (TruffleOptionsOverrideScope o = TruffleCompilerOptions.overrideOptions(TruffleCompilerOptions.TruffleFunctionInlining, false)) {
StructuredGraph graph = partialEval(callerWithException, new Object[0], AllowAssumptions.YES);
Assert.assertEquals(1, graph.getNodes().filter(UnwindNode.class).count());
}
}
use of org.graalvm.compiler.truffle.common.TruffleCompilerOptions.TruffleOptionsOverrideScope in project graal by oracle.
the class TruffleToTruffleCallExceptionHandlerTest method testNeverSeenExceptionHandlerSkipped.
@Test
@SuppressWarnings("try")
public void testNeverSeenExceptionHandlerSkipped() {
/*
* We disable truffle AST inlining to not inline the callee
*/
try (TruffleOptionsOverrideScope o = TruffleCompilerOptions.overrideOptions(TruffleCompilerOptions.TruffleFunctionInlining, false)) {
StructuredGraph graph = partialEval(callerNoException, new Object[0], AllowAssumptions.YES);
Assert.assertEquals(0, graph.getNodes().filter(UnwindNode.class).count());
}
}
Aggregations