use of com.oracle.truffle.api.instrumentation.SourceSectionFilter in project graal by oracle.
the class SuspendableLocationFinder method collectSuspendableLocations.
private static SectionsCollector collectSuspendableLocations(Source source, int startIndex, int endIndex, boolean restrictToSingleFunction, TruffleInstrument.Env env) {
SourceSectionFilter filter = SourceSectionFilter.newBuilder().sourceIs(source).indexIn(IndexRange.between(startIndex, endIndex)).tagIs(SUSPENDABLE_TAGS).build();
SectionsCollector sectionsCollector;
if (restrictToSingleFunction) {
sectionsCollector = new FunctionSectionsCollector(startIndex, env.getInstrumenter());
} else {
sectionsCollector = new SectionsCollector(startIndex);
}
EventBinding<SectionsCollector> binding = env.getInstrumenter().attachLoadSourceSectionListener(filter, sectionsCollector, true);
binding.dispose();
return sectionsCollector;
}
use of com.oracle.truffle.api.instrumentation.SourceSectionFilter 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.instrumentation.SourceSectionFilter in project graal by oracle.
the class TypeHandler method start.
public boolean start() {
if (currentBinding.get() == null) {
final SourceSectionFilter filter = SourceSectionFilter.newBuilder().tagIs(StandardTags.RootTag.class).includeInternal(false).build();
final Instrumenter instrumenter = env.getInstrumenter();
final EventBinding<TypeProfileEventFactory> binding = instrumenter.attachExecutionEventFactory(filter, new TypeProfileEventFactory());
if (currentBinding.compareAndSet(null, binding)) {
return true;
} else {
binding.dispose();
}
}
return false;
}
use of com.oracle.truffle.api.instrumentation.SourceSectionFilter in project graal by oracle.
the class CPUSamplerSnippets method resetSampling.
private void resetSampling() {
assert Thread.holdsLock(this);
cleanup();
if (!collecting || closed) {
return;
}
if (samplerThread == null) {
samplerThread = new Timer("Sampling thread", true);
}
SourceSectionFilter f = this.filter;
if (f == null) {
f = DEFAULT_FILTER;
}
this.stackOverflowed = false;
this.shadowStack = new ShadowStack(stackLimit);
this.stacksBinding = this.shadowStack.install(env.getInstrumenter(), combine(f, mode), mode == Mode.EXCLUDE_INLINED_ROOTS);
this.samplerTask = new SamplingTimerTask();
this.samplerThread.schedule(samplerTask, 0, period);
}
use of com.oracle.truffle.api.instrumentation.SourceSectionFilter in project graal by oracle.
the class MemoryTracerSnippets method resetTracer.
void resetTracer() {
assert Thread.holdsLock(this);
if (activeBinding != null) {
activeBinding.dispose();
activeBinding = null;
}
if (!collecting || closed) {
return;
}
this.shadowStack = new ShadowStack(stackLimit);
SourceSectionFilter f = this.filter;
if (f == null) {
f = DEFAULT_FILTER;
}
this.stacksBinding = this.shadowStack.install(env.getInstrumenter(), f, false);
this.activeBinding = env.getInstrumenter().attachAllocationListener(AllocationEventFilter.ANY, new Listener());
}
Aggregations