use of org.graalvm.compiler.truffle.runtime.OptimizedDirectCallNode in project graal by oracle.
the class ExperimentalSplittingStrategyTest method testNoSplitsDirectCallsBecauseFirstExecution.
@Test
public void testNoSplitsDirectCallsBecauseFirstExecution() {
final OptimizedCallTarget callTarget = (OptimizedCallTarget) runtime.createCallTarget(new SplittableRootNode() {
@Child
private OptimizedDirectCallNode callNode = (OptimizedDirectCallNode) runtime.createDirectCallNode(runtime.createCallTarget(new SplittingTestRootNode(ExperimentalSplittingStrategyTestFactory.TurnsPolymorphicOnZeroNodeGen.create(new ReturnsArgumentNode()))));
@Override
public Object execute(VirtualFrame frame) {
final Object[] first = { 1 };
callNode.call(first);
callNode.call(first);
// This call turns the node polymorphic
final Object[] second = { 0 };
callNode.call(second);
return null;
}
});
// Multiple call nodes
runtime.createDirectCallNode(callTarget);
runtime.createDirectCallNode(callTarget);
final DirectCallNode directCallNode = runtime.createDirectCallNode(callTarget);
directCallNode.call(new Object[] { 0 });
Assert.assertFalse("Target needs split after first execution", getNeedsSplit(callTarget));
}
use of org.graalvm.compiler.truffle.runtime.OptimizedDirectCallNode 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 org.graalvm.compiler.truffle.runtime.OptimizedDirectCallNode 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);
}
Aggregations