Search in sources :

Example 6 with TruffleCompilationTask

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));
        }
    }
}
Also used : CompilationIdentifier(org.graalvm.compiler.core.common.CompilationIdentifier) TruffleCompilerImpl(org.graalvm.compiler.truffle.compiler.TruffleCompilerImpl) Builder(org.graalvm.compiler.debug.DebugContext.Builder) OptimizedCallTarget(org.graalvm.compiler.truffle.runtime.OptimizedCallTarget) TruffleInliningData(org.graalvm.compiler.truffle.common.TruffleInliningData) DebugContext(org.graalvm.compiler.debug.DebugContext) TruffleCompilationTask(org.graalvm.compiler.truffle.common.TruffleCompilationTask) TruffleInlining(org.graalvm.compiler.truffle.runtime.TruffleInlining) DebugCloseable(org.graalvm.compiler.debug.DebugCloseable)

Example 7 with TruffleCompilationTask

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);
    }
}
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)

Aggregations

TruffleCompilationTask (org.graalvm.compiler.truffle.common.TruffleCompilationTask)7 CompilationIdentifier (org.graalvm.compiler.core.common.CompilationIdentifier)2 TruffleCompilerListener (org.graalvm.compiler.truffle.common.TruffleCompilerListener)2 TruffleInliningData (org.graalvm.compiler.truffle.common.TruffleInliningData)2 TruffleCompilerImpl (org.graalvm.compiler.truffle.compiler.TruffleCompilerImpl)2 OptimizedCallTarget (org.graalvm.compiler.truffle.runtime.OptimizedCallTarget)2 TruffleInlining (org.graalvm.compiler.truffle.runtime.TruffleInlining)2 CEntryPointOptions (com.oracle.svm.core.c.function.CEntryPointOptions)1 IsolatedCompileContext (com.oracle.svm.graal.isolated.IsolatedCompileContext)1 SubstrateTruffleCompiler (com.oracle.svm.truffle.api.SubstrateTruffleCompiler)1 TruffleSafepoint (com.oracle.truffle.api.TruffleSafepoint)1 VirtualFrame (com.oracle.truffle.api.frame.VirtualFrame)1 RootNode (com.oracle.truffle.api.nodes.RootNode)1 PrintWriter (java.io.PrintWriter)1 StringWriter (java.io.StringWriter)1 Callable (java.util.concurrent.Callable)1 JavaKind (jdk.vm.ci.meta.JavaKind)1 ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)1 ResolvedJavaType (jdk.vm.ci.meta.ResolvedJavaType)1 StampPair (org.graalvm.compiler.core.common.type.StampPair)1