本文整理了Java中com.oracle.truffle.api.nodes.Node
类的一些代码示例,展示了Node
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Node
类的具体详情如下:
包路径:com.oracle.truffle.api.nodes.Node
类名称:Node
[英]Abstract base class for all Truffle nodes.
[中]所有块菌节点的抽象基类。
代码示例来源:origin: com.oracle/truffle
final void replaceHelper(Node newNode, CharSequence reason) {
CompilerAsserts.neverPartOfCompilation();
assert inAtomicBlock();
if (this.getParent() == null) {
throw new IllegalStateException("This node cannot be replaced, because it does not yet have a parent.");
}
if (sourceSection != null && newNode.getSourceSection() == null) {
// Pass on the source section to the new node.
newNode.assignSourceSection(sourceSection);
}
// (aw) need to set parent *before* replace, so that (unsynchronized) getRootNode()
// will always find the root node
newNode.parent = this.parent;
if (NodeUtil.replaceChild(this.parent, this, newNode)) {
this.parent.adoptHelper(newNode);
} else {
this.parent.adoptUnadoptedHelper(newNode);
}
reportReplace(this, newNode, reason);
onReplace(newNode, reason);
}
代码示例来源:origin: com.oracle/truffle
public final void atomic(Runnable closure) {
RootNode rootNode = getRootNode();
synchronized (rootNode != null ? rootNode : GIL) {
assert enterAtomic();
try {
closure.run();
} finally {
assert exitAtomic();
}
}
}
代码示例来源:origin: com.oracle.truffle/truffle-api
@Override
public SourceSection getInstrumentedSourceSection() {
if (node == null) {
return null;
} else {
return node.getEncapsulatingSourceSection();
}
}
代码示例来源:origin: com.oracle/truffle
private static void updateSourceSection(Node oldNode, Node newNode) {
if (newNode.getSourceSection() == null) {
newNode.assignSourceSection(oldNode.getSourceSection());
}
}
代码示例来源:origin: com.oracle/truffle
private void adoptUnadoptedHelper() {
Iterable<Node> children = this.getChildren();
for (Node child : children) {
if (child != null && child.getParent() == null) {
this.adoptUnadoptedHelper(child);
}
}
}
代码示例来源:origin: com.oracle/truffle
private void adoptHelper() {
Iterable<Node> children = this.getChildren();
for (Node child : children) {
if (child != null && child.getParent() != this) {
this.adoptHelper(child);
}
}
}
代码示例来源:origin: com.oracle.truffle/truffle-api
final void replaceHelper(Node newNode, CharSequence reason) {
CompilerAsserts.neverPartOfCompilation("do not call Node.replaceHelper from compiled code");
assert inAtomicBlock();
if (this.getParent() == null) {
throw new IllegalStateException("This node cannot be replaced, because it does not yet have a parent.");
}
// (aw) need to set parent *before* replace, so that (unsynchronized) getRootNode()
// will always find the root node
newNode.parent = this.parent;
if (!NodeUtil.replaceChild(this.parent, this, newNode, true)) {
this.parent.adoptUnadoptedHelper(newNode);
}
reportReplace(this, newNode, reason);
onReplace(newNode, reason);
}
代码示例来源:origin: org.graalvm.compiler/compiler
@Override
public void nodeProperties(PolymorphicSpecializeGraph graph, PolymorphicSpecializeGraph.DumpNode node, Map<String, ? super Object> properties) {
properties.put("label", node.node.toString());
properties.put("ROOT?", node.node instanceof RootNode);
properties.put("LEAF?", node.edge == null);
properties.put("RootNode", node.node.getRootNode());
properties.putAll(node.node.getDebugProperties());
properties.put("SourceSection", node.node.getSourceSection());
if (Introspection.isIntrospectable(node.node)) {
final List<Introspection.SpecializationInfo> specializations = Introspection.getSpecializations(node.node);
for (Introspection.SpecializationInfo specialization : specializations) {
properties.put(specialization.getMethodName() + ".isActive", specialization.isActive());
properties.put(specialization.getMethodName() + ".isExcluded", specialization.isExcluded());
properties.put(specialization.getMethodName() + ".instances", specialization.getInstances());
}
}
}
代码示例来源:origin: com.oracle/truffle
public String displayMethodName(Node node) {
if (node == null) {
return null;
}
RootNode root = node.getRootNode();
if (root == null) {
return "unknown";
}
return root.getCallTarget().toString();
}
代码示例来源:origin: com.oracle.truffle/truffle-api
public boolean visit(Node child) {
if (child != null && child.getParent() == null) {
newChild.adoptUnadoptedHelper(child);
}
return true;
}
});
代码示例来源:origin: org.graalvm.truffle/truffle-api
static void adoptChildrenHelper(Node currentNode) {
NodeClass clazz = currentNode.getNodeClass();
for (Object field : clazz.getNodeFields()) {
if (clazz.isChildField(field)) {
if (child != null) {
Node node = (Node) child;
if (node.getParent() != currentNode) {
currentNode.adoptHelper(node);
if (child != null) {
Node node = (Node) child;
if (node.getParent() != currentNode) {
currentNode.adoptHelper(node);
代码示例来源:origin: org.graalvm.truffle/truffle-api
static void traceRewrite(Node oldNode, Node newNode, CharSequence reason) {
if (TruffleOptions.TraceRewritesFilterFromCost != null) {
if (filterByKind(oldNode, TruffleOptions.TraceRewritesFilterFromCost)) {
return;
}
}
if (TruffleOptions.TraceRewritesFilterToCost != null) {
if (filterByKind(newNode, TruffleOptions.TraceRewritesFilterToCost)) {
return;
}
}
String filter = TruffleOptions.TraceRewritesFilterClass;
Class<? extends Node> from = oldNode.getClass();
Class<? extends Node> to = newNode.getClass();
if (filter != null && (filterByContainsClassName(from, filter) || filterByContainsClassName(to, filter))) {
return;
}
final SourceSection reportedSourceSection = oldNode.getEncapsulatingSourceSection();
PrintStream out = System.out;
out.printf("[truffle] rewrite %-50s |From %-40s |To %-40s |Reason %s %s%n", oldNode.toString(), formatNodeInfo(oldNode), formatNodeInfo(newNode),
reason != null && reason.length() > 0 ? reason : "unknown", formatLocation(reportedSourceSection));
}
代码示例来源:origin: org.graalvm.compiler/compiler
private static String extractSourceSection(OptimizedDirectCallNode node) {
Node cnode = node;
while (cnode.getSourceSection() == null && !(cnode instanceof RootNode)) {
cnode = cnode.getParent();
if (cnode == null) {
return "";
}
}
return getShortDescription(cnode.getSourceSection());
}
代码示例来源:origin: com.oracle.truffle/truffle-api
/**
* Originally returned the <em>tags</em> if any, associated with a node; now unsupported.
*
* @since 0.8 or earlier
*/
public static String printSyntaxTags(final Object node) {
if ((node instanceof Node) && ((Node) node).getSourceSection() != null) {
return ((Node) node).getSourceSection().toString();
}
return "";
}
代码示例来源:origin: org.graalvm.truffle/truffle-api
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;
}
代码示例来源:origin: com.oracle/truffle
public void probeAST(Node node) {
node.accept(this);
}
}
代码示例来源:origin: com.oracle/truffle
public String displaySourceLocation(Node node) {
if (node == null) {
return "<unknown>";
}
SourceSection section = node.getSourceSection();
boolean estimated = false;
if (section == null) {
section = node.getEncapsulatingSourceSection();
estimated = true;
}
return section.getShortDescription() + (estimated ? "~" : "");
}
代码示例来源:origin: org.graalvm.compiler/compiler
@Override
public boolean isCounted(Node node) {
NodeCost cost = node.getCost();
boolean polymorphic = cost == NodeCost.POLYMORPHIC || cost == NodeCost.MEGAMORPHIC;
return polymorphic;
}
});
代码示例来源:origin: com.oracle/truffle
public static boolean verify(Node root) {
Iterable<Node> children = root.getChildren();
for (Node child : children) {
if (child != null) {
if (child.getParent() != root) {
throw new AssertionError(toStringWithClass(child) + ": actual parent=" + toStringWithClass(child.getParent()) + " expected parent=" + toStringWithClass(root));
}
verify(child);
}
}
return true;
}
代码示例来源:origin: org.graalvm.compiler/compiler
@Override
public void onCompilationSuccess(OptimizedCallTarget target, TruffleInlining inliningDecision, GraphInfo graph, CompilationResultInfo result) {
for (Node node : target.nodeIterable(inliningDecision)) {
if (node != null && (node.getCost() == NodeCost.MEGAMORPHIC || node.getCost() == NodeCost.POLYMORPHIC)) {
NodeCost cost = node.getCost();
Map<String, Object> props = new LinkedHashMap<>();
props.put("simpleName", node.getClass().getSimpleName());
props.put("subtree", "\n" + NodeUtil.printCompactTreeToString(node));
String msg = cost == NodeCost.MEGAMORPHIC ? "megamorphic" : "polymorphic";
runtime.logEvent(0, msg, node.toString(), props);
}
}
}
内容来源于网络,如有侵权,请联系作者删除!