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 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
370 String value = formatReference(node.value); | 370 String value = formatReference(node.value); |
371 String args = node.typeArguments.map(formatReference).join(', '); | 371 String args = node.typeArguments.map(formatReference).join(', '); |
372 return "TypeTest ($value ${node.type} ($args))"; | 372 return "TypeTest ($value ${node.type} ($args))"; |
373 } | 373 } |
374 | 374 |
375 visitApplyBuiltinOperator(cps_ir.ApplyBuiltinOperator node) { | 375 visitApplyBuiltinOperator(cps_ir.ApplyBuiltinOperator node) { |
376 String operator = node.operator.toString(); | 376 String operator = node.operator.toString(); |
377 String args = node.arguments.map(formatReference).join(', '); | 377 String args = node.arguments.map(formatReference).join(', '); |
378 return 'ApplyBuiltinOperator $operator ($args)'; | 378 return 'ApplyBuiltinOperator $operator ($args)'; |
379 } | 379 } |
380 | |
381 @override | |
382 visitForeignCode(cps_ir.ForeignCode node) { | |
383 String id = names.name(node); | |
384 String arguments = node.arguments.map(formatReference).join(', '); | |
385 String continuation = node.continuation == null ? '' | |
386 : ' ${formatReference(node.continuation)}'; | |
387 printStmt(id, "ForeignCode ${node.type} ${node.codeTemplate} $arguments" | |
388 "$continuation"); | |
389 } | |
390 } | 380 } |
391 | 381 |
392 /** | 382 /** |
393 * Invents (and remembers) names for Continuations, Parameters, etc. | 383 * Invents (and remembers) names for Continuations, Parameters, etc. |
394 * The names must match the conventions used by IR Hydra, e.g. | 384 * The names must match the conventions used by IR Hydra, e.g. |
395 * Continuations and Functions must have names of form B### since they | 385 * Continuations and Functions must have names of form B### since they |
396 * are visualized as basic blocks. | 386 * are visualized as basic blocks. |
397 */ | 387 */ |
398 class Names { | 388 class Names { |
399 final Map<Object, String> names = {}; | 389 final Map<Object, String> names = {}; |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
566 | 556 |
567 // Primitives and conditions are not visited when searching for blocks. | 557 // Primitives and conditions are not visited when searching for blocks. |
568 unexpectedNode(cps_ir.Node node) { | 558 unexpectedNode(cps_ir.Node node) { |
569 throw "The IR tracer's block collector reached an unexpected IR " | 559 throw "The IR tracer's block collector reached an unexpected IR " |
570 "instruction: $node"; | 560 "instruction: $node"; |
571 } | 561 } |
572 | 562 |
573 visitLiteralList(cps_ir.LiteralList node) { | 563 visitLiteralList(cps_ir.LiteralList node) { |
574 unexpectedNode(node); | 564 unexpectedNode(node); |
575 } | 565 } |
576 | |
577 visitLiteralMap(cps_ir.LiteralMap node) { | 566 visitLiteralMap(cps_ir.LiteralMap node) { |
578 unexpectedNode(node); | 567 unexpectedNode(node); |
579 } | 568 } |
580 | |
581 visitConstant(cps_ir.Constant node) { | 569 visitConstant(cps_ir.Constant node) { |
582 unexpectedNode(node); | 570 unexpectedNode(node); |
583 } | 571 } |
584 | |
585 visitCreateFunction(cps_ir.CreateFunction node) { | 572 visitCreateFunction(cps_ir.CreateFunction node) { |
586 unexpectedNode(node); | 573 unexpectedNode(node); |
587 } | 574 } |
588 | |
589 visitGetMutableVariable(cps_ir.GetMutableVariable node) { | 575 visitGetMutableVariable(cps_ir.GetMutableVariable node) { |
590 unexpectedNode(node); | 576 unexpectedNode(node); |
591 } | 577 } |
592 | |
593 visitParameter(cps_ir.Parameter node) { | 578 visitParameter(cps_ir.Parameter node) { |
594 unexpectedNode(node); | 579 unexpectedNode(node); |
595 } | 580 } |
596 | |
597 visitMutableVariable(cps_ir.MutableVariable node) { | 581 visitMutableVariable(cps_ir.MutableVariable node) { |
598 unexpectedNode(node); | 582 unexpectedNode(node); |
599 } | 583 } |
600 | |
601 visitGetField(cps_ir.GetField node) { | 584 visitGetField(cps_ir.GetField node) { |
602 unexpectedNode(node); | 585 unexpectedNode(node); |
603 } | 586 } |
604 | |
605 visitGetStatic(cps_ir.GetStatic node) { | 587 visitGetStatic(cps_ir.GetStatic node) { |
606 unexpectedNode(node); | 588 unexpectedNode(node); |
607 } | 589 } |
608 | |
609 visitCreateBox(cps_ir.CreateBox node) { | 590 visitCreateBox(cps_ir.CreateBox node) { |
610 unexpectedNode(node); | 591 unexpectedNode(node); |
611 } | 592 } |
612 | |
613 visitCreateInstance(cps_ir.CreateInstance node) { | 593 visitCreateInstance(cps_ir.CreateInstance node) { |
614 unexpectedNode(node); | 594 unexpectedNode(node); |
615 } | 595 } |
616 | |
617 visitIsTrue(cps_ir.IsTrue node) { | 596 visitIsTrue(cps_ir.IsTrue node) { |
618 unexpectedNode(node); | 597 unexpectedNode(node); |
619 } | 598 } |
620 | |
621 visitIdentical(cps_ir.Identical node) { | 599 visitIdentical(cps_ir.Identical node) { |
622 unexpectedNode(node); | 600 unexpectedNode(node); |
623 } | 601 } |
624 | |
625 visitInterceptor(cps_ir.Interceptor node) { | 602 visitInterceptor(cps_ir.Interceptor node) { |
626 unexpectedNode(node); | 603 unexpectedNode(node); |
627 } | 604 } |
628 | |
629 visitReadTypeVariable(cps_ir.ReadTypeVariable node) { | 605 visitReadTypeVariable(cps_ir.ReadTypeVariable node) { |
630 unexpectedNode(node); | 606 unexpectedNode(node); |
631 } | 607 } |
632 | |
633 visitReifyRuntimeType(cps_ir.ReifyRuntimeType node) { | 608 visitReifyRuntimeType(cps_ir.ReifyRuntimeType node) { |
634 unexpectedNode(node); | 609 unexpectedNode(node); |
635 } | 610 } |
636 | |
637 visitTypeExpression(cps_ir.TypeExpression node) { | 611 visitTypeExpression(cps_ir.TypeExpression node) { |
638 unexpectedNode(node); | 612 unexpectedNode(node); |
639 } | 613 } |
640 | |
641 visitNonTailThrow(cps_ir.NonTailThrow node) { | 614 visitNonTailThrow(cps_ir.NonTailThrow node) { |
642 unexpectedNode(node); | 615 unexpectedNode(node); |
643 } | 616 } |
644 | |
645 visitCreateInvocationMirror(cps_ir.CreateInvocationMirror node) { | 617 visitCreateInvocationMirror(cps_ir.CreateInvocationMirror node) { |
646 unexpectedNode(node); | 618 unexpectedNode(node); |
647 } | 619 } |
648 | |
649 visitTypeTest(cps_ir.TypeTest node) { | 620 visitTypeTest(cps_ir.TypeTest node) { |
650 unexpectedNode(node); | 621 unexpectedNode(node); |
651 } | 622 } |
652 | |
653 visitApplyBuiltinOperator(cps_ir.ApplyBuiltinOperator node) { | 623 visitApplyBuiltinOperator(cps_ir.ApplyBuiltinOperator node) { |
654 unexpectedNode(node); | 624 unexpectedNode(node); |
655 } | 625 } |
656 | |
657 @override | |
658 visitForeignCode(cps_ir.ForeignCode node) { | |
659 if (node.continuation != null) { | |
660 addEdgeToContinuation(node.continuation); | |
661 } | |
662 } | |
663 } | 626 } |
OLD | NEW |