| OLD | NEW |
| 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; | 8 import 'cps_ir_nodes.dart' as cps_ir; |
| 9 import '../tracer.dart'; | 9 import '../tracer.dart'; |
| 10 | 10 |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 return '$name $value'; | 235 return '$name $value'; |
| 236 } | 236 } |
| 237 | 237 |
| 238 visitSetMutable(cps_ir.SetMutable node) { | 238 visitSetMutable(cps_ir.SetMutable node) { |
| 239 String variable = names.name(node.variable.definition); | 239 String variable = names.name(node.variable.definition); |
| 240 String value = formatReference(node.value); | 240 String value = formatReference(node.value); |
| 241 return 'SetMutable $variable := $value'; | 241 return 'SetMutable $variable := $value'; |
| 242 } | 242 } |
| 243 | 243 |
| 244 String formatReference(cps_ir.Reference ref) { | 244 String formatReference(cps_ir.Reference ref) { |
| 245 if (ref == null) return 'null'; |
| 245 cps_ir.Definition target = ref.definition; | 246 cps_ir.Definition target = ref.definition; |
| 246 if (target is cps_ir.Continuation && target.isReturnContinuation) { | 247 if (target is cps_ir.Continuation && target.isReturnContinuation) { |
| 247 return "return"; // Do not generate a name for the return continuation | 248 return "return"; // Do not generate a name for the return continuation |
| 248 } else { | 249 } else { |
| 249 return names.name(ref.definition); | 250 return names.name(ref.definition); |
| 250 } | 251 } |
| 251 } | 252 } |
| 252 | 253 |
| 253 visitConstant(cps_ir.Constant node) { | 254 visitConstant(cps_ir.Constant node) { |
| 254 return "Constant ${node.value.toStructuredString()}"; | 255 return "Constant ${node.value.toStructuredString()}"; |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 382 String object = formatReference(node.object); | 383 String object = formatReference(node.object); |
| 383 String index = formatReference(node.index); | 384 String index = formatReference(node.index); |
| 384 String value = formatReference(node.value); | 385 String value = formatReference(node.value); |
| 385 return 'SetIndex $object $index $value'; | 386 return 'SetIndex $object $index $value'; |
| 386 } | 387 } |
| 387 | 388 |
| 388 visitRefinement(cps_ir.Refinement node) { | 389 visitRefinement(cps_ir.Refinement node) { |
| 389 String value = formatReference(node.value); | 390 String value = formatReference(node.value); |
| 390 return 'Refinement $value ${node.refineType}'; | 391 return 'Refinement $value ${node.refineType}'; |
| 391 } | 392 } |
| 393 |
| 394 visitNullCheck(cps_ir.NullCheck node) { |
| 395 String value = formatReference(node.value); |
| 396 String condition = formatReference(node.condition); |
| 397 return 'NullCheck $value condition:$condition selector:${node.selector}'; |
| 398 } |
| 392 } | 399 } |
| 393 | 400 |
| 394 /** | 401 /** |
| 395 * Invents (and remembers) names for Continuations, Parameters, etc. | 402 * Invents (and remembers) names for Continuations, Parameters, etc. |
| 396 * The names must match the conventions used by IR Hydra, e.g. | 403 * The names must match the conventions used by IR Hydra, e.g. |
| 397 * Continuations and Functions must have names of form B### since they | 404 * Continuations and Functions must have names of form B### since they |
| 398 * are visualized as basic blocks. | 405 * are visualized as basic blocks. |
| 399 */ | 406 */ |
| 400 class Names { | 407 class Names { |
| 401 final Map<Object, String> names = {}; | 408 final Map<Object, String> names = {}; |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 664 unexpectedNode(node); | 671 unexpectedNode(node); |
| 665 } | 672 } |
| 666 | 673 |
| 667 visitYield(cps_ir.Yield node) { | 674 visitYield(cps_ir.Yield node) { |
| 668 unexpectedNode(node); | 675 unexpectedNode(node); |
| 669 } | 676 } |
| 670 | 677 |
| 671 visitRefinement(cps_ir.Refinement node) { | 678 visitRefinement(cps_ir.Refinement node) { |
| 672 unexpectedNode(node); | 679 unexpectedNode(node); |
| 673 } | 680 } |
| 681 |
| 682 visitNullCheck(cps_ir.NullCheck node) { |
| 683 unexpectedNode(node); |
| 684 } |
| 674 } | 685 } |
| OLD | NEW |