/** * Find or create a logger for a given language or instrument class. If a logger for the class * already exists it's returned, otherwise a new logger is created. * * @param id the unique id of language or instrument * @param forClass the {@link Class} to create a logger for * @return a {@link Logger} * @throws NullPointerException if {@code id} or {@code forClass} is null * @since 1.0 */ public static TruffleLogger getLogger(final String id, final Class<?> forClass) { Objects.requireNonNull(forClass, "Class must be non null."); return getLogger(id, forClass.getName()); }
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; }
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()); }