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 hide Function; | 8 import 'cps_ir_nodes.dart' as cps_ir hide Function; |
9 import '../tracer.dart'; | 9 import '../tracer.dart'; |
10 | 10 |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 | 221 |
222 visitBranch(cps_ir.Branch node) { | 222 visitBranch(cps_ir.Branch node) { |
223 String dummy = names.name(node); | 223 String dummy = names.name(node); |
224 String condition = visit(node.condition); | 224 String condition = visit(node.condition); |
225 String trueCont = formatReference(node.trueContinuation); | 225 String trueCont = formatReference(node.trueContinuation); |
226 String falseCont = formatReference(node.falseContinuation); | 226 String falseCont = formatReference(node.falseContinuation); |
227 printStmt(dummy, "Branch $condition ($trueCont, $falseCont)"); | 227 printStmt(dummy, "Branch $condition ($trueCont, $falseCont)"); |
228 } | 228 } |
229 | 229 |
230 visitSetMutableVariable(cps_ir.SetMutableVariable node) { | 230 visitSetMutableVariable(cps_ir.SetMutableVariable node) { |
231 String dummy = names.name(node); | |
232 String variable = names.name(node.variable.definition); | 231 String variable = names.name(node.variable.definition); |
233 String value = formatReference(node.value); | 232 String value = formatReference(node.value); |
234 printStmt(dummy, 'SetMutableVariable $variable := $value'); | 233 return 'SetMutableVariable $variable := $value'; |
235 visit(node.body); | |
236 } | 234 } |
237 | 235 |
238 String formatReference(cps_ir.Reference ref) { | 236 String formatReference(cps_ir.Reference ref) { |
239 cps_ir.Definition target = ref.definition; | 237 cps_ir.Definition target = ref.definition; |
240 if (target is cps_ir.Continuation && target.isReturnContinuation) { | 238 if (target is cps_ir.Continuation && target.isReturnContinuation) { |
241 return "return"; // Do not generate a name for the return continuation | 239 return "return"; // Do not generate a name for the return continuation |
242 } else { | 240 } else { |
243 return names.name(ref.definition); | 241 return names.name(ref.definition); |
244 } | 242 } |
245 } | 243 } |
(...skipping 14 matching lines...) Expand all Loading... |
260 | 258 |
261 visitContinuation(cps_ir.Continuation node) { | 259 visitContinuation(cps_ir.Continuation node) { |
262 return "Continuation ${names.name(node)}"; | 260 return "Continuation ${names.name(node)}"; |
263 } | 261 } |
264 | 262 |
265 visitIsTrue(cps_ir.IsTrue node) { | 263 visitIsTrue(cps_ir.IsTrue node) { |
266 return "IsTrue(${names.name(node.value.definition)})"; | 264 return "IsTrue(${names.name(node.value.definition)})"; |
267 } | 265 } |
268 | 266 |
269 visitSetField(cps_ir.SetField node) { | 267 visitSetField(cps_ir.SetField node) { |
270 String dummy = names.name(node); | |
271 String object = formatReference(node.object); | 268 String object = formatReference(node.object); |
272 String field = node.field.name; | 269 String field = node.field.name; |
273 String value = formatReference(node.value); | 270 String value = formatReference(node.value); |
274 printStmt(dummy, 'SetField $object.$field = $value'); | 271 return 'SetField $object.$field = $value'; |
275 visit(node.body); | |
276 } | 272 } |
277 | 273 |
278 visitGetField(cps_ir.GetField node) { | 274 visitGetField(cps_ir.GetField node) { |
279 String object = formatReference(node.object); | 275 String object = formatReference(node.object); |
280 String field = node.field.name; | 276 String field = node.field.name; |
281 return 'GetField($object.$field)'; | 277 return 'GetField($object.$field)'; |
282 } | 278 } |
283 | 279 |
284 visitGetStatic(cps_ir.GetStatic node) { | 280 visitGetStatic(cps_ir.GetStatic node) { |
285 String element = node.element.name; | 281 String element = node.element.name; |
286 return 'GetStatic($element)'; | 282 return 'GetStatic($element)'; |
287 } | 283 } |
288 | 284 |
289 visitSetStatic(cps_ir.SetStatic node) { | 285 visitSetStatic(cps_ir.SetStatic node) { |
290 String dummy = names.name(node); | |
291 String element = node.element.name; | 286 String element = node.element.name; |
292 String value = formatReference(node.value); | 287 String value = formatReference(node.value); |
293 printStmt(dummy, 'SetStatic $element = $value'); | 288 return 'SetStatic $element = $value'; |
294 visit(node.body); | |
295 } | 289 } |
296 | 290 |
297 visitGetLazyStatic(cps_ir.GetLazyStatic node) { | 291 visitGetLazyStatic(cps_ir.GetLazyStatic node) { |
298 String dummy = names.name(node); | 292 String dummy = names.name(node); |
299 String kont = formatReference(node.continuation); | 293 String kont = formatReference(node.continuation); |
300 printStmt(dummy, "GetLazyStatic $kont"); | 294 printStmt(dummy, "GetLazyStatic $kont"); |
301 } | 295 } |
302 | 296 |
303 visitCreateBox(cps_ir.CreateBox node) { | 297 visitCreateBox(cps_ir.CreateBox node) { |
304 return 'CreateBox'; | 298 return 'CreateBox'; |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
516 | 510 |
517 visitThrow(cps_ir.Throw exp) { | 511 visitThrow(cps_ir.Throw exp) { |
518 } | 512 } |
519 | 513 |
520 visitRethrow(cps_ir.Rethrow exp) { | 514 visitRethrow(cps_ir.Rethrow exp) { |
521 } | 515 } |
522 | 516 |
523 visitUnreachable(cps_ir.Unreachable node) { | 517 visitUnreachable(cps_ir.Unreachable node) { |
524 } | 518 } |
525 | 519 |
526 visitSetMutableVariable(cps_ir.SetMutableVariable exp) { | |
527 visit(exp.body); | |
528 } | |
529 | |
530 visitSetField(cps_ir.SetField exp) { | |
531 visit(exp.body); | |
532 } | |
533 | |
534 visitSetStatic(cps_ir.SetStatic exp) { | |
535 visit(exp.body); | |
536 } | |
537 | |
538 visitGetLazyStatic(cps_ir.GetLazyStatic exp) { | 520 visitGetLazyStatic(cps_ir.GetLazyStatic exp) { |
539 addEdgeToContinuation(exp.continuation); | 521 addEdgeToContinuation(exp.continuation); |
540 } | 522 } |
541 | 523 |
542 visitBranch(cps_ir.Branch exp) { | 524 visitBranch(cps_ir.Branch exp) { |
543 cps_ir.Continuation trueTarget = exp.trueContinuation.definition; | 525 cps_ir.Continuation trueTarget = exp.trueContinuation.definition; |
544 if (!trueTarget.isReturnContinuation) { | 526 if (!trueTarget.isReturnContinuation) { |
545 currentBlock.addEdgeTo(getBlock(trueTarget)); | 527 currentBlock.addEdgeTo(getBlock(trueTarget)); |
546 } | 528 } |
547 cps_ir.Continuation falseTarget = exp.falseContinuation.definition; | 529 cps_ir.Continuation falseTarget = exp.falseContinuation.definition; |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
652 } | 634 } |
653 | 635 |
654 visitGetIndex(cps_ir.GetIndex node) { | 636 visitGetIndex(cps_ir.GetIndex node) { |
655 unexpectedNode(node); | 637 unexpectedNode(node); |
656 } | 638 } |
657 | 639 |
658 visitSetIndex(cps_ir.SetIndex node) { | 640 visitSetIndex(cps_ir.SetIndex node) { |
659 unexpectedNode(node); | 641 unexpectedNode(node); |
660 } | 642 } |
661 | 643 |
| 644 visitSetMutableVariable(cps_ir.SetMutableVariable node) { |
| 645 unexpectedNode(node); |
| 646 } |
| 647 |
| 648 visitSetField(cps_ir.SetField node) { |
| 649 unexpectedNode(node); |
| 650 } |
| 651 |
| 652 visitSetStatic(cps_ir.SetStatic node) { |
| 653 unexpectedNode(node); |
| 654 } |
| 655 |
662 @override | 656 @override |
663 visitForeignCode(cps_ir.ForeignCode node) { | 657 visitForeignCode(cps_ir.ForeignCode node) { |
664 if (node.continuation != null) { | 658 if (node.continuation != null) { |
665 addEdgeToContinuation(node.continuation); | 659 addEdgeToContinuation(node.continuation); |
666 } | 660 } |
667 } | 661 } |
668 } | 662 } |
OLD | NEW |