use of com.oracle.truffle.api.nodes.Node in project graal by oracle.
the class InstrumentationUpdateTest method assertExecuted.
private void assertExecuted(Node... children) {
Iterator<EventContext> executeIterator = executionEvents.iterator();
for (Node loadedChild : children) {
Assert.assertTrue(executeIterator.hasNext());
Assert.assertSame(loadedChild, executeIterator.next().getInstrumentedNode());
}
Assert.assertFalse(executeIterator.hasNext());
}
use of com.oracle.truffle.api.nodes.Node 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);
}
use of com.oracle.truffle.api.nodes.Node in project graal by oracle.
the class SourceListenerTest method testBindingDisposalImpl.
private void testBindingDisposalImpl(boolean load) throws Exception {
Instrument instrument = engine.getInstruments().get("testBindingDisposal");
TestBindingDisposal impl = instrument.lookup(TestBindingDisposal.class);
impl.doAttach(load);
Source source1 = lines("STATEMENT");
run(source1);
assertEvents(impl.onlyNewEvents, source1);
assertEvents(impl.allEvents, source1);
impl.onlyNewBinding.dispose();
impl.allBinding.dispose();
// No new events received after bindings are disposed
com.oracle.truffle.api.source.Source source2a = com.oracle.truffle.api.source.Source.newBuilder("line2a").mimeType("mime").name("NoName2a").build();
com.oracle.truffle.api.source.Source source2b = com.oracle.truffle.api.source.Source.newBuilder("line2b").mimeType("mime").name("NoName2b").build();
Node node2a = new SourceSectionFilterTest.SourceSectionNode(source2a.createSection(1));
Node node2b = new SourceSectionFilterTest.SourceSectionNode(source2b.createSection(1));
RootNode root2 = SourceSectionFilterTest.createRootNode(engine, null, Boolean.FALSE, node2a, node2b);
Truffle.getRuntime().createCallTarget(root2).call();
assertEvents(impl.onlyNewEvents, source1);
assertEvents(impl.allEvents, source1);
// Clear and reattach
impl.onlyNewEvents.clear();
impl.allEvents.clear();
impl.doAttach(load);
Source source3 = lines("VARIABLE(a, 10)");
run(source3);
assertEvents(impl.onlyNewEvents, source3);
assertEvents(impl.allEvents, getSourceImpl(source1), source2a, source2b, getSourceImpl(source3));
}
use of com.oracle.truffle.api.nodes.Node in project graal by oracle.
the class SourceSectionFilterTest method testSourceIn.
@Test
public void testSourceIn() {
Source sampleSource1 = Source.newBuilder("line1\nline2\nline3\nline4").name("unknown").mimeType(InstrumentationTestLanguage.MIME_TYPE).build();
Source sampleSource2 = Source.newBuilder("line1\nline2\nline3\nline4").name("unknown").mimeType(InstrumentationTestLanguage.MIME_TYPE).build();
Source sampleSource3 = Source.newBuilder("line1\nline2\nline3\nline4").name("unknown").mimeType(InstrumentationTestLanguage.MIME_TYPE).build();
Node root1 = createNode(sampleSource1.createSection(0, 23));
Node root2 = createNode(sampleSource2.createSection(0, 23));
Node root3 = createNode(sampleSource3.createSection(0, 23));
Assert.assertTrue(isInstrumented(SourceSectionFilter.newBuilder().sourceIs(sampleSource1).build(), root1, createNode(sampleSource1.createSection(0, 5), tags())));
Assert.assertFalse(isInstrumented(SourceSectionFilter.newBuilder().sourceIs(sampleSource1).build(), null, createNode(sampleSource2.createUnavailableSection())));
Assert.assertFalse(isInstrumented(SourceSectionFilter.newBuilder().sourceIs(sampleSource1).build(), root2, createNode(sampleSource2.createSection(0, 5), tags())));
Assert.assertTrue(isInstrumented(SourceSectionFilter.newBuilder().sourceIs(sampleSource1, sampleSource2).build(), root2, createNode(sampleSource2.createSection(0, 5), tags())));
Assert.assertTrue(isInstrumented(SourceSectionFilter.newBuilder().sourceIs(sampleSource1, sampleSource2).build(), root1, createNode(sampleSource1.createSection(0, 5), tags())));
Assert.assertFalse(isInstrumented(SourceSectionFilter.newBuilder().sourceIs(sampleSource1, sampleSource2).build(), root3, createNode(sampleSource3.createSection(0, 5), tags())));
Assert.assertNotNull(SourceSectionFilter.newBuilder().sourceIs(sampleSource1, sampleSource2).build().toString());
}
use of com.oracle.truffle.api.nodes.Node in project graal by oracle.
the class SourceSectionFilterTest method testLineStartIn.
@Test
public void testLineStartIn() {
Source sampleSource = Source.newBuilder("line1\nline2\nline3\nline4").name("unknown").mimeType(InstrumentationTestLanguage.MIME_TYPE).build();
Node root = createNode(sampleSource.createSection(0, 23));
Assert.assertTrue(isInstrumented(SourceSectionFilter.newBuilder().lineStartsIn(IndexRange.byLength(2, 1)).build(), root, createNode(sampleSource.createSection(6, 15))));
Assert.assertFalse(isInstrumented(SourceSectionFilter.newBuilder().lineStartsIn(IndexRange.byLength(2, 1)).build(), root, createNode(sampleSource.createSection(0, 15))));
Assert.assertFalse(isInstrumented(SourceSectionFilter.newBuilder().lineStartsIn(IndexRange.byLength(2, 2)).build(), root, createNode(sampleSource.createSection(0, 15))));
Assert.assertTrue(isInstrumented(SourceSectionFilter.newBuilder().lineStartsIn(IndexRange.byLength(1, 2)).build(), root, createNode(sampleSource.createSection(0, 15))));
Assert.assertTrue(isInstrumented(SourceSectionFilter.newBuilder().lineStartsIn(IndexRange.byLength(1, 2)).build(), root, createNode(sampleSource.createSection(6, 15))));
Assert.assertFalse(isInstrumented(SourceSectionFilter.newBuilder().lineStartsIn(IndexRange.byLength(1, 2)).build(), root, createNode(sampleSource.createSection(12, 6))));
}
Aggregations