Search in sources :

Example 1 with LoadSourceSectionEvent

use of com.oracle.truffle.api.instrumentation.LoadSourceSectionEvent in project graal by oracle.

the class InstrumentationUpdateTest method assertLoaded.

private void assertLoaded(Node... children) {
    Iterator<LoadSourceSectionEvent> loadIterator = loadEvents.iterator();
    for (Node loadedChild : children) {
        Assert.assertTrue(loadIterator.hasNext());
        Assert.assertSame(loadedChild, loadIterator.next().getNode());
    }
    Assert.assertFalse(loadIterator.hasNext());
}
Also used : LoadSourceSectionEvent(com.oracle.truffle.api.instrumentation.LoadSourceSectionEvent) WrapperNode(com.oracle.truffle.api.instrumentation.InstrumentableNode.WrapperNode) ProbeNode(com.oracle.truffle.api.instrumentation.ProbeNode) RootNode(com.oracle.truffle.api.nodes.RootNode) Node(com.oracle.truffle.api.nodes.Node) InstrumentableNode(com.oracle.truffle.api.instrumentation.InstrumentableNode)

Example 2 with LoadSourceSectionEvent

use of com.oracle.truffle.api.instrumentation.LoadSourceSectionEvent in project graal by oracle.

the class InstrumentationMultiThreadingTest method createDummyBindings.

private static EventBinding<?>[] createDummyBindings(Instrumenter instrumenter) {
    EventBinding<?>[] bindings = new EventBinding<?>[5];
    int bi = 0;
    ExecutionEventListener dummyListener = new ExecutionEventListener() {

        public void onReturnValue(EventContext context, VirtualFrame frame, Object result) {
        }

        public void onReturnExceptional(EventContext context, VirtualFrame frame, Throwable exception) {
        }

        public void onEnter(EventContext context, VirtualFrame frame) {
        }
    };
    bindings[bi++] = instrumenter.attachExecutionEventListener(SourceSectionFilter.newBuilder().tagIs(InstrumentationTestLanguage.EXPRESSION).build(), dummyListener);
    bindings[bi++] = instrumenter.attachExecutionEventListener(SourceSectionFilter.newBuilder().tagIs(InstrumentationTestLanguage.STATEMENT).build(), dummyListener);
    bindings[bi++] = instrumenter.attachLoadSourceListener(SourceFilter.ANY, new LoadSourceListener() {

        public void onLoad(LoadSourceEvent event) {
        }
    }, true);
    bindings[bi++] = instrumenter.attachLoadSourceSectionListener(SourceSectionFilter.newBuilder().tagIs(InstrumentationTestLanguage.EXPRESSION).build(), new LoadSourceSectionListener() {

        public void onLoad(LoadSourceSectionEvent event) {
        }
    }, true);
    bindings[bi++] = instrumenter.attachLoadSourceSectionListener(SourceSectionFilter.newBuilder().tagIs(InstrumentationTestLanguage.STATEMENT).build(), new LoadSourceSectionListener() {

        public void onLoad(LoadSourceSectionEvent event) {
        }
    }, true);
    return bindings;
}
Also used : EventContext(com.oracle.truffle.api.instrumentation.EventContext) VirtualFrame(com.oracle.truffle.api.frame.VirtualFrame) EventBinding(com.oracle.truffle.api.instrumentation.EventBinding) LoadSourceEvent(com.oracle.truffle.api.instrumentation.LoadSourceEvent) LoadSourceSectionEvent(com.oracle.truffle.api.instrumentation.LoadSourceSectionEvent) LoadSourceListener(com.oracle.truffle.api.instrumentation.LoadSourceListener) LoadSourceSectionListener(com.oracle.truffle.api.instrumentation.LoadSourceSectionListener) ExecutionEventListener(com.oracle.truffle.api.instrumentation.ExecutionEventListener)

Example 3 with LoadSourceSectionEvent

use of com.oracle.truffle.api.instrumentation.LoadSourceSectionEvent in project graal by oracle.

the class InstrumentationUpdateTest method setEventFilter.

private void setEventFilter(SourceSectionFilter filter) {
    EventBinding<?> old = this.eventBinding;
    eventBinding = instrumentEnv.getInstrumenter().attachExecutionEventListener(filter, new ExecutionEventListener() {

        public void onReturnValue(EventContext ctx, VirtualFrame frame, Object result) {
        }

        public void onReturnExceptional(EventContext ctx, VirtualFrame frame, Throwable exception) {
        }

        public void onEnter(EventContext ctx, VirtualFrame frame) {
            executionEvents.add(ctx);
        }
    });
    instrumentEnv.getInstrumenter().attachLoadSourceSectionListener(filter, new LoadSourceSectionListener() {

        public void onLoad(LoadSourceSectionEvent event) {
            loadEvents.add(event);
        }
    }, true);
    // dispose afterwards to avoid disposal of instrumentation wrappers
    if (old != null) {
        old.dispose();
    }
}
Also used : EventContext(com.oracle.truffle.api.instrumentation.EventContext) VirtualFrame(com.oracle.truffle.api.frame.VirtualFrame) LoadSourceSectionEvent(com.oracle.truffle.api.instrumentation.LoadSourceSectionEvent) LoadSourceSectionListener(com.oracle.truffle.api.instrumentation.LoadSourceSectionListener) ExecutionEventListener(com.oracle.truffle.api.instrumentation.ExecutionEventListener)

Example 4 with LoadSourceSectionEvent

use of com.oracle.truffle.api.instrumentation.LoadSourceSectionEvent in project graal by oracle.

the class SourceSectionListenerTest method assertEvents.

private static void assertEvents(List<LoadSourceSectionEvent> actualEvents, SourceSection... expectedSourceSections) {
    Assert.assertEquals(expectedSourceSections.length, actualEvents.size());
    for (int i = 0; i < expectedSourceSections.length; i++) {
        LoadSourceSectionEvent actualEvent = actualEvents.get(i);
        SourceSection expectedSourceSection = expectedSourceSections[i];
        Assert.assertEquals("index " + i, expectedSourceSection, actualEvent.getSourceSection());
        Assert.assertSame("index " + i, actualEvent.getNode().getSourceSection(), actualEvent.getSourceSection());
    }
}
Also used : LoadSourceSectionEvent(com.oracle.truffle.api.instrumentation.LoadSourceSectionEvent) SourceSection(org.graalvm.polyglot.SourceSection)

Aggregations

LoadSourceSectionEvent (com.oracle.truffle.api.instrumentation.LoadSourceSectionEvent)4 VirtualFrame (com.oracle.truffle.api.frame.VirtualFrame)2 EventContext (com.oracle.truffle.api.instrumentation.EventContext)2 ExecutionEventListener (com.oracle.truffle.api.instrumentation.ExecutionEventListener)2 LoadSourceSectionListener (com.oracle.truffle.api.instrumentation.LoadSourceSectionListener)2 EventBinding (com.oracle.truffle.api.instrumentation.EventBinding)1 InstrumentableNode (com.oracle.truffle.api.instrumentation.InstrumentableNode)1 WrapperNode (com.oracle.truffle.api.instrumentation.InstrumentableNode.WrapperNode)1 LoadSourceEvent (com.oracle.truffle.api.instrumentation.LoadSourceEvent)1 LoadSourceListener (com.oracle.truffle.api.instrumentation.LoadSourceListener)1 ProbeNode (com.oracle.truffle.api.instrumentation.ProbeNode)1 Node (com.oracle.truffle.api.nodes.Node)1 RootNode (com.oracle.truffle.api.nodes.RootNode)1 SourceSection (org.graalvm.polyglot.SourceSection)1