use of org.graalvm.compiler.truffle.common.TruffleCompilationTask in project graal by oracle.
the class PerformanceWarningTest method testHelper.
@SuppressWarnings("try")
private void testHelper(RootNode rootNode, boolean expectException, String... outputStrings) {
// Compile and capture output to logger's stream.
boolean seenException = false;
try {
OptimizedCallTarget target = (OptimizedCallTarget) rootNode.getCallTarget();
DebugContext debug = new Builder(GraalTruffleRuntime.getRuntime().getGraalOptions(OptionValues.class)).build();
try (DebugCloseable d = debug.disableIntercept();
DebugContext.Scope s = debug.scope("PerformanceWarningTest")) {
final OptimizedCallTarget compilable = target;
CompilationIdentifier compilationId = getTruffleCompiler(target).createCompilationIdentifier(compilable);
getTruffleCompiler(target).compileAST(compilable.getOptionValues(), debug, compilable, compilationId, new TruffleCompilerImpl.CancellableTruffleCompilationTask(new TruffleCompilationTask() {
private TruffleInliningData inlining = new TruffleInlining();
@Override
public boolean isCancelled() {
return false;
}
@Override
public boolean isLastTier() {
return true;
}
@Override
public TruffleInliningData inliningData() {
return inlining;
}
@Override
public boolean hasNextTier() {
return false;
}
}), null);
assertTrue(compilable.isValid());
}
} catch (AssertionError e) {
seenException = true;
if (!expectException) {
throw new AssertionError("Unexpected exception caught." + (outContent.size() > 0 ? '\n' + outContent.toString() : ""), 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().getName(), s, output), output.contains(s));
}
}
}
use of org.graalvm.compiler.truffle.common.TruffleCompilationTask in project graal by oracle.
the class TruffleToLibGraalEntryPoints method doCompile.
@TruffleToLibGraal(DoCompile)
@SuppressWarnings({ "unused", "try" })
@CEntryPoint(name = "Java_org_graalvm_compiler_truffle_runtime_hotspot_libgraal_TruffleToLibGraalCalls_doCompile")
public static void doCompile(JNIEnv env, JClass hsClazz, @CEntryPoint.IsolateThreadContext long isolateThreadId, long compilerHandle, long debugContextHandle, long compilationHandle, JByteArray hsOptions, JObject hsTask, JObject hsListener) {
try (JNIMethodScope scope = LibGraalUtil.openScope(TruffleToLibGraalEntryPoints.class, DoCompile, env)) {
TruffleCompilationIdentifier compilation = LibGraalObjectHandles.resolve(compilationHandle, TruffleCompilationIdentifier.class);
try (CompilationContext hotSpotObjectConstantScope = HotSpotGraalServices.openLocalCompilationContext(compilation)) {
HotSpotTruffleCompilerImpl compiler = LibGraalObjectHandles.resolve(compilerHandle, HotSpotTruffleCompilerImpl.class);
TruffleDebugContext debugContext = LibGraalObjectHandles.resolve(debugContextHandle, TruffleDebugContext.class);
Map<String, Object> options = decodeOptions(env, hsOptions);
TruffleCompilationTask task = hsTask.isNull() ? null : new HSTruffleCompilationTask(hsTask);
TruffleCompilerListener listener = hsListener.isNull() ? null : new HSTruffleCompilerListener(scope, hsListener);
compiler.doCompile(debugContext, compilation, options, task, listener);
}
} catch (Throwable t) {
JNIExceptionWrapper.throwInHotSpot(env, t);
}
}
Aggregations