@Override public boolean isCounted(Node node) { NodeCost cost = node.getCost(); boolean polymorphic = cost == NodeCost.POLYMORPHIC || cost == NodeCost.MEGAMORPHIC; return polymorphic; } });
private static boolean filterByKind(Node node, NodeCost cost) { return node.getCost() == cost; }
private static boolean filterByKind(Node node, NodeCost cost) { return node.getCost() == cost; }
private static boolean filterByKind(Node node, NodeCost cost) { return node.getCost() == cost; }
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; }
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(); }
@Override public boolean visit(Node node) { if (!node.getCost().isTrivial()) { nodeCount++; } return true; } }
@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); } } }
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); }
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); }
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); } } } } }
NodeCost cost = node.getCost(); if (cost.isTrivial()) { nodeCountTrivial++;
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"); } }