本文整理了Java中com.oracle.truffle.api.nodes.Node.getCost()
方法的一些代码示例,展示了Node.getCost()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Node.getCost()
方法的具体详情如下:
包路径:com.oracle.truffle.api.nodes.Node
类名称:Node
方法名:getCost
[英]Returns a rough estimate for the cost of this Node. This estimate can be used by runtime systems or guest languages to implement heuristics based on Truffle ASTs. This method is intended to be overridden by subclasses. The default implementation returns the value of NodeInfo#cost() of the NodeInfo annotation declared at the subclass. If no NodeInfo annotation is declared the method returns NodeCost#MONOMORPHIC as a default value.
[中]返回此节点成本的粗略估计值。运行时系统或来宾语言可以使用该估计来实现基于Truffle AST的启发式。此方法旨在被子类重写。默认实现返回在子类中声明的NodeInfo注释的NodeInfo#cost()值。如果没有声明NodeInfo注释,该方法将NodeCost#MONOMORPHIC作为默认值返回。
代码示例来源: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/truffle-api
private static boolean filterByKind(Node node, NodeCost cost) {
return node.getCost() == cost;
}
代码示例来源:origin: org.graalvm.truffle/truffle-api
private static boolean filterByKind(Node node, NodeCost cost) {
return node.getCost() == cost;
}
代码示例来源:origin: com.oracle/truffle
private static boolean filterByKind(Node node, NodeCost cost) {
return node.getCost() == cost;
}
代码示例来源:origin: com.oracle/truffle
private static boolean containsClass(Class<?>[] classList, Node node) {
Class<?> nodeClass = node.getClass();
for (Class<?> toCheck : classList) {
if (nodeClass == toCheck) {
if (node.getCost() == NodeCost.UNINITIALIZED) {
/*
* In case a specialization is excluded by the fallback specialization the
* uninitialized class is used as exclusion class. Because the fallback field in
* the uninitialized specialization is not accessible we use the costs to check
* if the fallback was reached or not. In case the fallback was reached in the
* uninitialized version the cost is MONOMORPHIC, otherwise it is UNINITIALIZED.
*/
continue;
}
return true;
}
}
return false;
}
代码示例来源:origin: com.oracle/truffle
private static String formatNodeInfo(Node node) {
String cost = "?";
switch (node.getCost()) {
case NONE:
cost = "G";
break;
case MONOMORPHIC:
cost = "M";
break;
case POLYMORPHIC:
cost = "P";
break;
case MEGAMORPHIC:
cost = "G";
break;
default:
cost = "?";
break;
}
return cost + " " + node.getClass().getSimpleName();
}
代码示例来源:origin: org.graalvm.compiler/compiler
@Override
public boolean visit(Node node) {
if (!node.getCost().isTrivial()) {
nodeCount++;
}
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);
}
}
}
代码示例来源:origin: org.graalvm.truffle/truffle-api
private static String formatNodeInfo(Node node) {
String cost = "?";
switch (node.getCost()) {
case NONE:
cost = "G";
break;
case MONOMORPHIC:
cost = "M";
break;
case POLYMORPHIC:
cost = "P";
break;
case MEGAMORPHIC:
cost = "G";
break;
default:
cost = "?";
break;
}
return cost + " " + nodeName(node);
}
代码示例来源:origin: com.oracle.truffle/truffle-api
private static String formatNodeInfo(Node node) {
String cost = "?";
switch (node.getCost()) {
case NONE:
cost = "G";
break;
case MONOMORPHIC:
cost = "M";
break;
case POLYMORPHIC:
cost = "P";
break;
case MEGAMORPHIC:
cost = "G";
break;
default:
cost = "?";
break;
}
return cost + " " + nodeName(node);
}
代码示例来源:origin: org.graalvm.compiler/compiler
private static void setBasicProperties(Map<String, ? super Object> properties, Node source) {
String className = className(source.getClass());
properties.put("label", dropNodeSuffix(className));
properties.put("cost", source.getCost());
NodeInfo nodeInfo = source.getClass().getAnnotation(NodeInfo.class);
if (nodeInfo != null) {
if (!nodeInfo.shortName().isEmpty()) {
properties.put("shortName", nodeInfo.shortName());
}
}
if (Introspection.isIntrospectable(source)) {
final List<Introspection.SpecializationInfo> specializations = Introspection.getSpecializations(source);
for (Introspection.SpecializationInfo specialization : specializations) {
final String methodName = specialization.getMethodName();
properties.put(methodName + ".isActive", specialization.isActive());
properties.put(methodName + ".isExcluded", specialization.isExcluded());
properties.put(methodName + ".instances", specialization.getInstances());
for (int i = 0; i < specialization.getInstances(); i++) {
final List<Object> cachedData = specialization.getCachedData(i);
for (Object o : cachedData) {
properties.put(methodName + "-cachedData[" + i + "]", o);
}
}
}
}
}
代码示例来源:origin: org.graalvm.compiler/compiler
NodeCost cost = node.getCost();
if (cost.isTrivial()) {
nodeCountTrivial++;
代码示例来源:origin: com.oracle/truffle
private static <T extends Node & DSLNode> T appendPolymorphic(Node uninitialized, T newNode) {
Class<?>[] includes = newNode.getMetadata0().getIncludes();
Node cur = getPrevious(uninitialized);
Node prev = uninitialized;
int depth = 0;
Class<?>[] types = null;
while (cur != null) {
if (containsClass(includes, cur)) {
cur.replace(prev, "Included in other specialization");
cur = prev;
} else {
depth++;
types = mergeTypes((DSLNode) cur, types);
}
prev = cur;
cur = getPrevious(cur);
}
assert prev.getCost() == NodeCost.POLYMORPHIC;
updateSourceSection(prev, newNode);
if (depth <= 1) {
newNode.adoptChildren0(prev, null);
return prev.replace(newNode, "Polymorphic to monomorphic.");
} else {
newNode.adoptChildren0(null, uninitialized);
((DSLNode) prev).updateTypes0(mergeTypes(newNode, types));
return uninitialized.replace(newNode, "Appended polymorphic");
}
}
内容来源于网络,如有侵权,请联系作者删除!