use of org.graalvm.compiler.truffle.runtime.TruffleInlining in project graal by oracle.
the class PerformanceTruffleInliningTest method reflectivelyGetExploreMethod.
private static Method reflectivelyGetExploreMethod() {
try {
final Class<?> truffleInliningClass = Class.forName(TruffleInlining.class.getName());
final Class<?>[] args = { List.class, int.class, TruffleInliningPolicy.class, int[].class, Map.class };
final Method exploreCallSitesMethod = truffleInliningClass.getDeclaredMethod("exploreCallSites", args);
ReflectionUtils.setAccessible(exploreCallSitesMethod, true);
return exploreCallSitesMethod;
} catch (ClassNotFoundException e) {
Assert.assertFalse("Could not find TruffleInlining class", true);
return null;
} catch (NoSuchMethodException e) {
Assert.assertFalse("Could not find exploreCallSites method", true);
return null;
}
}
use of org.graalvm.compiler.truffle.runtime.TruffleInlining 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.runtime.TruffleInlining in project graal by oracle.
the class BasicTruffleInliningTest method testFrequency.
@Test
public void testFrequency() {
// @formatter:off
TruffleInlining decisions = builder.target("callee").target("caller").execute(4).calls("callee", 2).buildDecisions();
// @formatter:on
assertInlined(decisions, "callee");
Assert.assertEquals(0.5, decisions.getCallSites().get(0).getProfile().getFrequency(), 0);
}
use of org.graalvm.compiler.truffle.runtime.TruffleInlining in project graal by oracle.
the class BasicTruffleInliningTest method testSimpleInline.
@Test
public void testSimpleInline() {
// @formatter:off
TruffleInlining decisions = builder.target("callee").target("caller").calls("callee").buildDecisions();
// @formatter:on
assertInlined(decisions, "callee");
}
use of org.graalvm.compiler.truffle.runtime.TruffleInlining in project graal by oracle.
the class BasicTruffleInliningTest method testInlineBigWithCallSites.
@Test
public void testInlineBigWithCallSites() {
// @formatter:off
TruffleInlining decisions = builder.target("callee", (TruffleCompilerOptions.getValue(TruffleInliningMaxCallerSize) / 3) - 3).target("caller").calls("callee").calls("callee").calls("callee").buildDecisions(true);
// @formatter:on
Assert.assertEquals(3, countInlines(decisions, "callee"));
}
Aggregations