use of com.oracle.truffle.api.nodes.Node in project graal by oracle.
the class ChildNodeTest method test.
@Test
public void test() {
TruffleRuntime runtime = Truffle.getRuntime();
TestChildNode leftChild = new TestChildNode();
TestChildNode rightChild = new TestChildNode();
TestRootNode rootNode = new TestRootNode(leftChild, rightChild);
CallTarget target = runtime.createCallTarget(rootNode);
assertEquals(rootNode, leftChild.getParent());
assertEquals(rootNode, rightChild.getParent());
Iterator<Node> iterator = rootNode.getChildren().iterator();
assertEquals(leftChild, iterator.next());
assertEquals(rightChild, iterator.next());
assertFalse(iterator.hasNext());
Object result = target.call();
assertEquals(42, result);
}
use of com.oracle.truffle.api.nodes.Node in project graal by oracle.
the class SuspendableLocationFinder method findSuspendableLocations.
static Iterable<SourceSection> findSuspendableLocations(SourceSection range, boolean restrictToSingleFunction, TruffleInstrument.Env env) {
Source source = range.getSource();
int startIndex = range.getCharIndex();
int endIndex = range.getCharEndIndex();
SectionsCollector sectionsCollector = collectSuspendableLocations(source, startIndex, endIndex, restrictToSingleFunction, env);
List<SourceSection> sections = sectionsCollector.getSections();
if (sections.isEmpty()) {
SourceSectionFilter filter = SourceSectionFilter.newBuilder().sourceIs(source).indexIn(IndexRange.between(startIndex, endIndex)).build();
ContainerNodeCollector nodeCollector = new ContainerNodeCollector(startIndex);
EventBinding<ContainerNodeCollector> binding = env.getInstrumenter().attachLoadSourceSectionListener(filter, nodeCollector, true);
binding.dispose();
if (nodeCollector.getContainerNode() != null) {
Node suspendableNode = nodeCollector.getContainerNode().findNearestNodeAt(startIndex, SUSPENDABLE_TAGS_SET);
if (suspendableNode != null) {
startIndex = Math.min(startIndex, suspendableNode.getSourceSection().getCharIndex());
endIndex = Math.max(endIndex, suspendableNode.getSourceSection().getCharEndIndex());
sectionsCollector = collectSuspendableLocations(source, startIndex, endIndex, restrictToSingleFunction, env);
sections = sectionsCollector.getSections();
}
}
}
return sections;
}
use of com.oracle.truffle.api.nodes.Node in project graal by oracle.
the class NodeAdoptionBenchmark method shallowSmallBlocks.
@Benchmark
public Object shallowSmallBlocks() {
Node block = createBlock(0, 5);
block.adoptChildren();
return block;
}
use of com.oracle.truffle.api.nodes.Node in project graal by oracle.
the class NodeAdoptionBenchmark method deepSmallBlocks.
@Benchmark
public Object deepSmallBlocks() {
Node block = createBlock(5, 5);
block.adoptChildren();
return block;
}
use of com.oracle.truffle.api.nodes.Node in project graal by oracle.
the class NodeAdoptionBenchmark method deepBigBlocks.
@Benchmark
public Object deepBigBlocks() {
Node block = createBlock(5, 30);
block.adoptChildren();
return block;
}
Aggregations