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