use of org.graalvm.compiler.truffle.common.TruffleInliningPlan in project graal by oracle.
the class PartialEvaluator method getDecision.
private static TruffleInliningPlan.Decision getDecision(TruffleInliningPlan inlining, JavaConstant callNode) {
TruffleInliningPlan.Decision decision = inlining.findDecision(callNode);
if (decision == null) {
JavaConstant target = getRuntime().getCallTargetForCallNode(callNode);
PerformanceInformationHandler.reportDecisionIsNull(target, callNode);
} else if (!decision.isTargetStable()) {
JavaConstant target = getRuntime().getCallTargetForCallNode(callNode);
PerformanceInformationHandler.reportCallTargetChanged(target, callNode, decision);
return null;
}
return decision;
}
use of org.graalvm.compiler.truffle.common.TruffleInliningPlan in project graal by oracle.
the class TransferToInterpreterTest method test.
@Test
public void test() {
RootNode rootNode = new TestRootNode();
GraalTruffleRuntime runtime = GraalTruffleRuntime.getRuntime();
OptimizedCallTarget target = (OptimizedCallTarget) runtime.createCallTarget(rootNode);
target.call(0);
Assert.assertFalse(target.isValid());
OptionValues options = TruffleCompilerOptions.getOptions();
DebugContext debug = DebugContext.create(options, DebugHandlersFactory.LOADER);
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);
Assert.assertTrue(target.isValid());
target.call(0);
Assert.assertTrue(target.isValid());
target.call(1);
Assert.assertFalse(target.isValid());
}
use of org.graalvm.compiler.truffle.common.TruffleInliningPlan 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));
}
}
}
Aggregations