use of com.oracle.truffle.api.nodes.Node in project graal by oracle.
the class TraceCallTreeListener method logTruffleCallTree.
private void logTruffleCallTree(OptimizedCallTarget compilable, TruffleInlining inliningDecision) {
CallTreeNodeVisitor visitor = new CallTreeNodeVisitor() {
@Override
public boolean visit(List<TruffleInlining> decisionStack, Node node) {
if (node instanceof OptimizedDirectCallNode) {
OptimizedDirectCallNode callNode = ((OptimizedDirectCallNode) node);
int depth = decisionStack == null ? 0 : decisionStack.size() - 1;
TruffleInliningDecision inlining = CallTreeNodeVisitor.getCurrentInliningDecision(decisionStack);
String dispatched = "<dispatched>";
if (inlining != null && inlining.shouldInline()) {
dispatched = "";
}
Map<String, Object> properties = new LinkedHashMap<>();
GraalTruffleRuntimeListener.addASTSizeProperty(callNode.getCurrentCallTarget(), inliningDecision, properties);
properties.putAll(callNode.getCurrentCallTarget().getDebugProperties(inliningDecision));
runtime.logEvent(depth, "opt call tree", callNode.getCurrentCallTarget().toString() + dispatched, properties);
} else if (node instanceof OptimizedIndirectCallNode) {
int depth = decisionStack == null ? 0 : decisionStack.size() - 1;
runtime.logEvent(depth, "opt call tree", "<indirect>", new LinkedHashMap<>());
}
return true;
}
};
compilable.accept(visitor, inliningDecision);
}
use of com.oracle.truffle.api.nodes.Node in project graal by oracle.
the class TraceCompilationListener method onCompilationSuccess.
@Override
public void onCompilationSuccess(OptimizedCallTarget target, TruffleInlining inliningDecision, GraphInfo graph, CompilationResultInfo result) {
long timeCompilationFinished = System.nanoTime();
int nodeCountLowered = graph.getNodeCount();
Times compilation = currentCompilation.get();
int calls = 0;
int inlinedCalls;
if (inliningDecision == null) {
for (Node node : target.nodeIterable(null)) {
if (node instanceof OptimizedDirectCallNode) {
calls++;
}
}
inlinedCalls = 0;
} else {
calls = inliningDecision.countCalls();
inlinedCalls = inliningDecision.countInlinedCalls();
}
int dispatchedCalls = calls - inlinedCalls;
Map<String, Object> properties = new LinkedHashMap<>();
GraalTruffleRuntimeListener.addASTSizeProperty(target, inliningDecision, properties);
properties.put("Time", //
String.format(//
"%5.0f(%4.0f+%-4.0f)ms", //
(timeCompilationFinished - compilation.timeCompilationStarted) / 1e6, //
(compilation.timePartialEvaluationFinished - compilation.timeCompilationStarted) / 1e6, (timeCompilationFinished - compilation.timePartialEvaluationFinished) / 1e6));
properties.put("DirectCallNodes", String.format("I %4d/D %4d", inlinedCalls, dispatchedCalls));
properties.put("GraalNodes", String.format("%5d/%5d", compilation.nodeCountPartialEval, nodeCountLowered));
properties.put("CodeSize", result.getTargetCodeSize());
properties.put("CodeAddress", "0x" + Long.toHexString(target.getCodeAddress()));
properties.put("Source", formatSourceSection(target.getRootNode().getSourceSection()));
runtime.logEvent(0, "opt done", target.toString(), properties);
currentCompilation.set(null);
}
use of com.oracle.truffle.api.nodes.Node in project graal by oracle.
the class TraceCompilationPolymorphismListener method onCompilationSuccess.
@Override
public void onCompilationSuccess(OptimizedCallTarget target, TruffleInlining inliningDecision, GraphInfo graph, CompilationResultInfo result) {
for (Node node : target.nodeIterable(inliningDecision)) {
if (node != null && (node.getCost() == NodeCost.MEGAMORPHIC || node.getCost() == NodeCost.POLYMORPHIC)) {
NodeCost cost = node.getCost();
Map<String, Object> props = new LinkedHashMap<>();
props.put("simpleName", node.getClass().getSimpleName());
props.put("subtree", "\n" + NodeUtil.printCompactTreeToString(node));
String msg = cost == NodeCost.MEGAMORPHIC ? "megamorphic" : "polymorphic";
runtime.logEvent(0, msg, node.toString(), props);
}
}
}
use of com.oracle.truffle.api.nodes.Node in project graal by oracle.
the class TruffleTreeDumpHandler method findNamedNodeChildren.
@SuppressWarnings("deprecation")
private static LinkedHashMap<String, Node> findNamedNodeChildren(Node node) {
LinkedHashMap<String, Node> nodes = new LinkedHashMap<>();
NodeClass nodeClass = NodeClass.get(node);
for (com.oracle.truffle.api.nodes.NodeFieldAccessor field : findNodeFields(nodeClass)) {
if (isChildField(nodeClass, field)) {
Object value = findFieldObject(nodeClass, field, node);
if (value != null) {
nodes.put(findFieldName(nodeClass, field), (Node) value);
}
} else if (isChildrenField(nodeClass, field)) {
Object value = findFieldObject(nodeClass, field, node);
if (value != null) {
Object[] children = (Object[]) value;
for (int i = 0; i < children.length; i++) {
if (children[i] != null) {
nodes.put(findFieldName(nodeClass, field) + "[" + i + "]", (Node) children[i]);
}
}
}
}
}
return nodes;
}
use of com.oracle.truffle.api.nodes.Node in project graal by oracle.
the class OptimizedOSRLoopNode method compileImpl.
private OptimizedCallTarget compileImpl(VirtualFrame frame) {
RootNode root = getRootNode();
Node parent = getParent();
if (speculationLog == null) {
speculationLog = GraalTruffleRuntime.getRuntime().createSpeculationLog();
}
OptimizedCallTarget osrTarget = (OptimizedCallTarget) GraalTruffleRuntime.getRuntime().createCallTarget(createRootNodeImpl(root, frame.getClass()));
osrTarget.setSpeculationLog(speculationLog);
// let the old parent re-adopt the children
parent.adoptChildren();
osrTarget.compile();
return osrTarget;
}
Aggregations