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());
}
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);
}
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);
}
};
}
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);
}
}
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);
}
Aggregations