Search in sources :

Example 31 with RootNode

use of com.oracle.truffle.api.nodes.RootNode in project graal by oracle.

the class SLInstrumentTest method checkRootNode.

private static void checkRootNode(Scope ls, String name, MaterializedFrame frame) {
    assertEquals(name, ls.getName());
    Node node = ls.getNode();
    assertTrue(node.getClass().getName(), node instanceof RootNode);
    assertEquals(name, ((RootNode) node).getName());
    assertEquals(frame.getFrameDescriptor(), ((RootNode) node).getFrameDescriptor());
}
Also used : RootNode(com.oracle.truffle.api.nodes.RootNode) RootNode(com.oracle.truffle.api.nodes.RootNode) ProbeNode(com.oracle.truffle.api.instrumentation.ProbeNode) Node(com.oracle.truffle.api.nodes.Node)

Example 32 with RootNode

use of com.oracle.truffle.api.nodes.RootNode in project graal by oracle.

the class PolyglotExceptionFrame method createGuest.

static PolyglotExceptionFrame createGuest(PolyglotExceptionImpl exception, TruffleStackTraceElement frame, boolean first) {
    if (frame == null) {
        return null;
    }
    RootNode targetRoot = frame.getTarget().getRootNode();
    if (targetRoot.isInternal()) {
        return null;
    }
    LanguageInfo info = targetRoot.getLanguageInfo();
    if (info == null) {
        return null;
    }
    PolyglotEngineImpl engine = exception.context.getEngine();
    PolyglotLanguage language = engine.idToLanguage.get(info.getId());
    String rootName = targetRoot.getName();
    SourceSection location;
    Node callNode = frame.getLocation();
    if (callNode != null) {
        com.oracle.truffle.api.source.SourceSection section = callNode.getEncapsulatingSourceSection();
        if (section != null) {
            Source source = engine.getAPIAccess().newSource(language.getId(), section.getSource());
            location = engine.getAPIAccess().newSourceSection(source, section);
        } else {
            location = null;
        }
    } else {
        location = first ? exception.getSourceLocation() : null;
    }
    return new PolyglotExceptionFrame(exception, language, location, rootName, false, null);
}
Also used : RootNode(com.oracle.truffle.api.nodes.RootNode) Node(com.oracle.truffle.api.nodes.Node) RootNode(com.oracle.truffle.api.nodes.RootNode) Source(org.graalvm.polyglot.Source) LanguageInfo(com.oracle.truffle.api.nodes.LanguageInfo) SourceSection(org.graalvm.polyglot.SourceSection)

Example 33 with RootNode

use of com.oracle.truffle.api.nodes.RootNode in project graal by oracle.

the class TruffleTestInvoker method createStatement.

Statement createStatement(String testName, FrameworkMethod method, Object test) {
    final TruffleFrameworkMethod truffleMethod = (TruffleFrameworkMethod) method;
    final RootNode[] testNodes = truffleMethod.createTestRootNodes(test);
    if (testNodes == null) {
        return null;
    }
    return new Statement() {

        @Override
        public void evaluate() throws Throwable {
            ArrayList<T> callTargets = new ArrayList<>(testNodes.length);
            for (RootNode testNode : testNodes) {
                callTargets.add(createTestCallTarget(testNode));
            }
            Object[] args = callTargets.toArray();
            for (int i = 0; i < truffleMethod.warmupIterations; i++) {
                truffleMethod.invokeExplosively(test, args);
            }
            for (T callTarget : callTargets) {
                finishWarmup(callTarget, testName);
            }
            truffleMethod.invokeExplosively(test, args);
        }
    };
}
Also used : RootNode(com.oracle.truffle.api.nodes.RootNode) Statement(org.junit.runners.model.Statement) ArrayList(java.util.ArrayList)

Example 34 with RootNode

use of com.oracle.truffle.api.nodes.RootNode in project graal by oracle.

the class Profiler method createCountingNode.

private ExecutionEventNode createCountingNode(EventContext context) {
    SourceSection sourceSection = context.getInstrumentedSourceSection();
    Counter counter = counters.get(sourceSection);
    if (counter == null) {
        final RootNode rootNode = context.getInstrumentedNode().getRootNode();
        counter = new Counter(sourceSection, rootNode == null ? "<unknown>>" : rootNode.getName());
        counters.put(sourceSection, counter);
    }
    if (isTiming) {
        return TimedCounterNode.create(this, counter, context);
    } else {
        return new CounterNode(this, counter);
    }
}
Also used : RootNode(com.oracle.truffle.api.nodes.RootNode) SourceSection(com.oracle.truffle.api.source.SourceSection)

Example 35 with RootNode

use of com.oracle.truffle.api.nodes.RootNode in project graal by oracle.

the class SourceListenerTest method testNoRootSectionImpl.

private void testNoRootSectionImpl(TestLoadExecuteSource impl) throws Exception {
    com.oracle.truffle.api.source.Source source1 = com.oracle.truffle.api.source.Source.newBuilder("line1\nline2").mimeType("mime").name("NoName1").build();
    com.oracle.truffle.api.source.Source source2 = com.oracle.truffle.api.source.Source.newBuilder("line3\nline4").mimeType("mime").name("NoName2").build();
    com.oracle.truffle.api.source.Source source3 = com.oracle.truffle.api.source.Source.newBuilder("line5\nline6").mimeType("mime").name("NoName3").build();
    Node node1 = new SourceSectionFilterTest.SourceSectionNode(source1.createSection(1));
    RootNode rootA = SourceSectionFilterTest.createRootNode(engine, null, Boolean.FALSE, node1);
    assertEvents(impl.allEvents);
    Truffle.getRuntime().createCallTarget(rootA).call();
    assertEvents(impl.allEvents, source1);
    Node node2 = new SourceSectionFilterTest.SourceSectionNode(source2.createSection(2));
    Node node3 = new SourceSectionFilterTest.SourceSectionNode(source3.createSection(2));
    RootNode rootB = SourceSectionFilterTest.createRootNode(engine, null, Boolean.FALSE, node2, node3);
    assertEvents(impl.allEvents, source1);
    Truffle.getRuntime().createCallTarget(rootB).call();
    assertEvents(impl.allEvents, source1, source2, source3);
}
Also used : RootNode(com.oracle.truffle.api.nodes.RootNode) Node(com.oracle.truffle.api.nodes.Node) RootNode(com.oracle.truffle.api.nodes.RootNode)

Aggregations

RootNode (com.oracle.truffle.api.nodes.RootNode)86 Test (org.junit.Test)36 VirtualFrame (com.oracle.truffle.api.frame.VirtualFrame)24 Node (com.oracle.truffle.api.nodes.Node)23 CallTarget (com.oracle.truffle.api.CallTarget)16 OptimizedCallTarget (org.graalvm.compiler.truffle.runtime.OptimizedCallTarget)16 RootCallTarget (com.oracle.truffle.api.RootCallTarget)12 FrameDescriptor (com.oracle.truffle.api.frame.FrameDescriptor)12 RootTestNode (org.graalvm.compiler.truffle.test.nodes.RootTestNode)9 Source (com.oracle.truffle.api.source.Source)8 AbstractTestNode (org.graalvm.compiler.truffle.test.nodes.AbstractTestNode)8 TruffleRuntime (com.oracle.truffle.api.TruffleRuntime)7 TruffleBoundary (com.oracle.truffle.api.CompilerDirectives.TruffleBoundary)6 SourceSection (com.oracle.truffle.api.source.SourceSection)6 LanguageInfo (com.oracle.truffle.api.nodes.LanguageInfo)5 ArrayList (java.util.ArrayList)5 TruffleObject (com.oracle.truffle.api.interop.TruffleObject)4 TruffleContext (com.oracle.truffle.api.TruffleContext)3 TruffleException (com.oracle.truffle.api.TruffleException)3 TruffleLanguage (com.oracle.truffle.api.TruffleLanguage)3