use of org.graalvm.compiler.truffle.runtime.OptimizedCallTarget in project graal by oracle.
the class DFAPartialEvaluationTest method assertPartialEvalEqualsAndRunsCorrect.
private void assertPartialEvalEqualsAndRunsCorrect(RootNode program, String input) {
assertMatches(program, input);
final OptimizedCallTarget compilable = (OptimizedCallTarget) Truffle.getRuntime().createCallTarget(program);
partialEval(compilable, new Object[] { input }, StructuredGraph.AllowAssumptions.YES, INVALID_COMPILATION_ID);
// fail on Exceptions only for now
}
use of org.graalvm.compiler.truffle.runtime.OptimizedCallTarget in project graal by oracle.
the class ExperimentalSplittingStrategyTest method testSplitPropagatesThrongSoleCallers.
@Test
public void testSplitPropagatesThrongSoleCallers() {
OptimizedCallTarget turnsPolymorphic = (OptimizedCallTarget) runtime.createCallTarget(new SplittingTestRootNode(ExperimentalSplittingStrategyTestFactory.TurnsPolymorphicOnZeroNodeGen.create(new ReturnsArgumentNode())));
testPropagatesThroughSoleCallers(turnsPolymorphic, new Object[] { 1 }, new Object[] { 0 });
turnsPolymorphic = (OptimizedCallTarget) runtime.createCallTarget(new SplittingTestRootNode(ExperimentalSplittingStrategyTestFactory.HasInlineCacheNodeGen.create(new ReturnsArgumentNode())));
Object[] first = new Object[] { runtime.createCallTarget(new DummyRootNode()) };
Object[] second = new Object[] { runtime.createCallTarget(new DummyRootNode()) };
testPropagatesThroughSoleCallers(turnsPolymorphic, first, second);
}
use of org.graalvm.compiler.truffle.runtime.OptimizedCallTarget in project graal by oracle.
the class ExplodeLoopBlockDuplicationTest method testBlockDuplication.
/*
* Test that polymorphic caches duplicate the cached block and can therefore resolve the
* abstract method call and resolve the result to a constant.
*/
@Test
public void testBlockDuplication() {
OptimizedCallTarget target = (OptimizedCallTarget) Truffle.getRuntime().createCallTarget(new ObjectCacheTestRootNode());
AbstractType value1 = new ConcreteType1();
AbstractType value2 = new ConcreteType2();
target.call(value1);
target.call(value2);
target.compile();
assertCompiled(target);
target.call(value1);
target.call(value2);
assertCompiled(target);
}
use of org.graalvm.compiler.truffle.runtime.OptimizedCallTarget in project graal by oracle.
the class IndirectCallSiteTest method testIndirectCallNodeDoesNotDeopOnFirstCall.
@Test
public void testIndirectCallNodeDoesNotDeopOnFirstCall() {
final Object[] noArguments = new Object[0];
final OptimizedCallTarget innerTarget = (OptimizedCallTarget) runtime.createCallTarget(new RootNode(null) {
@Override
public Object execute(VirtualFrame frame) {
return null;
}
});
final OptimizedCallTarget uninitializedInnerTarget = (OptimizedCallTarget) runtime.createCallTarget(new RootNode(null) {
@Override
public Object execute(VirtualFrame frame) {
return null;
}
});
final OptimizedCallTarget outerTarget = (OptimizedCallTarget) runtime.createCallTarget(new RootNode(null) {
@Child
OptimizedIndirectCallNode indirectCallNode = (OptimizedIndirectCallNode) runtime.createIndirectCallNode();
@Override
public Object execute(VirtualFrame frame) {
if (frame.getArguments().length == 0) {
return indirectCallNode.call(innerTarget, noArguments);
} else {
return indirectCallNode.call(uninitializedInnerTarget, noArguments);
}
}
});
final int compilationThreshold = TruffleCompilerOptions.getValue(TruffleCompilationThreshold);
for (int i = 0; i < compilationThreshold; i++) {
outerTarget.call(noArguments);
}
assertCompiled(outerTarget);
outerTarget.call(new Object[] { null });
assertCompiled(outerTarget);
}
use of org.graalvm.compiler.truffle.runtime.OptimizedCallTarget in project graal by oracle.
the class InstrumentBranchesPhaseTest method simpleIfTest.
@Test
public void simpleIfTest() {
InstrumentPhase.Instrumentation instrumentation = truffleCompiler.getInstrumentation();
FrameDescriptor descriptor = new FrameDescriptor();
SimpleIfTestNode result = new SimpleIfTestNode(5);
RootTestNode rootNode = new RootTestNode(descriptor, "simpleIfRoot", result);
OptimizedCallTarget target = compileHelper("simpleIfRoot", rootNode, new Object[0]);
Assert.assertTrue(target.isValid());
target.call();
String stackOutput = instrumentation.accessTableToList(getOptions()).get(0);
Assert.assertTrue(stackOutput, stackOutput.contains("org.graalvm.compiler.truffle.test.InstrumentBranchesPhaseTest$SimpleIfTestNode.execute(InstrumentBranchesPhaseTest.java"));
Assert.assertTrue(stackOutput, stackOutput.contains("[bci: 4]\n[0] state = ELSE(if=0#, else=1#)"));
String histogramOutput = instrumentation.accessTableToHistogram().get(0);
Assert.assertEquals(" 0: ********************************************************************************", histogramOutput);
}
Aggregations