本文整理汇总了Java中com.oracle.truffle.api.nodes.Node.getCost方法的典型用法代码示例。如果您正苦于以下问题:Java Node.getCost方法的具体用法?Java Node.getCost怎么用?Java Node.getCost使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.oracle.truffle.api.nodes.Node
的用法示例。
在下文中一共展示了Node.getCost方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: notifyCompilationSuccess
import com.oracle.truffle.api.nodes.Node; //导入方法依赖的package包/类
@Override
public void notifyCompilationSuccess(OptimizedCallTarget target, TruffleInlining inliningDecision, StructuredGraph graph, CompilationResult result,
Map<OptimizedCallTarget, Object> compilationMap) {
super.notifyCompilationSuccess(target, inliningDecision, graph, result, compilationMap);
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";
log(0, msg, node.toString(), props);
}
}
}
示例2: visitNode
import com.oracle.truffle.api.nodes.Node; //导入方法依赖的package包/类
private boolean visitNode(List<TruffleInlining> stack, Node node) {
if (node == null) {
return true;
}
NodeCost cost = node.getCost();
if (cost.isTrivial()) {
nodeCountTrivial++;
} else {
nodeCountNonTrivial++;
if (cost == NodeCost.MONOMORPHIC) {
nodeCountMonomorphic++;
} else if (cost == NodeCost.POLYMORPHIC) {
nodeCountPolymorphic++;
} else if (cost == NodeCost.MEGAMORPHIC) {
nodeCountMegamorphic++;
}
}
if (node instanceof DirectCallNode) {
TruffleInliningDecision decision = CallTreeNodeVisitor.getCurrentInliningDecision(stack);
if (decision != null && decision.getProfile().getCallNode() == node && decision.isInline()) {
callCountDirectInlined++;
} else {
callCountDirectDispatched++;
}
if (decision != null && decision.getProfile().getCallNode().isCallTargetCloned()) {
callCountDirectCloned++;
} else {
callCountDirectNotCloned++;
}
} else if (node instanceof IndirectCallNode) {
callCountIndirect++;
} else if (node instanceof LoopNode) {
loopCount++;
}
return true;
}