Search in sources :

Example 6 with TruffleDebugContext

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();
    }
}
Also used : TruffleDebugContext(org.graalvm.compiler.truffle.common.TruffleDebugContext) IOException(java.io.IOException)

Example 7 with TruffleDebugContext

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);
    }
}
Also used : TruffleCompilationIdentifier(org.graalvm.compiler.truffle.compiler.TruffleCompilationIdentifier) JNIMethodScope(org.graalvm.jniutils.JNIMethodScope) TruffleDebugContext(org.graalvm.compiler.truffle.common.TruffleDebugContext) JNIUtil.createString(org.graalvm.jniutils.JNIUtil.createString) JString(org.graalvm.jniutils.JNI.JString) GetSuppliedString(org.graalvm.compiler.truffle.common.hotspot.libgraal.TruffleToLibGraal.Id.GetSuppliedString) JNIUtil.createHSString(org.graalvm.jniutils.JNIUtil.createHSString) TruffleCompilationTask(org.graalvm.compiler.truffle.common.TruffleCompilationTask) HotSpotTruffleCompilerImpl(org.graalvm.compiler.truffle.compiler.hotspot.HotSpotTruffleCompilerImpl) CompilationContext(org.graalvm.compiler.hotspot.CompilationContext) HSObject(org.graalvm.jniutils.HSObject) JObject(org.graalvm.jniutils.JNI.JObject) TruffleCompilerListener(org.graalvm.compiler.truffle.common.TruffleCompilerListener) CEntryPoint(org.graalvm.nativeimage.c.function.CEntryPoint) TruffleToLibGraal(org.graalvm.compiler.truffle.common.hotspot.libgraal.TruffleToLibGraal)

Example 8 with TruffleDebugContext

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;
    }
}
Also used : JNIMethodScope(org.graalvm.jniutils.JNIMethodScope) TruffleCompilation(org.graalvm.compiler.truffle.common.TruffleCompilation) TruffleDebugContext(org.graalvm.compiler.truffle.common.TruffleDebugContext) HSObject(org.graalvm.jniutils.HSObject) JObject(org.graalvm.jniutils.JNI.JObject) JNIUtil.createString(org.graalvm.jniutils.JNIUtil.createString) JString(org.graalvm.jniutils.JNI.JString) GetSuppliedString(org.graalvm.compiler.truffle.common.hotspot.libgraal.TruffleToLibGraal.Id.GetSuppliedString) JNIUtil.createHSString(org.graalvm.jniutils.JNIUtil.createHSString) HotSpotTruffleCompilerImpl(org.graalvm.compiler.truffle.compiler.hotspot.HotSpotTruffleCompilerImpl) CEntryPoint(org.graalvm.nativeimage.c.function.CEntryPoint) TruffleToLibGraal(org.graalvm.compiler.truffle.common.hotspot.libgraal.TruffleToLibGraal)

Example 9 with TruffleDebugContext

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);
}
Also used : OptionValues(org.graalvm.compiler.options.OptionValues) Builder(org.graalvm.compiler.debug.DebugContext.Builder) TruffleDebugContext(org.graalvm.compiler.truffle.common.TruffleDebugContext) DebugContext(org.graalvm.compiler.debug.DebugContext) CompilableTruffleAST(org.graalvm.compiler.truffle.common.CompilableTruffleAST)

Example 10 with TruffleDebugContext

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));
        }
    }
}
Also used : OptionValues(org.graalvm.compiler.options.OptionValues) Scope(org.graalvm.compiler.debug.DebugContext.Scope) TruffleDebugContext(org.graalvm.compiler.truffle.common.TruffleDebugContext) DebugContext(org.graalvm.compiler.debug.DebugContext) CompilableTruffleAST(org.graalvm.compiler.truffle.common.CompilableTruffleAST)

Aggregations

TruffleDebugContext (org.graalvm.compiler.truffle.common.TruffleDebugContext)10 TruffleCompilation (org.graalvm.compiler.truffle.common.TruffleCompilation)4 TruffleToLibGraal (org.graalvm.compiler.truffle.common.hotspot.libgraal.TruffleToLibGraal)4 JNIMethodScope (org.graalvm.jniutils.JNIMethodScope)4 CEntryPoint (org.graalvm.nativeimage.c.function.CEntryPoint)4 TruffleCompiler (org.graalvm.compiler.truffle.common.TruffleCompiler)3 GetSuppliedString (org.graalvm.compiler.truffle.common.hotspot.libgraal.TruffleToLibGraal.Id.GetSuppliedString)3 JString (org.graalvm.jniutils.JNI.JString)3 JNIUtil.createHSString (org.graalvm.jniutils.JNIUtil.createHSString)3 JNIUtil.createString (org.graalvm.jniutils.JNIUtil.createString)3 DebugContext (org.graalvm.compiler.debug.DebugContext)2 OptionValues (org.graalvm.compiler.options.OptionValues)2 CompilableTruffleAST (org.graalvm.compiler.truffle.common.CompilableTruffleAST)2 TruffleCompilationIdentifier (org.graalvm.compiler.truffle.compiler.TruffleCompilationIdentifier)2 HotSpotTruffleCompilerImpl (org.graalvm.compiler.truffle.compiler.hotspot.HotSpotTruffleCompilerImpl)2 GraalTruffleRuntime (org.graalvm.compiler.truffle.runtime.GraalTruffleRuntime)2 OptimizedCallTarget (org.graalvm.compiler.truffle.runtime.OptimizedCallTarget)2 HSObject (org.graalvm.jniutils.HSObject)2 JObject (org.graalvm.jniutils.JNI.JObject)2 OptimizationFailedException (com.oracle.truffle.api.OptimizationFailedException)1