void create(String[] expectedServices) { if (TRACE) { trace("Create instrument %s class %s %n", instrument, instrumentClass); } services = env.onCreate(instrument); if (expectedServices != null && !TruffleOptions.AOT) { checkServices(expectedServices); } if (TRACE) { trace("Created instrument %s class %s %n", instrument, instrumentClass); } }
void initializeInstrument(Object vmObject, Class<?> instrumentClass) { Env env = new Env(vmObject, out, err, in, messageInterceptor); env.instrumenter = new InstrumentClientInstrumenter(env, instrumentClass); if (TRACE) { trace("Initialize instrument class %s %n", instrumentClass); } try { env.instrumenter.instrument = (TruffleInstrument) instrumentClass.getDeclaredConstructor().newInstance(); } catch (Exception e) { failInstrumentInitialization(env, String.format("Failed to create new instrumenter class %s", instrumentClass.getName()), e); return; } if (TRACE) { trace("Initialized instrument %s class %s %n", env.instrumenter.instrument, instrumentClass); } addInstrumenter(vmObject, env.instrumenter); }
void initializeInstrument(Object vmObject, Class<?> instrumentClass) { Env env = new Env(vmObject, out, err, in); env.instrumenter = new InstrumentClientInstrumenter(env, instrumentClass); if (TRACE) { trace("Initialize instrument class %s %n", instrumentClass); } try { env.instrumenter.instrument = (TruffleInstrument) instrumentClass.newInstance(); } catch (InstantiationException | IllegalAccessException e) { failInstrumentInitialization(env, String.format("Failed to create new instrumenter class %s", instrumentClass.getName()), e); return; } if (TRACE) { trace("Initialized instrument %s class %s %n", env.instrumenter.instrument, instrumentClass); } addInstrumenter(vmObject, env.instrumenter); }
private <T extends ContextsListener> EventBinding<T> addContextsBinding(EventBinding<T> binding, boolean includeActiveContexts) { if (TRACE) { trace("BEGIN: Adding contexts binding %s%n", binding.getElement()); } contextsBindings.add(binding); if (includeActiveContexts) { Accessor.EngineSupport engineAccess = InstrumentationHandler.AccessorInstrumentHandler.engineAccess(); engineAccess.reportAllLanguageContexts(sourceVM, binding.getElement()); } if (TRACE) { trace("END: Added contexts binding %s%n", binding.getElement()); } return binding; }
private <T extends ThreadsListener> EventBinding<T> addThreadsBinding(EventBinding<T> binding, boolean includeStartedThreads) { if (TRACE) { trace("BEGIN: Adding threads binding %s%n", binding.getElement()); } threadsBindings.add(binding); if (includeStartedThreads) { Accessor.EngineSupport engineAccess = InstrumentationHandler.AccessorInstrumentHandler.engineAccess(); engineAccess.reportAllContextThreads(sourceVM, binding.getElement()); } if (TRACE) { trace("END: Added threads binding %s%n", binding.getElement()); } return binding; }
<T> EventBinding<T> addExecutionBinding(EventBinding.Source<T> binding) { if (TRACE) { trace("BEGIN: Adding execution binding %s, %s%n", binding.getFilter(), binding.getElement()); } this.executionBindings.add(binding); if (!executedRoots.isEmpty()) { visitRoots(executedRoots, new InsertWrappersWithBindingVisitor(binding)); } if (TRACE) { trace("END: Added execution binding %s, %s%n", binding.getFilter(), binding.getElement()); } return binding; }
<T> EventBinding<T> addExecutionBinding(EventBinding.Source<T> binding) { if (TRACE) { trace("BEGIN: Adding execution binding %s, %s%n", binding.getFilter(), binding.getElement()); } this.executionBindings.add(binding); if (!executedRoots.isEmpty()) { visitRoots(executedRoots, new InsertWrappersWithBindingVisitor(binding)); } if (TRACE) { trace("END: Added execution binding %s, %s%n", binding.getFilter(), binding.getElement()); } return binding; }
@SuppressWarnings("deprecation") private static void traceFilterCheck(String result, Set<Class<?>> providedTags, EventBinding<?> binding, Node node, SourceSection sourceSection) { Set<Class<?>> tags = binding.getFilter().getReferencedTags(); Set<Class<?>> containedTags = new HashSet<>(); for (Class<?> tag : tags) { if (hasTagImpl(providedTags, node, tag)) { containedTags.add(tag); } } trace(" Filter %4s %s section:%s tags:%s%n", result, binding.getFilter(), sourceSection, containedTags); }
private <T extends ContextsListener> EventBinding<T> addContextsBinding(EventBinding<T> binding, boolean includeActiveContexts) { if (TRACE) { trace("BEGIN: Adding contexts binding %s%n", binding.getElement()); } contextsBindings.add(binding); if (includeActiveContexts) { Accessor.EngineSupport engineAccess = InstrumentationHandler.AccessorInstrumentHandler.engineAccess(); engineAccess.reportAllLanguageContexts(sourceVM, binding.getElement()); } if (TRACE) { trace("END: Added contexts binding %s%n", binding.getElement()); } return binding; }
@SuppressWarnings("deprecation") private static void traceFilterCheck(String result, Set<Class<?>> providedTags, EventBinding<?> binding, Node node, SourceSection sourceSection) { Set<Class<?>> tags = binding.getFilter().getReferencedTags(); Set<Class<?>> containedTags = new HashSet<>(); for (Class<?> tag : tags) { if (hasTagImpl(providedTags, node, tag)) { containedTags.add(tag); } } trace(" Filter %4s %s section:%s tags:%s%n", result, binding.getFilter(), sourceSection, containedTags); }
private <T extends ThreadsListener> EventBinding<T> addThreadsBinding(EventBinding<T> binding, boolean includeStartedThreads) { if (TRACE) { trace("BEGIN: Adding threads binding %s%n", binding.getElement()); } threadsBindings.add(binding); if (includeStartedThreads) { Accessor.EngineSupport engineAccess = InstrumentationHandler.AccessorInstrumentHandler.engineAccess(); engineAccess.reportAllContextThreads(sourceVM, binding.getElement()); } if (TRACE) { trace("END: Added threads binding %s%n", binding.getElement()); } return binding; }
<T> EventBinding<T> addSourceSectionBinding(EventBinding.Source<T> binding, boolean notifyLoaded) { if (TRACE) { trace("BEGIN: Adding binding %s, %s%n", binding.getFilter(), binding.getElement()); } this.sourceSectionBindings.add(binding); if (notifyLoaded) { if (!loadedRoots.isEmpty()) { visitRoots(loadedRoots, new NotifyLoadedWithBindingVisitor(binding)); } } if (TRACE) { trace("END: Added binding %s, %s%n", binding.getFilter(), binding.getElement()); } return binding; }
<T> EventBinding<T> addSourceSectionBinding(EventBinding.Source<T> binding, boolean notifyLoaded) { if (TRACE) { trace("BEGIN: Adding binding %s, %s%n", binding.getFilter(), binding.getElement()); } this.sourceSectionBindings.add(binding); if (notifyLoaded) { if (!loadedRoots.isEmpty()) { visitRoots(loadedRoots, new NotifyLoadedWithBindingVisitor(binding)); } } if (TRACE) { trace("END: Added binding %s, %s%n", binding.getFilter(), binding.getElement()); } return binding; }
private void visitLoadedSourceSections(EventBinding.Source<?> binding) { if (TRACE) { trace("BEGIN: Visiting loaded source sections %s, %s%n", binding.getFilter(), binding.getElement()); } if (!loadedRoots.isEmpty()) { visitRoots(loadedRoots, new NotifyLoadedWithBindingVisitor(binding)); } if (TRACE) { trace("END: Visited loaded source sections %s, %s%n", binding.getFilter(), binding.getElement()); } }
private <T extends AllocationListener> EventBinding<T> addAllocationBinding(EventBinding.Allocation<T> binding) { if (TRACE) { trace("BEGIN: Adding allocation binding %s%n", binding.getElement()); } this.allocationBindings.add(binding); for (AllocationReporter allocationReporter : allocationReporters) { if (binding.getAllocationFilter().contains(allocationReporter.language)) { allocationReporter.addListener(binding.getElement()); } } if (TRACE) { trace("END: Added allocation binding %s%n", binding.getElement()); } return binding; }
private <T extends AllocationListener> EventBinding<T> addAllocationBinding(EventBinding.Allocation<T> binding) { if (TRACE) { trace("BEGIN: Adding allocation binding %s%n", binding.getElement()); } this.allocationBindings.add(binding); for (AllocationReporter allocationReporter : allocationReporters) { if (binding.getAllocationFilter().contains(allocationReporter.language)) { allocationReporter.addListener(binding.getElement()); } } if (TRACE) { trace("END: Added allocation binding %s%n", binding.getElement()); } return binding; }
@SuppressWarnings("deprecation") private static void invalidateWrapperImpl(com.oracle.truffle.api.instrumentation.InstrumentableFactory.WrapperNode parent, Node node) { ProbeNode probeNode = parent.getProbeNode(); if (TRACE) { SourceSection section = probeNode.getContext().getInstrumentedSourceSection(); trace("Invalidate wrapper for %s, section %s %n", node, section); } if (probeNode != null) { probeNode.invalidate(); } }
@SuppressWarnings("deprecation") private static void invalidateWrapperImpl(com.oracle.truffle.api.instrumentation.InstrumentableFactory.WrapperNode parent, Node node) { ProbeNode probeNode = parent.getProbeNode(); if (TRACE) { SourceSection section = probeNode.getContext().getInstrumentedSourceSection(); trace("Invalidate wrapper for %s, section %s %n", node, section); } if (probeNode != null) { probeNode.invalidate(); } }
@SuppressWarnings("deprecation") static void removeWrapper(ProbeNode node) { if (TRACE) { trace("Remove wrapper for %s%n", node.getContext().getInstrumentedSourceSection()); } com.oracle.truffle.api.instrumentation.InstrumentableFactory.WrapperNode wrapperNode = node.findWrapper(); ((Node) wrapperNode).replace(wrapperNode.getDelegateNode()); }
@SuppressWarnings("deprecation") static void removeWrapper(ProbeNode node) { if (TRACE) { trace("Remove wrapper for %s%n", node.getContext().getInstrumentedSourceSection()); } com.oracle.truffle.api.instrumentation.InstrumentableFactory.WrapperNode wrapperNode = node.findWrapper(); ((Node) wrapperNode).replace(wrapperNode.getDelegateNode()); }