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

Side by Side Diff: pkg/compiler/lib/src/cps_ir/cps_ir_tracer.dart

Issue 1305863010: dart2js cps: Store the TypeMask for each primitive in a field. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Print type in CPS IR tracer Created 5 years, 3 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library dart2js.ir_tracer; 5 library dart2js.ir_tracer;
6 6
7 import 'dart:async' show EventSink; 7 import 'dart:async' show EventSink;
8 import 'cps_ir_nodes.dart' as cps_ir hide Function; 8 import 'cps_ir_nodes.dart' as cps_ir hide Function;
9 import '../tracer.dart'; 9 import '../tracer.dart';
10 10
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 96
97 void printStmt(String resultVar, String contents) { 97 void printStmt(String resultVar, String contents) {
98 int bci = 0; 98 int bci = 0;
99 int uses = 0; 99 int uses = 0;
100 addIndent(); 100 addIndent();
101 add("$bci $uses $resultVar $contents <|@\n"); 101 add("$bci $uses $resultVar $contents <|@\n");
102 } 102 }
103 103
104 visitLetPrim(cps_ir.LetPrim node) { 104 visitLetPrim(cps_ir.LetPrim node) {
105 String id = names.name(node.primitive); 105 String id = names.name(node.primitive);
106 printStmt(id, "LetPrim $id = ${formatPrimitive(node.primitive)}"); 106 String primitive = visit(node.primitive);
107 printStmt(id, "LetPrim $id = $primitive [type=${node.primitive.type}]");
107 visit(node.body); 108 visit(node.body);
108 } 109 }
109 110
110 visitLetCont(cps_ir.LetCont node) { 111 visitLetCont(cps_ir.LetCont node) {
111 if (IR_TRACE_LET_CONT) { 112 if (IR_TRACE_LET_CONT) {
112 String dummy = names.name(node); 113 String dummy = names.name(node);
113 114
114 String nameContinuation(cps_ir.Continuation cont) { 115 String nameContinuation(cps_ir.Continuation cont) {
115 String name = names.name(cont); 116 String name = names.name(cont);
116 return cont.isRecursive ? '$name*' : name; 117 return cont.isRecursive ? '$name*' : name;
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 entries.add("$key: $value"); 209 entries.add("$key: $value");
209 } 210 }
210 return "LiteralMap (${entries.join(', ')})"; 211 return "LiteralMap (${entries.join(', ')})";
211 } 212 }
212 213
213 visitTypeCast(cps_ir.TypeCast node) { 214 visitTypeCast(cps_ir.TypeCast node) {
214 String dummy = names.name(node); 215 String dummy = names.name(node);
215 String value = formatReference(node.value); 216 String value = formatReference(node.value);
216 String args = node.typeArguments.map(formatReference).join(', '); 217 String args = node.typeArguments.map(formatReference).join(', ');
217 String kont = formatReference(node.continuation); 218 String kont = formatReference(node.continuation);
218 printStmt(dummy, "TypeCast ($value ${node.type} ($args)) $kont"); 219 printStmt(dummy, "TypeCast ($value ${node.dartType} ($args)) $kont");
219 } 220 }
220 221
221 visitInvokeContinuation(cps_ir.InvokeContinuation node) { 222 visitInvokeContinuation(cps_ir.InvokeContinuation node) {
222 String dummy = names.name(node); 223 String dummy = names.name(node);
223 String kont = formatReference(node.continuation); 224 String kont = formatReference(node.continuation);
224 String args = node.arguments.map(formatReference).join(', '); 225 String args = node.arguments.map(formatReference).join(', ');
225 printStmt(dummy, "InvokeContinuation $kont ($args)"); 226 printStmt(dummy, "InvokeContinuation $kont ($args)");
226 } 227 }
227 228
228 visitBranch(cps_ir.Branch node) { 229 visitBranch(cps_ir.Branch node) {
(...skipping 13 matching lines...) Expand all
242 243
243 String formatReference(cps_ir.Reference ref) { 244 String formatReference(cps_ir.Reference ref) {
244 cps_ir.Definition target = ref.definition; 245 cps_ir.Definition target = ref.definition;
245 if (target is cps_ir.Continuation && target.isReturnContinuation) { 246 if (target is cps_ir.Continuation && target.isReturnContinuation) {
246 return "return"; // Do not generate a name for the return continuation 247 return "return"; // Do not generate a name for the return continuation
247 } else { 248 } else {
248 return names.name(ref.definition); 249 return names.name(ref.definition);
249 } 250 }
250 } 251 }
251 252
252 String formatPrimitive(cps_ir.Primitive p) => visit(p);
253
254 visitConstant(cps_ir.Constant node) { 253 visitConstant(cps_ir.Constant node) {
255 return "Constant ${node.value.toStructuredString()}"; 254 return "Constant ${node.value.toStructuredString()}";
256 } 255 }
257 256
258 visitParameter(cps_ir.Parameter node) { 257 visitParameter(cps_ir.Parameter node) {
259 return "Parameter ${names.name(node)}"; 258 return "Parameter ${names.name(node)}";
260 } 259 }
261 260
262 visitMutableVariable(cps_ir.MutableVariable node) { 261 visitMutableVariable(cps_ir.MutableVariable node) {
263 return "MutableVariable ${names.name(node)}"; 262 return "MutableVariable ${names.name(node)}";
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 } 336 }
338 337
339 visitCreateInvocationMirror(cps_ir.CreateInvocationMirror node) { 338 visitCreateInvocationMirror(cps_ir.CreateInvocationMirror node) {
340 String args = node.arguments.map(formatReference).join(', '); 339 String args = node.arguments.map(formatReference).join(', ');
341 return "CreateInvocationMirror(${node.selector.name}, $args)"; 340 return "CreateInvocationMirror(${node.selector.name}, $args)";
342 } 341 }
343 342
344 visitTypeTest(cps_ir.TypeTest node) { 343 visitTypeTest(cps_ir.TypeTest node) {
345 String value = formatReference(node.value); 344 String value = formatReference(node.value);
346 String args = node.typeArguments.map(formatReference).join(', '); 345 String args = node.typeArguments.map(formatReference).join(', ');
347 return "TypeTest ($value ${node.type} ($args))"; 346 return "TypeTest ($value ${node.dartType} ($args))";
348 } 347 }
349 348
350 visitApplyBuiltinOperator(cps_ir.ApplyBuiltinOperator node) { 349 visitApplyBuiltinOperator(cps_ir.ApplyBuiltinOperator node) {
351 String operator = node.operator.toString(); 350 String operator = node.operator.toString();
352 String args = node.arguments.map(formatReference).join(', '); 351 String args = node.arguments.map(formatReference).join(', ');
353 return 'ApplyBuiltinOperator $operator ($args)'; 352 return 'ApplyBuiltinOperator $operator ($args)';
354 } 353 }
355 354
356 visitApplyBuiltinMethod(cps_ir.ApplyBuiltinMethod node) { 355 visitApplyBuiltinMethod(cps_ir.ApplyBuiltinMethod node) {
357 String method = node.method.toString(); 356 String method = node.method.toString();
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
673 672
674 @override 673 @override
675 visitAwait(cps_ir.Await node) { 674 visitAwait(cps_ir.Await node) {
676 unexpectedNode(node); 675 unexpectedNode(node);
677 } 676 }
678 677
679 visitRefinement(cps_ir.Refinement node) { 678 visitRefinement(cps_ir.Refinement node) {
680 unexpectedNode(node); 679 unexpectedNode(node);
681 } 680 }
682 } 681 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698