/** @since 0.12 */ @Override public String toString() { return "EventContext[source=" + getInstrumentedSourceSection() + "]"; }
public SourceSection getInstrumentedSourceSection() { return eventContext.getInstrumentedSourceSection(); }
/** @since 0.12 */ @Override public String toString() { return "EventContext[source=" + getInstrumentedSourceSection() + "]"; }
private Payload getCounter(EventContext context) { SourceSection sourceSection = context.getInstrumentedSourceSection(); return payloadMap.computeIfAbsent(sourceSection, new Function<SourceSection, Payload>() { @Override public Payload apply(SourceSection section) { return new Payload(new StackTraceEntry(CPUTracer.this.env.getInstrumenter(), context, StackTraceEntry.STATE_INTERPRETED)); } }); }
/** * Creates a shallow copy of this node. * * @return the new copy * @since 0.31 */ @Override public Node copy() { ProbeNode pn = (ProbeNode) super.copy(); pn.context = new EventContext(pn, context.getInstrumentedSourceSection()); return pn; }
/** * Creates a shallow copy of this node. * * @return the new copy * @since 0.31 */ @Override public Node copy() { ProbeNode pn = (ProbeNode) super.copy(); pn.context = new EventContext(pn, context.getInstrumentedSourceSection()); return pn; }
public SourceSection getInstrumentedSourceSection() { SourceSection ss = eventContext.getInstrumentedSourceSection(); if (ss == null) { Node node = eventContext.getInstrumentedNode(); // Nodes tagged with standard tags should have a source section attached. PrintStream err = new PrintStream(env.err()); err.print("WARNING: Instrumented node " + node + " of class " + node.getClass() + " has null SourceSection."); ss = node.getEncapsulatingSourceSection(); if (ss == null) { RootNode root = node.getRootNode(); err.print("WARNING: and null encapsulating SourceSection under " + root + " of class = " + root.getClass()); } err.flush(); } return ss; }
@Override public ExecutionEventNode create(EventContext context) { if (!isResolved()) { resolveBreakpoint(context.getInstrumentedSourceSection()); } switch (suspendAnchor) { case BEFORE: return new BreakpointBeforeNode(Breakpoint.this, context); case AFTER: return new BreakpointAfterNode(Breakpoint.this, context); default: throw new IllegalStateException("Unknown suspend anchor: " + suspendAnchor); } }
AbstractNode(ListenerImpl config, EventContext context) { this.config = config; this.context = context; this.location = config.engine.impl.getPolyglotSourceSection(context.getInstrumentedSourceSection()); this.cachedEvent = config.engine.impl.getMonitoring().newExecutionEvent(this); }
@Override public ExecutionEventNode create(EventContext context) { if (!isResolved()) { resolveBreakpoint(context.getInstrumentedSourceSection()); } if (exceptionFilter != null) { return new BreakpointAfterNodeException(Breakpoint.this, context); } switch (suspendAnchor) { case BEFORE: return new BreakpointBeforeNode(Breakpoint.this, context); case AFTER: return new BreakpointAfterNode(Breakpoint.this, context); default: throw new IllegalStateException("Unknown suspend anchor: " + suspendAnchor); } }
private ExecutionEventNode createCountingNode(EventContext context) { SourceSection sourceSection = context.getInstrumentedSourceSection(); Counter counter = counters.get(sourceSection); if (counter == null) { final RootNode rootNode = context.getInstrumentedNode().getRootNode(); counter = new Counter(sourceSection, rootNode == null ? "<unknown>>" : rootNode.getName()); counters.put(sourceSection, counter); } if (isTiming) { return TimedCounterNode.create(this, counter, context); } else { return new CounterNode(this, counter); } }
StackTraceEntry(Instrumenter instrumenter, EventContext context, byte state) { this.tags = instrumenter.queryTags(context.getInstrumentedNode()); this.sourceSection = context.getInstrumentedSourceSection(); this.instrumentedNode = context.getInstrumentedNode(); this.rootName = extractRootName(instrumentedNode); this.state = state; }
@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()); }
final EventContext getInputContext(int index) { EventContext[] contexts = inputContexts; if (contexts == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); ProbeNode probe = findProbe(); EventContext thisContext = probe.context; RootNode rootNode = getRootNode(); Set<Class<?>> providedTags = probe.handler.getProvidedTags(rootNode); inputContexts = contexts = findChildContexts(getBinding(), rootNode, providedTags, thisContext.getInstrumentedNode(), thisContext.getInstrumentedSourceSection(), inputCount); } if (contexts == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); throw new IllegalStateException("Input event context not yet available. They are only available during event notifications."); } return contexts[index]; }
final EventContext getInputContext(int index) { EventContext[] contexts = inputContexts; if (contexts == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); ProbeNode probe = findProbe(); EventContext thisContext = probe.context; RootNode rootNode = getRootNode(); Set<Class<?>> providedTags = probe.handler.getProvidedTags(rootNode); inputContexts = contexts = findChildContexts(getBinding(), rootNode, providedTags, thisContext.getInstrumentedNode(), thisContext.getInstrumentedSourceSection(), inputCount); } if (contexts == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); throw new IllegalStateException("Input event context not yet available. They are only available during event notifications."); } return contexts[index]; }
EventChainNode createParentEventChainCallback(VirtualFrame frame, EventBinding.Source<?> binding, RootNode rootNode, Set<Class<?>> providedTags) { EventChainNode parent = findParentChain(frame, binding); if (!(parent instanceof EventProviderWithInputChainNode)) { // this event is unreachable because nobody is listening to it. return null; } EventContext parentContext = parent.findProbe().getContext(); EventProviderWithInputChainNode parentChain = (EventProviderWithInputChainNode) parent; int index = indexOfChild(binding, rootNode, providedTags, parentContext.getInstrumentedNode(), parentContext.getInstrumentedSourceSection(), context.getInstrumentedNode()); if (index < 0 || index >= parentChain.inputCount) { // not found. a child got replaced? // TODO what to do if child was not found? // we should not continue with an out of bounds child index. assert false; return null; } ProbeNode probe = parent.findProbe(); return new InputValueChainNode(binding, probe, context, index); }
EventChainNode createParentEventChainCallback(VirtualFrame frame, EventBinding.Source<?> binding, RootNode rootNode, Set<Class<?>> providedTags) { EventChainNode parent = findParentChain(frame, binding); if (!(parent instanceof EventProviderWithInputChainNode)) { // this event is unreachable because nobody is listening to it. return null; } EventContext parentContext = parent.findProbe().getContext(); EventProviderWithInputChainNode parentChain = (EventProviderWithInputChainNode) parent; int index = indexOfChild(binding, rootNode, providedTags, parentContext.getInstrumentedNode(), parentContext.getInstrumentedSourceSection(), context.getInstrumentedNode()); if (index < 0 || index >= parentChain.inputCount) { // not found. a child got replaced? // probe should have been notified about this with notifyInserted assert throwIllegalASTAssertion(parentChain, parentContext, binding, rootNode, providedTags, index); return null; } ProbeNode probe = parent.findProbe(); return new InputValueChainNode(binding, probe, context, index); }