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