Search in sources :

Example 1 with CallTarget

use of com.oracle.truffle.api.CallTarget in project graal by oracle.

the class OptimizedOSRLoopNodeTest method doBefore.

@BeforeClass
public static void doBefore() {
    // ensure that all classes are properly loaded
    TestRootNode rootNode = new TestRootNode(DEFAULT, new TestRepeatingNode());
    CallTarget target = runtime.createCallTarget(rootNode);
    target.call(1);
    rootNode = new TestRootNode(CONFIGURED, new TestRepeatingNode());
    target = runtime.createCallTarget(rootNode);
    target.call(1);
}
Also used : RootCallTarget(com.oracle.truffle.api.RootCallTarget) OptimizedCallTarget(org.graalvm.compiler.truffle.runtime.OptimizedCallTarget) CallTarget(com.oracle.truffle.api.CallTarget) BeforeClass(org.junit.BeforeClass)

Example 2 with CallTarget

use of com.oracle.truffle.api.CallTarget in project graal by oracle.

the class ControlFlowExceptionPartialEvaluationTest method catchControlFlowExceptionFromCall.

@Test
public void catchControlFlowExceptionFromCall() {
    Assume.assumeTrue(TruffleCompilerOptions.getValue(TruffleFunctionInlining));
    CallTarget callTarget = Truffle.getRuntime().createCallTarget(new RootTestNode(new FrameDescriptor(), "throwControlFlowException", new ThrowControlFlowExceptionTestNode()));
    AbstractTestNode result = new CatchControlFlowExceptionTestNode(new CallTestNode(callTarget));
    assertPartialEvalEquals("constant42", new RootTestNode(new FrameDescriptor(), "catchControlFlowExceptionFromCall", result));
}
Also used : FrameDescriptor(com.oracle.truffle.api.frame.FrameDescriptor) AbstractTestNode(org.graalvm.compiler.truffle.test.nodes.AbstractTestNode) CallTarget(com.oracle.truffle.api.CallTarget) RootTestNode(org.graalvm.compiler.truffle.test.nodes.RootTestNode) Test(org.junit.Test)

Example 3 with CallTarget

use of com.oracle.truffle.api.CallTarget in project graal by oracle.

the class GraalTVMCI method onLoopCount.

@Override
public void onLoopCount(Node source, int count) {
    Node node = source;
    Node parentNode = source != null ? source.getParent() : null;
    while (node != null) {
        if (node instanceof OptimizedOSRLoopNode) {
            ((OptimizedOSRLoopNode) node).reportChildLoopCount(count);
        }
        parentNode = node;
        node = node.getParent();
    }
    if (parentNode != null && parentNode instanceof RootNode) {
        CallTarget target = ((RootNode) parentNode).getCallTarget();
        if (target instanceof OptimizedCallTarget) {
            ((OptimizedCallTarget) target).onLoopCount(count);
        }
    }
}
Also used : RootNode(com.oracle.truffle.api.nodes.RootNode) RootCallTarget(com.oracle.truffle.api.RootCallTarget) CallTarget(com.oracle.truffle.api.CallTarget) Node(com.oracle.truffle.api.nodes.Node) RootNode(com.oracle.truffle.api.nodes.RootNode)

Example 4 with CallTarget

use of com.oracle.truffle.api.CallTarget in project graal by oracle.

the class AssumptionsTest method testAssumptionArrays.

@Test
public void testAssumptionArrays() {
    CallTarget root = createCallTarget(AssumptionArrayTestFactory.getInstance());
    AssumptionArrayTest node = getNode(root);
    Assumption a1 = Truffle.getRuntime().createAssumption();
    Assumption a2 = Truffle.getRuntime().createAssumption();
    node.assumptions = new Assumption[] { a1, a2 };
    assertEquals("do1", root.call(42));
    a2.invalidate();
    assertEquals("do2", root.call(42));
}
Also used : TestHelper.createCallTarget(com.oracle.truffle.api.dsl.test.TestHelper.createCallTarget) CallTarget(com.oracle.truffle.api.CallTarget) Assumption(com.oracle.truffle.api.Assumption) Test(org.junit.Test)

Example 5 with CallTarget

use of com.oracle.truffle.api.CallTarget in project graal by oracle.

the class AssumptionsTest method testStaticField.

@Test
public void testStaticField() {
    CallTarget root = createCallTarget(StaticFieldTestFactory.getInstance());
    assertEquals(42, root.call(42));
    assertEquals(42, root.call(42));
    StaticFieldTest.FIELD.invalidate();
    try {
        root.call(45);
        fail();
    } catch (UnsupportedSpecializationException e) {
    }
}
Also used : TestHelper.createCallTarget(com.oracle.truffle.api.dsl.test.TestHelper.createCallTarget) CallTarget(com.oracle.truffle.api.CallTarget) UnsupportedSpecializationException(com.oracle.truffle.api.dsl.UnsupportedSpecializationException) Test(org.junit.Test)

Aggregations

CallTarget (com.oracle.truffle.api.CallTarget)128 Test (org.junit.Test)102 TestHelper.createCallTarget (com.oracle.truffle.api.dsl.test.TestHelper.createCallTarget)50 RootCallTarget (com.oracle.truffle.api.RootCallTarget)26 RootNode (com.oracle.truffle.api.nodes.RootNode)17 TruffleRuntime (com.oracle.truffle.api.TruffleRuntime)15 VirtualFrame (com.oracle.truffle.api.frame.VirtualFrame)10 UnsupportedSpecializationException (com.oracle.truffle.api.dsl.UnsupportedSpecializationException)9 TruffleObject (com.oracle.truffle.api.interop.TruffleObject)9 Node (com.oracle.truffle.api.nodes.Node)9 OptimizedCallTarget (org.graalvm.compiler.truffle.runtime.OptimizedCallTarget)9 TruffleContext (com.oracle.truffle.api.TruffleContext)6 LanguageContext (com.oracle.truffle.api.test.polyglot.LanguageSPITestLanguage.LanguageContext)6 Context (org.graalvm.polyglot.Context)6 Theory (org.junit.experimental.theories.Theory)6 TruffleException (com.oracle.truffle.api.TruffleException)5 UnknownIdentifierException (com.oracle.truffle.api.interop.UnknownIdentifierException)5 UnsupportedMessageException (com.oracle.truffle.api.interop.UnsupportedMessageException)5 UnsupportedTypeException (com.oracle.truffle.api.interop.UnsupportedTypeException)5 Source (com.oracle.truffle.api.source.Source)5