/** * Returns a list of all loaded sources. The sources are returned in the order as they have been * loaded by the languages. * * @return an unmodifiable list of sources * @since 0.17 * @deprecated not very flexible, polls all sources without any notification about changes. */ @Deprecated public List<Source> getLoadedSources() { final List<Source> sources = new ArrayList<>(); EventBinding<?> binding = env.getInstrumenter().attachLoadSourceListener(SourceFilter.ANY, new LoadSourceListener() { public void onLoad(LoadSourceEvent event) { sources.add(event.getSource()); } }, true); binding.dispose(); return Collections.unmodifiableList(sources); }
this.activeBinding = env.getInstrumenter().attachAllocationListener(AllocationEventFilter.ANY, new Listener());
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)); } }); }
env.getInstrumenter().attachLoadSourceSectionListener( SourceSectionFilter.newBuilder().sourceIs(source).build(), sectionsCollector, true).dispose();
CPUSampler(Env env) { this.env = env; env.getInstrumenter().attachContextsListener(new ContextsListener() { @Override public void onContextCreated(TruffleContext context) { } @Override public void onLanguageContextCreated(TruffleContext context, LanguageInfo language) { } @Override public void onLanguageContextInitialized(TruffleContext context, LanguageInfo language) { if (!language.isInternal()) { nonInternalLanguageContextInitialized = true; } } @Override public void onLanguageContextFinalized(TruffleContext context, LanguageInfo language) { } @Override public void onLanguageContextDisposed(TruffleContext context, LanguageInfo language) { } @Override public void onContextClosed(TruffleContext context) { } }, true); }
env.getInstrumenter().visitLoadedSourceSections( SourceSectionFilter.newBuilder().sourceIs(source).build(), sectionsCollector);
private HeapMonitor(TruffleInstrument.Env env) { this.env = env; env.getInstrumenter().attachContextsListener(new ContextsListener() { @Override public void onContextCreated(TruffleContext context) { } @Override public void onLanguageContextCreated(TruffleContext context, LanguageInfo language) { } @Override public void onLanguageContextInitialized(TruffleContext context, LanguageInfo language) { initializedLanguages.put(language, language); } @Override public void onLanguageContextFinalized(TruffleContext context, LanguageInfo language) { initializedLanguages.remove(language); } @Override public void onLanguageContextDisposed(TruffleContext context, LanguageInfo language) { } @Override public void onContextClosed(TruffleContext context) { } }, true); }
/** @since 0.22 */ @Test public void testValueWithSource() throws Exception { String id = valueWithSource(); if (id == null) { return; } PolyglotEngine.Value valueFunction = findGlobalSymbol(id); SourceSection sourceLocation; PolyglotRuntime.Instrument instr = vm().getRuntime().getInstruments().get(TckInstrument.ID); instr.setEnabled(true); try { Value value = valueFunction.execute(); TckInstrument tckInstrument = instr.lookup(TckInstrument.class); assertNotNull(tckInstrument); TruffleInstrument.Env env = tckInstrument.getEnvironment(); assertNotNull(env); sourceLocation = value.getSourceLocation(); assertNotNull(sourceLocation); List<SourceSection> lss = env.getInstrumenter().querySourceSections(SourceSectionFilter.ANY); assertTrue("Source section not among loaded sections", lss.contains(sourceLocation)); } finally { instr.setEnabled(false); } }
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.shadowStack = new ShadowStack(stackLimit, f, env.getInstrumenter(), TruffleLogger.getLogger(CPUTracerInstrument.ID)); this.stacksBinding = this.shadowStack.install(env.getInstrumenter(), f, false); this.activeBinding = env.getInstrumenter().attachAllocationListener(AllocationEventFilter.ANY, new Listener()); }
Instrumenter getInstrumenter() { return env.getInstrumenter(); }
DebuggerExecutionLifecycle(DebuggerSession session) { this.session = session; this.lifecycleInstrumenter = session.getDebugger().getEnv().getInstrumenter(); }
DebuggerExecutionLifecycle(Debugger debugger) { this.debugger = debugger; this.lifecycleInstrumenter = debugger.getEnv().getInstrumenter(); }
Instrumenter getInstrumenter() { return env.getInstrumenter(); }
@Override public Payload apply(SourceSection section) { return new Payload(new StackTraceEntry(CPUTracer.this.env.getInstrumenter(), context, StackTraceEntry.STATE_INTERPRETED)); } });
@Override protected void onCreate(Env env) { this.profiler = new Profiler(env.getInstrumenter()); env.registerService(this.profiler); }
private synchronized ShadowStack initializeShadowStack() { ShadowStack localShadowStack = shadowStack; if (localShadowStack == null) { assert stacksBinding == null; SourceSectionFilter f = this.filter; if (f == null) { f = DEFAULT_FILTER; } this.shadowStack = localShadowStack = new ShadowStack(stackLimit, f, env.getInstrumenter(), TruffleLogger.getLogger(CPUSamplerInstrument.ID)); this.stacksBinding = this.shadowStack.install(env.getInstrumenter(), combine(f, mode), mode == Mode.EXCLUDE_INLINED_ROOTS); } return localShadowStack; }