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

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

Issue 1153603006: dart2js cps: Type casts and related changes to type propagation. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Another typo in SExpression unstrngifier Created 5 years, 6 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 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 String dummy = names.name(node); 186 String dummy = names.name(node);
187 String value = formatReference(node.value); 187 String value = formatReference(node.value);
188 printStmt(dummy, "Throw $value"); 188 printStmt(dummy, "Throw $value");
189 } 189 }
190 190
191 visitRethrow(cps_ir.Rethrow node) { 191 visitRethrow(cps_ir.Rethrow node) {
192 String dummy = names.name(node); 192 String dummy = names.name(node);
193 printStmt(dummy, "Rethrow"); 193 printStmt(dummy, "Rethrow");
194 } 194 }
195 195
196 visitUnreachable(cps_ir.Unreachable node) {
197 String dummy = names.name(node);
198 printStmt(dummy, 'Unreachable');
199 }
200
196 visitLiteralList(cps_ir.LiteralList node) { 201 visitLiteralList(cps_ir.LiteralList node) {
197 String dummy = names.name(node); 202 String dummy = names.name(node);
198 String values = node.values.map(formatReference).join(', '); 203 String values = node.values.map(formatReference).join(', ');
199 printStmt(dummy, "LiteralList ($values)"); 204 printStmt(dummy, "LiteralList ($values)");
200 } 205 }
201 206
202 visitLiteralMap(cps_ir.LiteralMap node) { 207 visitLiteralMap(cps_ir.LiteralMap node) {
203 String dummy = names.name(node); 208 String dummy = names.name(node);
204 List<String> entries = new List<String>(); 209 List<String> entries = new List<String>();
205 for (cps_ir.LiteralMapEntry entry in node.entries) { 210 for (cps_ir.LiteralMapEntry entry in node.entries) {
206 String key = formatReference(entry.key); 211 String key = formatReference(entry.key);
207 String value = formatReference(entry.value); 212 String value = formatReference(entry.value);
208 entries.add("$key: $value"); 213 entries.add("$key: $value");
209 } 214 }
210 printStmt(dummy, "LiteralMap (${entries.join(', ')})"); 215 printStmt(dummy, "LiteralMap (${entries.join(', ')})");
211 } 216 }
212 217
213 visitTypeOperator(cps_ir.TypeOperator node) { 218 visitTypeCast(cps_ir.TypeCast node) {
214 String dummy = names.name(node); 219 String dummy = names.name(node);
215 String operator = node.isTypeTest ? 'is' : 'as';
216 List<String> entries = new List<String>();
217 String value = formatReference(node.value); 220 String value = formatReference(node.value);
221 String args = node.typeArguments.map(formatReference).join(', ');
218 String kont = formatReference(node.continuation); 222 String kont = formatReference(node.continuation);
219 printStmt(dummy, "TypeOperator ($operator $value ${node.type}) $kont"); 223 printStmt(dummy, "TypeCast ($value ${node.type} ($args)) $kont");
220 } 224 }
221 225
222 visitInvokeContinuation(cps_ir.InvokeContinuation node) { 226 visitInvokeContinuation(cps_ir.InvokeContinuation node) {
223 String dummy = names.name(node); 227 String dummy = names.name(node);
224 String kont = formatReference(node.continuation); 228 String kont = formatReference(node.continuation);
225 String args = node.arguments.map(formatReference).join(', '); 229 String args = node.arguments.map(formatReference).join(', ');
226 printStmt(dummy, "InvokeContinuation $kont ($args)"); 230 printStmt(dummy, "InvokeContinuation $kont ($args)");
227 } 231 }
228 232
229 visitBranch(cps_ir.Branch node) { 233 visitBranch(cps_ir.Branch node) {
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 358
355 visitNonTailThrow(cps_ir.NonTailThrow node) { 359 visitNonTailThrow(cps_ir.NonTailThrow node) {
356 String value = formatReference(node.value); 360 String value = formatReference(node.value);
357 return "NonTailThrow($value)"; 361 return "NonTailThrow($value)";
358 } 362 }
359 363
360 visitCreateInvocationMirror(cps_ir.CreateInvocationMirror node) { 364 visitCreateInvocationMirror(cps_ir.CreateInvocationMirror node) {
361 String args = node.arguments.map(formatReference).join(', '); 365 String args = node.arguments.map(formatReference).join(', ');
362 return "CreateInvocationMirror(${node.selector.name}, $args)"; 366 return "CreateInvocationMirror(${node.selector.name}, $args)";
363 } 367 }
368
369 visitTypeTest(cps_ir.TypeTest node) {
370 String value = formatReference(node.value);
371 String args = node.typeArguments.map(formatReference).join(', ');
372 return "TypeTest ($value ${node.type} ($args))";
373 }
364 } 374 }
365 375
366 /** 376 /**
367 * Invents (and remembers) names for Continuations, Parameters, etc. 377 * Invents (and remembers) names for Continuations, Parameters, etc.
368 * The names must match the conventions used by IR Hydra, e.g. 378 * The names must match the conventions used by IR Hydra, e.g.
369 * Continuations and Functions must have names of form B### since they 379 * Continuations and Functions must have names of form B### since they
370 * are visualized as basic blocks. 380 * are visualized as basic blocks.
371 */ 381 */
372 class Names { 382 class Names {
373 final Map<Object, String> names = {}; 383 final Map<Object, String> names = {};
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 visitConcatenateStrings(cps_ir.ConcatenateStrings exp) { 500 visitConcatenateStrings(cps_ir.ConcatenateStrings exp) {
491 addEdgeToContinuation(exp.continuation); 501 addEdgeToContinuation(exp.continuation);
492 } 502 }
493 503
494 visitThrow(cps_ir.Throw exp) { 504 visitThrow(cps_ir.Throw exp) {
495 } 505 }
496 506
497 visitRethrow(cps_ir.Rethrow exp) { 507 visitRethrow(cps_ir.Rethrow exp) {
498 } 508 }
499 509
510 visitUnreachable(cps_ir.Unreachable node) {
511 }
512
500 visitSetMutableVariable(cps_ir.SetMutableVariable exp) { 513 visitSetMutableVariable(cps_ir.SetMutableVariable exp) {
501 visit(exp.body); 514 visit(exp.body);
502 } 515 }
503 516
504 visitSetField(cps_ir.SetField exp) { 517 visitSetField(cps_ir.SetField exp) {
505 visit(exp.body); 518 visit(exp.body);
506 } 519 }
507 520
508 visitSetStatic(cps_ir.SetStatic exp) { 521 visitSetStatic(cps_ir.SetStatic exp) {
509 visit(exp.body); 522 visit(exp.body);
510 } 523 }
511 524
512 visitGetLazyStatic(cps_ir.GetLazyStatic exp) { 525 visitGetLazyStatic(cps_ir.GetLazyStatic exp) {
513 addEdgeToContinuation(exp.continuation); 526 addEdgeToContinuation(exp.continuation);
514 } 527 }
515 528
516 visitBranch(cps_ir.Branch exp) { 529 visitBranch(cps_ir.Branch exp) {
517 cps_ir.Continuation trueTarget = exp.trueContinuation.definition; 530 cps_ir.Continuation trueTarget = exp.trueContinuation.definition;
518 if (!trueTarget.isReturnContinuation) { 531 if (!trueTarget.isReturnContinuation) {
519 currentBlock.addEdgeTo(getBlock(trueTarget)); 532 currentBlock.addEdgeTo(getBlock(trueTarget));
520 } 533 }
521 cps_ir.Continuation falseTarget = exp.falseContinuation.definition; 534 cps_ir.Continuation falseTarget = exp.falseContinuation.definition;
522 if (!falseTarget.isReturnContinuation) { 535 if (!falseTarget.isReturnContinuation) {
523 currentBlock.addEdgeTo(getBlock(falseTarget)); 536 currentBlock.addEdgeTo(getBlock(falseTarget));
524 } 537 }
525 } 538 }
526 539
527 visitTypeOperator(cps_ir.TypeOperator exp) { 540 visitTypeCast(cps_ir.TypeCast exp) {
528 addEdgeToContinuation(exp.continuation); 541 addEdgeToContinuation(exp.continuation);
529 } 542 }
530 543
531 visitContinuation(cps_ir.Continuation c) { 544 visitContinuation(cps_ir.Continuation c) {
532 var old_node = currentBlock; 545 var old_node = currentBlock;
533 currentBlock = getBlock(c); 546 currentBlock = getBlock(c);
534 visit(c.body); 547 visit(c.body);
535 currentBlock = old_node; 548 currentBlock = old_node;
536 } 549 }
537 550
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
596 unexpectedNode(node); 609 unexpectedNode(node);
597 } 610 }
598 611
599 visitNonTailThrow(cps_ir.NonTailThrow node) { 612 visitNonTailThrow(cps_ir.NonTailThrow node) {
600 unexpectedNode(node); 613 unexpectedNode(node);
601 } 614 }
602 615
603 visitCreateInvocationMirror(cps_ir.CreateInvocationMirror node) { 616 visitCreateInvocationMirror(cps_ir.CreateInvocationMirror node) {
604 unexpectedNode(node); 617 unexpectedNode(node);
605 } 618 }
619
620 visitTypeTest(cps_ir.TypeTest node) {
621 unexpectedNode(node);
622 }
606 } 623 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/cps_ir/cps_ir_nodes_sexpr.dart ('k') | pkg/compiler/lib/src/cps_ir/shrinking_reductions.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698