use of org.graalvm.compiler.truffle.common.TruffleDebugContext in project graal by oracle.
the class PolymorphicSpecializeDump method dumpPolymorphicSpecialize.
public static void dumpPolymorphicSpecialize(OptimizedCallTarget callTarget, List<Node> toDump) {
assert toDump.size() > 0;
try (TruffleDebugContext debugContext = openDebugContext(callTarget)) {
Collections.reverse(toDump);
PolymorphicSpecializeDump.PolymorphicSpecializeGraph graph = new PolymorphicSpecializeDump.PolymorphicSpecializeGraph(toDump);
final GraphOutput<PolymorphicSpecializeGraph, ?> output = debugContext.buildOutput(GraphOutput.newBuilder(new PolymorphicSpecializeDump.PolymorphicSpecializeGraphStructure()));
output.beginGroup(graph, "Polymorphic Specialize [" + callTarget + "]", "Polymorphic Specialize", null, 0, null);
output.print(graph, null, 0, toDump.get(toDump.size() - 1).toString());
output.endGroup();
output.close();
} catch (IOException e) {
e.printStackTrace();
}
}
use of org.graalvm.compiler.truffle.common.TruffleDebugContext 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);
}
}
use of org.graalvm.compiler.truffle.common.TruffleDebugContext in project graal by oracle.
the class TruffleToLibGraalEntryPoints method openDebugContext.
@TruffleToLibGraal(OpenDebugContext)
@CEntryPoint(name = "Java_org_graalvm_compiler_truffle_runtime_hotspot_libgraal_TruffleToLibGraalCalls_openDebugContext")
@SuppressWarnings({ "unused", "try" })
public static long openDebugContext(JNIEnv env, JClass hsClazz, @CEntryPoint.IsolateThreadContext long isolateThreadId, long compilerHandle, long compilationHandle, JByteArray hsOptions) {
try (JNIMethodScope s = LibGraalUtil.openScope(TruffleToLibGraalEntryPoints.class, OpenDebugContext, env)) {
HotSpotTruffleCompilerImpl compiler = LibGraalObjectHandles.resolve(compilerHandle, HotSpotTruffleCompilerImpl.class);
TruffleCompilation compilation = LibGraalObjectHandles.resolve(compilationHandle, TruffleCompilation.class);
Map<String, Object> options = decodeOptions(env, hsOptions);
TruffleDebugContext debugContext = compiler.openDebugContext(options, compilation);
long handle = LibGraalObjectHandles.create(debugContext);
return handle;
} catch (Throwable t) {
JNIExceptionWrapper.throwInHotSpot(env, t);
return 0;
}
}
use of org.graalvm.compiler.truffle.common.TruffleDebugContext in project graal by oracle.
the class TruffleCompilerImpl method openDebugContext.
@Override
public final TruffleDebugContext openDebugContext(Map<String, Object> options, TruffleCompilation compilation) {
OptionValues graalOptions = TruffleCompilerRuntime.getRuntime().getGraalOptions(OptionValues.class);
final DebugContext debugContext;
if (compilation == null) {
debugContext = new Builder(graalOptions).build();
} else {
TruffleCompilationIdentifier ident = asTruffleCompilationIdentifier(compilation);
CompilableTruffleAST compilable = ident.getCompilable();
org.graalvm.options.OptionValues truffleOptions = getOptionsForCompiler(options);
if (ExpansionStatistics.isEnabled(truffleOptions)) {
graalOptions = enableNodeSourcePositions(graalOptions);
}
debugContext = createDebugContext(graalOptions, ident, compilable, DebugContext.getDefaultLogStream());
}
return new TruffleDebugContextImpl(debugContext);
}
use of org.graalvm.compiler.truffle.common.TruffleDebugContext in project graal by oracle.
the class TruffleCompilerImpl method doCompile.
@Override
@SuppressWarnings("try")
public final void doCompile(TruffleDebugContext truffleDebug, TruffleCompilation compilation, Map<String, Object> optionsMap, TruffleCompilationTask task, TruffleCompilerListener inListener) {
Objects.requireNonNull(compilation, "Compilation must be non null.");
org.graalvm.options.OptionValues options = getOptionsForCompiler(optionsMap);
TruffleCompilationIdentifier compilationId = asTruffleCompilationIdentifier(compilation);
CompilableTruffleAST compilable = compilationId.getCompilable();
boolean usingCallersDebug = truffleDebug instanceof TruffleDebugContextImpl;
if (usingCallersDebug) {
final DebugContext callerDebug = ((TruffleDebugContextImpl) truffleDebug).debugContext;
try (DebugContext.Scope s = maybeOpenTruffleScope(compilable, callerDebug)) {
actuallyCompile(options, task, inListener, compilationId, compilable, callerDebug);
} catch (Throwable e) {
notifyCompilableOfFailure(compilable, e, isSuppressedFailure(compilable, e));
}
} else {
OptionValues debugContextOptionValues = TruffleCompilerRuntime.getRuntime().getGraalOptions(OptionValues.class);
try (DebugContext graalDebug = createDebugContext(debugContextOptionValues, compilationId, compilable, DebugContext.getDefaultLogStream());
DebugContext.Scope s = maybeOpenTruffleScope(compilable, graalDebug)) {
actuallyCompile(options, task, inListener, compilationId, compilable, graalDebug);
} catch (Throwable e) {
notifyCompilableOfFailure(compilable, e, isSuppressedFailure(compilable, e));
}
}
}
Aggregations