Search in sources :

Example 41 with OptimizedCallTarget

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
}
Also used : OptimizedCallTarget(org.graalvm.compiler.truffle.runtime.OptimizedCallTarget)

Example 42 with OptimizedCallTarget

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);
}
Also used : OptimizedCallTarget(org.graalvm.compiler.truffle.runtime.OptimizedCallTarget) Test(org.junit.Test)

Example 43 with OptimizedCallTarget

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);
}
Also used : OptimizedCallTarget(org.graalvm.compiler.truffle.runtime.OptimizedCallTarget) Test(org.junit.Test)

Example 44 with OptimizedCallTarget

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);
}
Also used : VirtualFrame(com.oracle.truffle.api.frame.VirtualFrame) RootNode(com.oracle.truffle.api.nodes.RootNode) OptimizedIndirectCallNode(org.graalvm.compiler.truffle.runtime.OptimizedIndirectCallNode) OptimizedCallTarget(org.graalvm.compiler.truffle.runtime.OptimizedCallTarget) Test(org.junit.Test)

Example 45 with OptimizedCallTarget

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);
}
Also used : FrameDescriptor(com.oracle.truffle.api.frame.FrameDescriptor) InstrumentPhase(org.graalvm.compiler.truffle.compiler.phases.InstrumentPhase) OptimizedCallTarget(org.graalvm.compiler.truffle.runtime.OptimizedCallTarget) RootTestNode(org.graalvm.compiler.truffle.test.nodes.RootTestNode) Test(org.junit.Test)

Aggregations

OptimizedCallTarget (org.graalvm.compiler.truffle.runtime.OptimizedCallTarget)57 Test (org.junit.Test)42 RootNode (com.oracle.truffle.api.nodes.RootNode)18 FrameDescriptor (com.oracle.truffle.api.frame.FrameDescriptor)14 RootTestNode (org.graalvm.compiler.truffle.test.nodes.RootTestNode)14 VirtualFrame (com.oracle.truffle.api.frame.VirtualFrame)13 AbstractTestNode (org.graalvm.compiler.truffle.test.nodes.AbstractTestNode)11 TruffleOptionsOverrideScope (org.graalvm.compiler.truffle.common.TruffleCompilerOptions.TruffleOptionsOverrideScope)8 DirectCallNode (com.oracle.truffle.api.nodes.DirectCallNode)6 TruffleCompilerOptions (org.graalvm.compiler.truffle.common.TruffleCompilerOptions)6 Specialization (com.oracle.truffle.api.dsl.Specialization)4 CompilationIdentifier (org.graalvm.compiler.core.common.CompilationIdentifier)4 GraalTruffleRuntime (org.graalvm.compiler.truffle.runtime.GraalTruffleRuntime)4 OptimizedDirectCallNode (org.graalvm.compiler.truffle.runtime.OptimizedDirectCallNode)4 Theory (org.junit.experimental.theories.Theory)4 Assumption (com.oracle.truffle.api.Assumption)3 LoopNode (com.oracle.truffle.api.nodes.LoopNode)3 Ignore (org.junit.Ignore)3 Node (com.oracle.truffle.api.nodes.Node)2 WeakReference (java.lang.ref.WeakReference)2