Search in sources :

Example 1 with TruffleCallNode

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

the class OptimizedCallTarget method getCallNodes.

@Override
public final TruffleCallNode[] getCallNodes() {
    final List<OptimizedDirectCallNode> callNodes = new ArrayList<>();
    getRootNode().accept(new NodeVisitor() {

        @Override
        public boolean visit(Node node) {
            if (node instanceof OptimizedDirectCallNode) {
                callNodes.add((OptimizedDirectCallNode) node);
            }
            return true;
        }
    });
    return callNodes.toArray(new TruffleCallNode[0]);
}
Also used : BlockNode(com.oracle.truffle.api.nodes.BlockNode) TruffleCallNode(org.graalvm.compiler.truffle.common.TruffleCallNode) RootNode(com.oracle.truffle.api.nodes.RootNode) Node(com.oracle.truffle.api.nodes.Node) ArrayList(java.util.ArrayList) NodeVisitor(com.oracle.truffle.api.nodes.NodeVisitor)

Example 2 with TruffleCallNode

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

the class PEAgnosticInlineInvokePlugin method notifyNotInlined.

@Override
public void notifyNotInlined(GraphBuilderContext b, ResolvedJavaMethod original, Invoke invoke) {
    if (original.equals(partialEvaluator.callDirectMethod)) {
        TruffleCallNode truffleCallNode = truffleInliningData.findCallNode(lastDirectCallNode);
        invokeToTruffleCallNode.put(invoke, truffleCallNode);
        lastDirectCallNode = null;
    } else if (lastDirectCallNode == null && indirectCall) {
        indirectCall = false;
        indirectInvokes.add(invoke);
    }
}
Also used : TruffleCallNode(org.graalvm.compiler.truffle.common.TruffleCallNode)

Example 3 with TruffleCallNode

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

the class CallNode method makeRoot.

/**
 * Returns a fully expanded and partially evaluated CallNode to be used as a root of a callTree.
 */
static CallNode makeRoot(CallTree callTree, PartialEvaluator.Request request) {
    Objects.requireNonNull(callTree);
    Objects.requireNonNull(request);
    CallNode root = new CallNode(null, request.compilable, 1, 0, callTree.nextId());
    callTree.add(root);
    root.ir = request.graph;
    root.policyData = callTree.getPolicy().newCallNodeData(root);
    final GraphManager.Entry entry = callTree.getGraphManager().peRoot();
    root.irAfterPE = entry.graphAfterPEForDebugDump;
    EconomicMap<Invoke, TruffleCallNode> invokeToTruffleCallNode = entry.invokeToTruffleCallNode;
    root.verifyTrivial(entry);
    addChildren(root, invokeToTruffleCallNode);
    root.state = State.Inlined;
    callTree.getPolicy().afterExpand(root);
    callTree.frontierSize = root.children.size();
    return root;
}
Also used : TruffleCallNode(org.graalvm.compiler.truffle.common.TruffleCallNode) TruffleCallNode(org.graalvm.compiler.truffle.common.TruffleCallNode) Invoke(org.graalvm.compiler.nodes.Invoke)

Example 4 with TruffleCallNode

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

the class HSCompilableTruffleAST method getCallNodes.

@TruffleFromLibGraal(GetCallNodes)
@Override
public TruffleCallNode[] getCallNodes() {
    JNIMethodScope scope = scope();
    JNIEnv env = scope.getEnv();
    JObjectArray peerArr = callGetCallNodes(env, getHandle());
    int len = JNIUtil.GetArrayLength(env, peerArr);
    TruffleCallNode[] res = new TruffleCallNode[len];
    for (int i = 0; i < len; i++) {
        JObject peerTruffleCallNode = JNIUtil.GetObjectArrayElement(env, peerArr, i);
        res[i] = new HSTruffleCallNode(scope, peerTruffleCallNode);
    }
    return res;
}
Also used : TruffleCallNode(org.graalvm.compiler.truffle.common.TruffleCallNode) JNIMethodScope(org.graalvm.jniutils.JNIMethodScope) JObjectArray(org.graalvm.jniutils.JNI.JObjectArray) JObject(org.graalvm.jniutils.JNI.JObject) JNIEnv(org.graalvm.jniutils.JNI.JNIEnv) TruffleFromLibGraal(org.graalvm.compiler.truffle.common.hotspot.libgraal.TruffleFromLibGraal)

Example 5 with TruffleCallNode

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

the class CallNode method addChildren.

private static void addChildren(CallNode node, EconomicMap<Invoke, TruffleCallNode> invokeToTruffleCallNode) {
    for (Invoke invoke : invokeToTruffleCallNode.getKeys()) {
        if (!invoke.isAlive()) {
            continue;
        }
        final TruffleCallNode childCallNode = invokeToTruffleCallNode.get(invoke);
        double relativeFrequency = calculateFrequency(node.directCallTarget, childCallNode);
        double childFrequency = relativeFrequency * node.rootRelativeFrequency;
        CallNode callNode = new CallNode(childCallNode, childCallNode.getCurrentCallTarget(), childFrequency, node.depth + 1, node.getCallTree().nextId());
        node.getCallTree().add(callNode);
        node.children.add(callNode);
        callNode.policyData = node.getPolicy().newCallNodeData(callNode);
        callNode.setInvokeOrRemove(invoke);
    }
    node.getPolicy().afterAddChildren(node);
}
Also used : TruffleCallNode(org.graalvm.compiler.truffle.common.TruffleCallNode) TruffleCallNode(org.graalvm.compiler.truffle.common.TruffleCallNode) Invoke(org.graalvm.compiler.nodes.Invoke)

Aggregations

TruffleCallNode (org.graalvm.compiler.truffle.common.TruffleCallNode)10 CEntryPointOptions (com.oracle.svm.core.c.function.CEntryPointOptions)4 CEntryPoint (org.graalvm.nativeimage.c.function.CEntryPoint)4 Invoke (org.graalvm.compiler.nodes.Invoke)3 SubstrateCompilableTruffleAST (com.oracle.svm.truffle.api.SubstrateCompilableTruffleAST)2 ClientHandle (com.oracle.svm.graal.isolated.ClientHandle)1 BlockNode (com.oracle.truffle.api.nodes.BlockNode)1 Node (com.oracle.truffle.api.nodes.Node)1 NodeVisitor (com.oracle.truffle.api.nodes.NodeVisitor)1 RootNode (com.oracle.truffle.api.nodes.RootNode)1 ArrayList (java.util.ArrayList)1 Consumer (java.util.function.Consumer)1 JavaConstant (jdk.vm.ci.meta.JavaConstant)1 UnmodifiableEconomicMap (org.graalvm.collections.UnmodifiableEconomicMap)1 Node (org.graalvm.compiler.graph.Node)1 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)1 CompilableTruffleAST (org.graalvm.compiler.truffle.common.CompilableTruffleAST)1 TruffleInliningData (org.graalvm.compiler.truffle.common.TruffleInliningData)1 TruffleFromLibGraal (org.graalvm.compiler.truffle.common.hotspot.libgraal.TruffleFromLibGraal)1 JNIEnv (org.graalvm.jniutils.JNI.JNIEnv)1