use of com.oracle.truffle.api.instrumentation.ProbeNode.EventChainNode in project graal by oracle.
the class InstrumentationHandler method createBindings.
EventChainNode createBindings(VirtualFrame frame, ProbeNode probeNodeImpl) {
EventContext context = probeNodeImpl.getContext();
SourceSection sourceSection = context.getInstrumentedSourceSection();
if (TRACE) {
trace("BEGIN: Lazy update for %s%n", sourceSection);
}
RootNode rootNode;
Node parentInstrumentable = null;
SourceSection parentInstrumentableSourceSection = null;
Node parentNode = probeNodeImpl.getParent();
while (parentNode != null && parentNode.getParent() != null) {
if (parentInstrumentable == null) {
SourceSection parentSourceSection = parentNode.getSourceSection();
if (isInstrumentableNode(parentNode, parentSourceSection)) {
parentInstrumentable = parentNode;
parentInstrumentableSourceSection = parentSourceSection;
}
}
parentNode = parentNode.getParent();
}
if (parentNode instanceof RootNode) {
rootNode = (RootNode) parentNode;
} else {
throw new AssertionError();
}
Node instrumentedNode = probeNodeImpl.getContext().getInstrumentedNode();
Set<Class<?>> providedTags = getProvidedTags(rootNode);
EventChainNode root = null;
EventChainNode parent = null;
for (EventBinding.Source<?> binding : executionBindings) {
if (binding.isChildInstrumentedFull(providedTags, rootNode, parentInstrumentable, parentInstrumentableSourceSection, instrumentedNode, sourceSection)) {
if (TRACE) {
trace(" Found input value binding %s, %s%n", binding.getInputFilter(), System.identityHashCode(binding));
}
EventChainNode next = probeNodeImpl.createParentEventChainCallback(frame, binding, rootNode, providedTags);
if (next == null) {
// inconsistent AST
continue;
}
if (root == null) {
root = next;
} else {
assert parent != null;
parent.setNext(next);
}
parent = next;
}
if (binding.isInstrumentedFull(providedTags, rootNode, instrumentedNode, sourceSection)) {
if (TRACE) {
trace(" Found binding %s, %s%n", binding.getFilter(), binding.getElement());
}
EventChainNode next = probeNodeImpl.createEventChainCallback(frame, binding, rootNode, providedTags, instrumentedNode, sourceSection);
if (next == null) {
continue;
}
if (root == null) {
root = next;
} else {
assert parent != null;
parent.setNext(next);
}
parent = next;
}
}
if (TRACE) {
trace("END: Lazy updated for %s%n", sourceSection);
}
return root;
}
Aggregations