use of com.oracle.truffle.api.RootCallTarget in project graal by oracle.
the class ExperimentalSplittingStrategyTest method testDoesNotSplitDirectCallHelper.
private void testDoesNotSplitDirectCallHelper(OptimizedCallTarget callTarget, Object[] firstArgs, Object[] secondArgs) {
final RootCallTarget outer = runtime.createCallTarget(new CallsInnerNode(callTarget));
outer.call(firstArgs);
Assert.assertFalse("Target needs split before the node went polymorphic", getNeedsSplit(callTarget));
outer.call(firstArgs);
Assert.assertFalse("Target needs split before the node went polymorphic", getNeedsSplit(callTarget));
outer.call(secondArgs);
Assert.assertFalse("Target needs split even though it has only one caller", getNeedsSplit(callTarget));
// Test new dirrectCallNode will NOT split
final DirectCallNode newCallNode = runtime.createDirectCallNode(callTarget);
newCallNode.call(secondArgs);
Assert.assertFalse("new call node to \"needs split\" target is not split", newCallNode.isCallTargetCloned());
}
use of com.oracle.truffle.api.RootCallTarget in project graal by oracle.
the class ExperimentalSplittingStrategyTest method testIncreaseInPolymorphism.
@Test
public void testIncreaseInPolymorphism() {
OptimizedCallTarget callTarget = (OptimizedCallTarget) runtime.createCallTarget(new SplittingTestRootNode(ExperimentalSplittingStrategyTestFactory.TurnsPolymorphicOnZeroNodeGen.create(new ReturnsArgumentNode())));
final RootCallTarget outerTarget = runtime.createCallTarget(new CallsInnerNode(callTarget));
Object[] firstArgs = new Object[] { 1 };
outerTarget.call(firstArgs);
Assert.assertFalse("Target needs split before the node went polymorphic", getNeedsSplit(callTarget));
outerTarget.call(firstArgs);
Assert.assertFalse("Target needs split before the node went polymorphic", getNeedsSplit(callTarget));
Object[] secondArgs = new Object[] { 0 };
// Turns polymorphic
outerTarget.call(secondArgs);
Assert.assertFalse("Target needs split even though there is only 1 caller", getNeedsSplit(callTarget));
// Add second caller
final DirectCallNode directCallNode = runtime.createDirectCallNode(callTarget);
outerTarget.call(secondArgs);
Assert.assertFalse("Target needs split with no increase in polymorphism", getNeedsSplit(callTarget));
outerTarget.call(new Object[] { "foo" });
Assert.assertTrue("Target does not need split after increase in polymorphism", getNeedsSplit(callTarget));
// Test new dirrectCallNode will split
outerTarget.call(firstArgs);
directCallNode.call(firstArgs);
Assert.assertTrue("new call node to \"needs split\" target is not split", directCallNode.isCallTargetCloned());
}
use of com.oracle.truffle.api.RootCallTarget in project graal by oracle.
the class ExperimentalSplittingStrategyTest method testSoloTarget.
@Test
public void testSoloTarget() {
final ExposesReportPolymorphicSpecializeRootNode rootNode = new ExposesReportPolymorphicSpecializeRootNode();
final RootCallTarget callTarget = runtime.createCallTarget(rootNode);
callTarget.call(noArguments);
rootNode.report();
}
use of com.oracle.truffle.api.RootCallTarget in project graal by oracle.
the class CastExactPartialEvaluationTest method testCommon.
private void testCommon(AbstractTestNode testNode, String testName) {
FrameDescriptor fd = new FrameDescriptor();
RootNode rootNode = new RootTestNode(fd, testName, testNode);
RootCallTarget callTarget = Truffle.getRuntime().createCallTarget(rootNode);
Assert.assertEquals(42, callTarget.call(newBuffer()));
assertPartialEvalNoInvokes(callTarget, new Object[] { newBuffer() });
}
use of com.oracle.truffle.api.RootCallTarget in project graal by oracle.
the class TruffleTreeDumpHandler method dumpASTAndCallTrees.
private static void dumpASTAndCallTrees(DebugContext debug, TruffleTreeDump truffleTreeDump) throws IOException {
final RootCallTarget callTarget = truffleTreeDump.callTarget;
if (callTarget.getRootNode() != null && callTarget instanceof OptimizedCallTarget) {
AST ast = new AST(callTarget);
final GraphOutput<AST, ?> astOutput = debug.buildOutput(GraphOutput.newBuilder(AST_DUMP_STRUCTURE).blocks(AST_DUMP_STRUCTURE));
astOutput.beginGroup(ast, "AST", "AST", null, 0, DebugContext.addVersionProperties(null));
astOutput.print(ast, Collections.emptyMap(), 0, AFTER_PROFILING);
final TruffleInlining inlining = truffleTreeDump.inlining;
if (inlining.countInlinedCalls() > 0) {
dumpInlinedTrees(astOutput, callTarget, inlining, new ArrayList<>());
ast.inline(truffleTreeDump.inlining);
astOutput.print(ast, null, 1, AFTER_INLINING);
}
// AST
astOutput.endGroup();
astOutput.close();
CallTree callTree = new CallTree(truffleTreeDump.callTarget, null);
final GraphOutput<CallTree, ?> callTreeOutput = debug.buildOutput(GraphOutput.newBuilder(CALL_GRAPH_DUMP_STRUCTURE).blocks(CALL_GRAPH_DUMP_STRUCTURE));
callTreeOutput.beginGroup(null, "Call Tree", "Call Tree", null, 0, DebugContext.addVersionProperties(null));
callTreeOutput.print(callTree, null, 0, AFTER_PROFILING);
if (inlining.countInlinedCalls() > 0) {
callTree = new CallTree(truffleTreeDump.callTarget, truffleTreeDump.inlining);
callTreeOutput.print(callTree, null, 0, AFTER_INLINING);
}
// Call Tree
callTreeOutput.endGroup();
callTreeOutput.close();
}
}
Aggregations