Search in sources :

Example 1 with TruffleInliningData

use of org.graalvm.compiler.truffle.common.TruffleInliningData in project graal by oracle.

the class IsolatedTruffleInlining method getPosition0.

@CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class)
@CEntryPointOptions(publishAs = CEntryPointOptions.Publish.NotPublished)
private static CompilerHandle<TruffleSourceLanguagePosition> getPosition0(@SuppressWarnings("unused") ClientIsolateThread client, ClientHandle<? extends TruffleInliningData> inliningHandle, ClientHandle<?> callNodeConstantHandle) {
    TruffleInliningData inlining = IsolatedCompileClient.get().unhand(inliningHandle);
    JavaConstant callNodeConstant = SubstrateObjectConstant.forObject(IsolatedCompileClient.get().unhand(callNodeConstantHandle));
    TruffleSourceLanguagePosition position = inlining.getPosition(callNodeConstant);
    if (position == null) {
        return IsolatedHandles.nullHandle();
    }
    return createPositionInCompiler(IsolatedCompileClient.get().getCompiler(), IsolatedCompileClient.get().hand(position), position.getLineNumber(), position.getOffsetStart(), position.getOffsetEnd(), position.getNodeId());
}
Also used : TruffleInliningData(org.graalvm.compiler.truffle.common.TruffleInliningData) JavaConstant(jdk.vm.ci.meta.JavaConstant) TruffleSourceLanguagePosition(org.graalvm.compiler.truffle.common.TruffleSourceLanguagePosition) CEntryPoint(org.graalvm.nativeimage.c.function.CEntryPoint) CEntryPointOptions(com.oracle.svm.core.c.function.CEntryPointOptions)

Example 2 with TruffleInliningData

use of org.graalvm.compiler.truffle.common.TruffleInliningData in project graal by oracle.

the class IsolatedTruffleInlining method addInlinedTarget0.

@CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class)
@CEntryPointOptions(publishAs = CEntryPointOptions.Publish.NotPublished)
private static void addInlinedTarget0(@SuppressWarnings("unused") ClientIsolateThread client, ClientHandle<? extends TruffleInliningData> providerHandle, ClientHandle<SubstrateCompilableTruffleAST> targetHandle) {
    final IsolatedCompileClient isolatedCompileClient = IsolatedCompileClient.get();
    TruffleInliningData truffleInliningData = isolatedCompileClient.unhand(providerHandle);
    truffleInliningData.addInlinedTarget(isolatedCompileClient.unhand(targetHandle));
}
Also used : IsolatedCompileClient(com.oracle.svm.graal.isolated.IsolatedCompileClient) TruffleInliningData(org.graalvm.compiler.truffle.common.TruffleInliningData) CEntryPoint(org.graalvm.nativeimage.c.function.CEntryPoint) CEntryPointOptions(com.oracle.svm.core.c.function.CEntryPointOptions)

Example 3 with TruffleInliningData

use of org.graalvm.compiler.truffle.common.TruffleInliningData in project graal by oracle.

the class IsolatedTruffleInlining method addTargetToDequeue0.

@CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class)
@CEntryPointOptions(publishAs = CEntryPointOptions.Publish.NotPublished)
private static void addTargetToDequeue0(@SuppressWarnings("unused") ClientIsolateThread client, ClientHandle<? extends TruffleInliningData> providerHandle, ClientHandle<SubstrateCompilableTruffleAST> targetHandle) {
    final IsolatedCompileClient isolatedCompileClient = IsolatedCompileClient.get();
    TruffleInliningData truffleInliningData = isolatedCompileClient.unhand(providerHandle);
    truffleInliningData.addTargetToDequeue(isolatedCompileClient.unhand(targetHandle));
}
Also used : IsolatedCompileClient(com.oracle.svm.graal.isolated.IsolatedCompileClient) TruffleInliningData(org.graalvm.compiler.truffle.common.TruffleInliningData) CEntryPoint(org.graalvm.nativeimage.c.function.CEntryPoint) CEntryPointOptions(com.oracle.svm.core.c.function.CEntryPointOptions)

Example 4 with TruffleInliningData

use of org.graalvm.compiler.truffle.common.TruffleInliningData in project graal by oracle.

the class AgnosticInliningPhaseTest method runLanguageAgnosticInliningPhase.

protected StructuredGraph runLanguageAgnosticInliningPhase(OptimizedCallTarget callTarget) {
    final PartialEvaluator partialEvaluator = getTruffleCompiler(callTarget).getPartialEvaluator();
    final CompilationIdentifier compilationIdentifier = new CompilationIdentifier() {

        @Override
        public String toString(Verbosity verbosity) {
            return "";
        }
    };
    final PartialEvaluator.Request request = partialEvaluator.new Request(callTarget.getOptionValues(), getDebugContext(), callTarget, partialEvaluator.rootForCallTarget(callTarget), compilationIdentifier, getSpeculationLog(), 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;
        }
    }));
    final AgnosticInliningPhase agnosticInliningPhase = new AgnosticInliningPhase(partialEvaluator, request);
    agnosticInliningPhase.apply(request.graph, getTruffleCompiler(callTarget).getPartialEvaluator().getProviders());
    return request.graph;
}
Also used : PartialEvaluator(org.graalvm.compiler.truffle.compiler.PartialEvaluator) CompilationIdentifier(org.graalvm.compiler.core.common.CompilationIdentifier) TruffleCompilerImpl(org.graalvm.compiler.truffle.compiler.TruffleCompilerImpl) TruffleInlining(org.graalvm.compiler.truffle.runtime.TruffleInlining) TruffleInliningData(org.graalvm.compiler.truffle.common.TruffleInliningData) TruffleCompilationTask(org.graalvm.compiler.truffle.common.TruffleCompilationTask) AgnosticInliningPhase(org.graalvm.compiler.truffle.compiler.phases.inlining.AgnosticInliningPhase)

Example 5 with TruffleInliningData

use of org.graalvm.compiler.truffle.common.TruffleInliningData 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)

Aggregations

TruffleInliningData (org.graalvm.compiler.truffle.common.TruffleInliningData)8 CEntryPointOptions (com.oracle.svm.core.c.function.CEntryPointOptions)6 CEntryPoint (org.graalvm.nativeimage.c.function.CEntryPoint)6 IsolatedCompileClient (com.oracle.svm.graal.isolated.IsolatedCompileClient)2 JavaConstant (jdk.vm.ci.meta.JavaConstant)2 CompilationIdentifier (org.graalvm.compiler.core.common.CompilationIdentifier)2 TruffleCompilationTask (org.graalvm.compiler.truffle.common.TruffleCompilationTask)2 TruffleCompilerImpl (org.graalvm.compiler.truffle.compiler.TruffleCompilerImpl)2 TruffleInlining (org.graalvm.compiler.truffle.runtime.TruffleInlining)2 DebugCloseable (org.graalvm.compiler.debug.DebugCloseable)1 DebugContext (org.graalvm.compiler.debug.DebugContext)1 Builder (org.graalvm.compiler.debug.DebugContext.Builder)1 TruffleCallNode (org.graalvm.compiler.truffle.common.TruffleCallNode)1 TruffleSourceLanguagePosition (org.graalvm.compiler.truffle.common.TruffleSourceLanguagePosition)1 PartialEvaluator (org.graalvm.compiler.truffle.compiler.PartialEvaluator)1 AgnosticInliningPhase (org.graalvm.compiler.truffle.compiler.phases.inlining.AgnosticInliningPhase)1 OptimizedCallTarget (org.graalvm.compiler.truffle.runtime.OptimizedCallTarget)1