Search in sources :

Example 11 with DirectCallNode

use of com.oracle.truffle.api.nodes.DirectCallNode in project graal by oracle.

the class NFILanguage method parse.

@Override
protected CallTarget parse(ParsingRequest request) throws Exception {
    CharSequence nfiSource = request.getSource().getCharacters();
    NativeSource source = Parser.parseNFISource(nfiSource);
    String backendId;
    if (source.isDefaultBackend()) {
        backendId = "native";
    } else {
        backendId = source.getNFIBackendId();
    }
    Source backendSource = Source.newBuilder(source.getLibraryDescriptor()).mimeType("trufflenfi/" + backendId).name("<nfi-impl>").build();
    CallTarget backendTarget = getContextReference().get().env.parse(backendSource);
    DirectCallNode loadLibrary = DirectCallNode.create(backendTarget);
    return Truffle.getRuntime().createCallTarget(new NFIRootNode(this, loadLibrary, source));
}
Also used : NativeSource(com.oracle.truffle.nfi.types.NativeSource) CallTarget(com.oracle.truffle.api.CallTarget) DirectCallNode(com.oracle.truffle.api.nodes.DirectCallNode) Source(com.oracle.truffle.api.source.Source) NativeSource(com.oracle.truffle.nfi.types.NativeSource)

Example 12 with DirectCallNode

use of com.oracle.truffle.api.nodes.DirectCallNode in project graal by oracle.

the class TruffleTreeDumpHandler method dumpInlinedTrees.

private static void dumpInlinedTrees(GraphOutput<AST, ?> output, final RootCallTarget callTarget, TruffleInlining inlining, List<RootCallTarget> dumped) throws IOException {
    for (DirectCallNode callNode : NodeUtil.findAllNodeInstances(callTarget.getRootNode(), DirectCallNode.class)) {
        CallTarget inlinedCallTarget = callNode.getCurrentCallTarget();
        if (inlinedCallTarget instanceof RootCallTarget && callNode instanceof OptimizedDirectCallNode) {
            TruffleInliningDecision decision = inlining.findByCall((OptimizedDirectCallNode) callNode);
            if (decision != null && decision.shouldInline()) {
                final RootCallTarget rootCallTarget = (RootCallTarget) inlinedCallTarget;
                if (!dumped.contains(rootCallTarget)) {
                    AST ast = new AST(rootCallTarget);
                    output.beginGroup(ast, inlinedCallTarget.toString(), rootCallTarget.getRootNode().getName(), null, 0, DebugContext.addVersionProperties(null));
                    output.print(ast, Collections.emptyMap(), 0, AFTER_PROFILING);
                    output.endGroup();
                    dumped.add(rootCallTarget);
                    dumpInlinedTrees(output, (OptimizedCallTarget) inlinedCallTarget, decision, dumped);
                }
            }
        }
    }
}
Also used : RootCallTarget(com.oracle.truffle.api.RootCallTarget) CallTarget(com.oracle.truffle.api.CallTarget) DirectCallNode(com.oracle.truffle.api.nodes.DirectCallNode) RootCallTarget(com.oracle.truffle.api.RootCallTarget)

Example 13 with DirectCallNode

use of com.oracle.truffle.api.nodes.DirectCallNode in project graal by oracle.

the class TruffleInlining method getPosition.

@Override
public SourceLanguagePosition getPosition(JavaConstant node) {
    SnippetReflectionProvider snippetReflection = runtime().getGraalRuntime().getRequiredCapability(SnippetReflectionProvider.class);
    Node truffleNode = snippetReflection.asObject(Node.class, node);
    if (truffleNode == null) {
        return null;
    }
    SourceSection section = null;
    if (truffleNode instanceof DirectCallNode) {
        section = ((DirectCallNode) truffleNode).getCurrentRootNode().getSourceSection();
    }
    if (section == null) {
        section = truffleNode.getSourceSection();
    }
    if (section == null) {
        Node cur = truffleNode.getParent();
        while (cur != null) {
            section = cur.getSourceSection();
            if (section != null) {
                break;
            }
            cur = cur.getParent();
        }
    }
    if (section != null) {
        return new TruffleSourceLanguagePosition(section);
    }
    return null;
}
Also used : SnippetReflectionProvider(org.graalvm.compiler.api.replacements.SnippetReflectionProvider) DirectCallNode(com.oracle.truffle.api.nodes.DirectCallNode) Node(com.oracle.truffle.api.nodes.Node) SourceSection(com.oracle.truffle.api.source.SourceSection) DirectCallNode(com.oracle.truffle.api.nodes.DirectCallNode)

Example 14 with DirectCallNode

use of com.oracle.truffle.api.nodes.DirectCallNode in project sulong by graalvm.

the class LLVMDispatchNode method getIntrinsificationCallNode.

/*
     * Function is not defined in the user program (not available as LLVM IR). This would normally
     * result in a native call BUT there is an intrinsification available
     */
protected DirectCallNode getIntrinsificationCallNode(Intrinsic intrinsic) {
    RootCallTarget target = intrinsic.forceSplit() ? intrinsic.generateCallTarget(type) : intrinsic.cachedCallTarget(type);
    DirectCallNode directCallNode = DirectCallNode.create(target);
    if (intrinsic.forceInline()) {
        directCallNode.forceInlining();
    }
    return directCallNode;
}
Also used : RootCallTarget(com.oracle.truffle.api.RootCallTarget) DirectCallNode(com.oracle.truffle.api.nodes.DirectCallNode)

Aggregations

DirectCallNode (com.oracle.truffle.api.nodes.DirectCallNode)14 OptimizedDirectCallNode (org.graalvm.compiler.truffle.runtime.OptimizedDirectCallNode)6 OptimizedCallTarget (org.graalvm.compiler.truffle.runtime.OptimizedCallTarget)5 Test (org.junit.Test)5 RootCallTarget (com.oracle.truffle.api.RootCallTarget)4 VirtualFrame (com.oracle.truffle.api.frame.VirtualFrame)4 RootNode (com.oracle.truffle.api.nodes.RootNode)4 CallTarget (com.oracle.truffle.api.CallTarget)3 Node (com.oracle.truffle.api.nodes.Node)3 TruffleBoundary (com.oracle.truffle.api.CompilerDirectives.TruffleBoundary)1 NodeCost (com.oracle.truffle.api.nodes.NodeCost)1 NodeVisitor (com.oracle.truffle.api.nodes.NodeVisitor)1 Source (com.oracle.truffle.api.source.Source)1 SourceSection (com.oracle.truffle.api.source.SourceSection)1 NativeSource (com.oracle.truffle.nfi.types.NativeSource)1 SLBuiltinNode (com.oracle.truffle.sl.builtins.SLBuiltinNode)1 HashSet (java.util.HashSet)1 SnippetReflectionProvider (org.graalvm.compiler.api.replacements.SnippetReflectionProvider)1 TruffleCompilerOptions (org.graalvm.compiler.truffle.common.TruffleCompilerOptions)1 Ignore (org.junit.Ignore)1