Search in sources :

Example 1 with ExecutionEventNodeFactory

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

the class Profiler method reset.

// Reconfigure what's being collected; does not affect collected data
private void reset() {
    if (binding != null) {
        binding.dispose();
        binding = null;
    }
    if (isCollecting) {
        final Builder filterBuilder = SourceSectionFilter.newBuilder();
        if (mimeTypes != null) {
            filterBuilder.mimeTypeIs(mimeTypes);
        }
        final SourceSectionFilter filter = filterBuilder.tagIs(StandardTags.RootTag.class).sourceIs(notInternal).build();
        binding = instrumenter.attachExecutionEventFactory(filter, new ExecutionEventNodeFactory() {

            public ExecutionEventNode create(EventContext context) {
                return createCountingNode(context);
            }
        });
    }
}
Also used : EventContext(com.oracle.truffle.api.instrumentation.EventContext) ExecutionEventNodeFactory(com.oracle.truffle.api.instrumentation.ExecutionEventNodeFactory) Builder(com.oracle.truffle.api.instrumentation.SourceSectionFilter.Builder) SourceSectionFilter(com.oracle.truffle.api.instrumentation.SourceSectionFilter) StandardTags(com.oracle.truffle.api.instrumentation.StandardTags)

Example 2 with ExecutionEventNodeFactory

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

the class InstrumentationEventTest method setUp.

@Before
public final void setUp() {
    this.context = Context.create();
    this.instrument = context.getEngine().getInstruments().get(InputFilterTestInstrument.ID).lookup(InputFilterTestInstrument.class);
    this.instrumenter = instrument.environment.getInstrumenter();
    this.events = new ArrayList<>();
    this.factory = new ExecutionEventNodeFactory() {

        public ExecutionEventNode create(EventContext c) {
            return new ExecutionEventNode() {

                {
                    for (int i = 0; i < getInputCount(); i++) {
                        Assert.assertNotNull(getInputContext(i));
                    }
                }

                @Override
                protected void onInputValue(VirtualFrame frame, EventContext inputContext, int inputIndex, Object inputValue) {
                    saveInputValue(frame, inputIndex, inputValue);
                    assertTrue(inputIndex < getInputCount());
                    assertSame(inputContext, getInputContext(inputIndex));
                    events.add(new Event(EventKind.INPUT_VALUE, c, frame, null, null, inputIndex, inputValue, createInputContexts()));
                }

                @Override
                public void onEnter(VirtualFrame frame) {
                    events.add(new Event(EventKind.ENTER, c, frame, null, null, -1, null, createInputContexts()));
                }

                @Override
                protected void onReturnValue(VirtualFrame frame, Object result) {
                    events.add(new Event(EventKind.RETURN_VALUE, c, frame, getSavedInputValues(frame), result, -1, null, createInputContexts()));
                }

                private EventContext[] createInputContexts() {
                    EventContext[] inputContexts = new EventContext[getInputCount()];
                    for (int i = 0; i < getInputCount(); i++) {
                        Assert.assertNotNull(getInputContext(i));
                        inputContexts[i] = getInputContext(i);
                    }
                    return inputContexts;
                }
            };
        }
    };
}
Also used : EventContext(com.oracle.truffle.api.instrumentation.EventContext) VirtualFrame(com.oracle.truffle.api.frame.VirtualFrame) ExecutionEventNodeFactory(com.oracle.truffle.api.instrumentation.ExecutionEventNodeFactory) ExecutionEventNode(com.oracle.truffle.api.instrumentation.ExecutionEventNode) Before(org.junit.Before)

Example 3 with ExecutionEventNodeFactory

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

the class CPUTracerSnippets method resetTracer.

private synchronized void resetTracer() {
    assert Thread.holdsLock(this);
    if (activeBinding != null) {
        activeBinding.dispose();
        activeBinding = null;
    }
    if (!collecting || closed) {
        return;
    }
    SourceSectionFilter f = this.filter;
    if (f == null) {
        f = DEFAULT_FILTER;
    }
    this.activeBinding = env.getInstrumenter().attachExecutionEventFactory(f, new ExecutionEventNodeFactory() {

        @Override
        public ExecutionEventNode create(EventContext context) {
            return new CounterNode(getCounter(context));
        }
    });
}
Also used : EventContext(com.oracle.truffle.api.instrumentation.EventContext) ExecutionEventNodeFactory(com.oracle.truffle.api.instrumentation.ExecutionEventNodeFactory) SourceSectionFilter(com.oracle.truffle.api.instrumentation.SourceSectionFilter)

Aggregations

EventContext (com.oracle.truffle.api.instrumentation.EventContext)3 ExecutionEventNodeFactory (com.oracle.truffle.api.instrumentation.ExecutionEventNodeFactory)3 SourceSectionFilter (com.oracle.truffle.api.instrumentation.SourceSectionFilter)2 VirtualFrame (com.oracle.truffle.api.frame.VirtualFrame)1 ExecutionEventNode (com.oracle.truffle.api.instrumentation.ExecutionEventNode)1 Builder (com.oracle.truffle.api.instrumentation.SourceSectionFilter.Builder)1 StandardTags (com.oracle.truffle.api.instrumentation.StandardTags)1 Before (org.junit.Before)1