Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(37)

Unified Diff: pkg/compiler/lib/src/cps_ir/cps_ir_nodes_sexpr.dart

Issue 1616673002: dart2js cps: Debugging utility and fix idempotency in shrinking reducer. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Do not run the same Pass instance twice Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/compiler/lib/src/cps_ir/cps_ir_nodes.dart ('k') | pkg/compiler/lib/src/cps_ir/cps_ir_tracer.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/cps_ir/cps_ir_nodes_sexpr.dart
diff --git a/pkg/compiler/lib/src/cps_ir/cps_ir_nodes_sexpr.dart b/pkg/compiler/lib/src/cps_ir/cps_ir_nodes_sexpr.dart
index 2271f269f2fbec35e9eb68ca3c8f59fa203ada6f..daa8408d436896f2bf3458651fd409aa7b1ce701 100644
--- a/pkg/compiler/lib/src/cps_ir/cps_ir_nodes_sexpr.dart
+++ b/pkg/compiler/lib/src/cps_ir/cps_ir_nodes_sexpr.dart
@@ -29,6 +29,50 @@ class SExpressionStringifier extends Indentation implements Visitor<String> {
}
}
+ /// Create a stringifier with an extra layer of decoration.
+ SExpressionStringifier withDecorator(Decorator subDecorator) {
+ return new SExpressionStringifier((node, String s) {
+ return subDecorator(node, decorator(node, s));
+ });
+ }
+
+ /// Create a stringifier that displays type information.
+ SExpressionStringifier withTypes() => withDecorator(typeDecorator);
+
+ /// Creates a stringifier that adds annotations from a map;
+ /// see [Node.debugString].
+ SExpressionStringifier withAnnotations(Map annotations) {
+ return withDecorator(decoratorFromMap(annotations));
+ }
+
+ static Decorator decoratorFromMap(Map annotations) {
+ Map<Node, String> nodeMap = {};
+ for (var key in annotations.keys) {
+ if (key is Node) {
+ nodeMap[key] = '${annotations[key]}';
+ } else {
+ String text = key;
+ Node node = annotations[key];
+ if (nodeMap.containsKey(node)) {
+ // In case two annotations belong to the same node,
+ // put both annotations on that node.
+ nodeMap[node] += ' $text';
+ } else {
+ nodeMap[node] = text;
+ }
+ }
+ }
+ return (node, string) {
+ String text = nodeMap[node];
+ if (text != null) return '***$string*** $text';
+ return string;
+ };
+ }
+
+ static String typeDecorator(node, String string) {
+ return node is Variable ? '$string:${node.type}' : string;
+ }
+
String access(Reference<Definition> r) {
if (r == null) return '**** NULL ****';
return decorator(r, namer.getName(r.definition));
@@ -78,7 +122,8 @@ class SExpressionStringifier extends Indentation implements Visitor<String> {
node = node.body;
name = newValueName(node.primitive);
value = visit(node.primitive);
- bindings += '\n${indentation}$skip($name $value)';
+ String binding = decorator(node, '($name $value)');
+ bindings += '\n${indentation}$skip$binding';
}
String body = indentBlock(() => visit(node.body));
return '$indentation(LetPrim ($bindings)\n$body)';
« no previous file with comments | « pkg/compiler/lib/src/cps_ir/cps_ir_nodes.dart ('k') | pkg/compiler/lib/src/cps_ir/cps_ir_tracer.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698