use of com.oracle.truffle.api.nodes.Node in project graal by oracle.
the class DefaultNearestNodeSearch method findFirstNode.
private static Node findFirstNode(Node contextNode, Set<Class<? extends Tag>> tags) {
Node[] first = new Node[] { null };
contextNode.accept(new NodeVisitor() {
@Override
public boolean visit(Node node) {
if (isTaggedWith(node, tags)) {
first[0] = node;
return false;
}
return true;
}
});
return first[0];
}
use of com.oracle.truffle.api.nodes.Node in project graal by oracle.
the class UnwindInstrumentationReturnSnippets method getNodeObject.
/**
* Returns a language provided object that represents the instrumented node properties. The
* returned is alwasy a valid interop object. The returned object is never <code>null</code> and
* always returns <code>true</code> for the HAS_KEYS message. Multiple calls to
* {@link #getNodeObject()} return the same node object instance.
*
* @see InstrumentableNode#getNodeObject()
* @since 0.33
*/
public Object getNodeObject() {
Object object = this.nodeObject;
if (object == null) {
CompilerDirectives.transferToInterpreterAndInvalidate();
Node node = getInstrumentedNode();
if (node instanceof InstrumentableNode) {
object = ((InstrumentableNode) node).getNodeObject();
} else {
return null;
}
if (object == null) {
object = AccessorInstrumentHandler.interopAccess().createDefaultNodeObject(node);
} else {
assert AccessorInstrumentHandler.interopAccess().isValidNodeObject(object);
}
this.nodeObject = object;
}
return object;
}
use of com.oracle.truffle.api.nodes.Node in project graal by oracle.
the class UnwindInstrumentationReturnSnippets method parseInContext.
/**
* Evaluates source of (potentially different) language using the current context. The names of
* arguments are parameters for the resulting {#link CallTarget} that allow the
* <code>source</code> to reference the actual parameters passed to
* {@link CallTarget#call(java.lang.Object...)}.
*
* @param source the source to evaluate
* @param argumentNames the names of {@link CallTarget#call(java.lang.Object...)} arguments that
* can be referenced from the source
* @return the call target representing the parsed result
* @throws IOException if the parsing or evaluation fails for some reason
* @since 0.12
* @deprecated Use
* {@link TruffleInstrument.Env#parseInline(com.oracle.truffle.api.source.Source, com.oracle.truffle.api.nodes.Node, com.oracle.truffle.api.frame.MaterializedFrame)}
* with {@link #getInstrumentedNode()} instead.
*/
@Deprecated
public CallTarget parseInContext(Source source, String... argumentNames) throws IOException {
Node instrumentedNode = getInstrumentedNode();
LanguageInfo languageInfo = instrumentedNode.getRootNode().getLanguageInfo();
if (languageInfo == null) {
throw new IllegalArgumentException("No language available for given node.");
}
Env env = AccessorInstrumentHandler.engineAccess().getEnvForInstrument(languageInfo);
return AccessorInstrumentHandler.langAccess().parse(env, source, instrumentedNode, argumentNames);
}
use of com.oracle.truffle.api.nodes.Node 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;
}
use of com.oracle.truffle.api.nodes.Node in project graal by oracle.
the class InstrumentationHandler method invalidateWrapper.
@SuppressWarnings("deprecation")
private static void invalidateWrapper(Node node) {
Node parent = node.getParent();
if (!(parent instanceof com.oracle.truffle.api.instrumentation.InstrumentableFactory.WrapperNode)) {
// not yet wrapped
return;
}
invalidateWrapperImpl((com.oracle.truffle.api.instrumentation.InstrumentableFactory.WrapperNode) parent, node);
}
Aggregations