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

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

Issue 864293004: Add a shrinking reduction for dead continuation parameters. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 11 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 // IrNodes are kept in a separate library to have precise control over their 5 // IrNodes are kept in a separate library to have precise control over their
6 // dependencies on other parts of the system. 6 // dependencies on other parts of the system.
7 library dart2js.ir_nodes; 7 library dart2js.ir_nodes;
8 8
9 import '../constants/expressions.dart'; 9 import '../constants/expressions.dart';
10 import '../constants/values.dart' as values show ConstantValue; 10 import '../constants/values.dart' as values show ConstantValue;
(...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after
623 CreateFunction(this.definition); 623 CreateFunction(this.definition);
624 624
625 accept(Visitor visitor) => visitor.visitCreateFunction(this); 625 accept(Visitor visitor) => visitor.visitCreateFunction(this);
626 } 626 }
627 627
628 class Parameter extends Primitive { 628 class Parameter extends Primitive {
629 Parameter(Entity hint) { 629 Parameter(Entity hint) {
630 super.hint = hint; 630 super.hint = hint;
631 } 631 }
632 632
633 // In addition to a parent pointer to the containing Continuation or
634 // FunctionDefinition, parameters have an index into the list of parameters
635 // bound by the parent. This gives constant-time access to the continuation f rom
asgerf 2015/01/22 16:02:07 long line
Kevin Millikin (Google) 2015/01/22 16:16:28 You are right. Fixed.
636 // the parent.
637 int parent_index;
638
633 accept(Visitor visitor) => visitor.visitParameter(this); 639 accept(Visitor visitor) => visitor.visitParameter(this);
634 } 640 }
635 641
636 /// Continuations are normally bound by 'let cont'. A continuation with one 642 /// Continuations are normally bound by 'let cont'. A continuation with one
637 /// parameter and no body is used to represent a function's return continuation. 643 /// parameter and no body is used to represent a function's return continuation.
638 /// The return continuation is bound by the Function, not by 'let cont'. 644 /// The return continuation is bound by the Function, not by 'let cont'.
639 class Continuation extends Definition<Continuation> implements InteriorNode { 645 class Continuation extends Definition<Continuation> implements InteriorNode {
640 final List<Parameter> parameters; 646 final List<Parameter> parameters;
641 Expression body = null; 647 Expression body = null;
642 648
(...skipping 30 matching lines...) Expand all
673 FieldDefinition(this.element, this.body); 679 FieldDefinition(this.element, this.body);
674 680
675 FieldDefinition.withoutInitializer(this.element) 681 FieldDefinition.withoutInitializer(this.element)
676 : this.body = null; 682 : this.body = null;
677 683
678 accept(Visitor visitor) => visitor.visitFieldDefinition(this); 684 accept(Visitor visitor) => visitor.visitFieldDefinition(this);
679 applyPass(Pass pass) => pass.rewriteFieldDefinition(this); 685 applyPass(Pass pass) => pass.rewriteFieldDefinition(this);
680 686
681 /// `true` if this field has no initializer. 687 /// `true` if this field has no initializer.
682 /// 688 ///
683 /// If `true` [body] and [returnContinuation] are `null`. 689 /// If `true` [body] is `null`.
684 /// 690 ///
685 /// This is different from a initializer that is `null`. Consider this class: 691 /// This is different from a initializer that is `null`. Consider this class:
686 /// 692 ///
687 /// class Class { 693 /// class Class {
688 /// final field; 694 /// final field;
689 /// Class.a(this.field); 695 /// Class.a(this.field);
690 /// Class.b() : this.field = null; 696 /// Class.b() : this.field = null;
691 /// Class.c(); 697 /// Class.c();
692 /// } 698 /// }
693 /// 699 ///
(...skipping 16 matching lines...) Expand all
710 } 716 }
711 717
712 class RunnableBody extends InteriorNode { 718 class RunnableBody extends InteriorNode {
713 Expression body; 719 Expression body;
714 final Continuation returnContinuation; 720 final Continuation returnContinuation;
715 RunnableBody(this.body, this.returnContinuation); 721 RunnableBody(this.body, this.returnContinuation);
716 accept(Visitor visitor) => visitor.visitRunnableBody(this); 722 accept(Visitor visitor) => visitor.visitRunnableBody(this);
717 } 723 }
718 724
719 /// A function definition, consisting of parameters and a body. The parameters 725 /// A function definition, consisting of parameters and a body. The parameters
720 /// include a distinguished continuation parameter. 726 /// include a distinguished continuation parameter (held by the body).
721 class FunctionDefinition extends Node 727 class FunctionDefinition extends Node
722 implements ExecutableDefinition { 728 implements ExecutableDefinition {
723 final FunctionElement element; 729 final FunctionElement element;
724 /// Mixed list of [Parameter]s and [ClosureVariable]s. 730 /// Mixed list of [Parameter]s and [ClosureVariable]s.
725 final List<Definition> parameters; 731 final List<Definition> parameters;
726 final RunnableBody body; 732 final RunnableBody body;
727 final List<ConstDeclaration> localConstants; 733 final List<ConstDeclaration> localConstants;
728 734
729 /// Values for optional parameters. 735 /// Values for optional parameters.
730 final List<ConstantExpression> defaultParameterValues; 736 final List<ConstantExpression> defaultParameterValues;
(...skipping 13 matching lines...) Expand all
744 this.defaultParameterValues) 750 this.defaultParameterValues)
745 : body = null, 751 : body = null,
746 localConstants = const <ConstDeclaration>[], 752 localConstants = const <ConstDeclaration>[],
747 closureVariables = const <ClosureVariable>[]; 753 closureVariables = const <ClosureVariable>[];
748 754
749 accept(Visitor visitor) => visitor.visitFunctionDefinition(this); 755 accept(Visitor visitor) => visitor.visitFunctionDefinition(this);
750 applyPass(Pass pass) => pass.rewriteFunctionDefinition(this); 756 applyPass(Pass pass) => pass.rewriteFunctionDefinition(this);
751 757
752 /// Returns `true` if this function is abstract or external. 758 /// Returns `true` if this function is abstract or external.
753 /// 759 ///
754 /// If `true`, [body] and [returnContinuation] are `null` and [localConstants] 760 /// If `true`, [body] is `null` and [localConstants] is empty.
755 /// is empty.
756 bool get isAbstract => body == null; 761 bool get isAbstract => body == null;
757 } 762 }
758 763
759 abstract class Initializer extends Node {} 764 abstract class Initializer extends Node {}
760 765
761 class FieldInitializer extends Initializer { 766 class FieldInitializer extends Initializer {
762 final FieldElement element; 767 final FieldElement element;
763 final RunnableBody body; 768 final RunnableBody body;
764 769
765 FieldInitializer(this.element, this.body); 770 FieldInitializer(this.element, this.body);
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
877 // while leaving other nodes for subclasses (i.e., visitLiteralList). 882 // while leaving other nodes for subclasses (i.e., visitLiteralList).
878 visitNode(Node node) { 883 visitNode(Node node) {
879 throw "$this is stale, add missing visit override for $node"; 884 throw "$this is stale, add missing visit override for $node";
880 } 885 }
881 886
882 processReference(Reference ref) {} 887 processReference(Reference ref) {}
883 888
884 processRunnableBody(RunnableBody node) {} 889 processRunnableBody(RunnableBody node) {}
885 visitRunnableBody(RunnableBody node) { 890 visitRunnableBody(RunnableBody node) {
886 processRunnableBody(node); 891 processRunnableBody(node);
892 visit(node.returnContinuation);
887 visit(node.body); 893 visit(node.body);
888 } 894 }
889 895
890 processFieldDefinition(FieldDefinition node) {} 896 processFieldDefinition(FieldDefinition node) {}
891 visitFieldDefinition(FieldDefinition node) { 897 visitFieldDefinition(FieldDefinition node) {
892 processFieldDefinition(node); 898 processFieldDefinition(node);
893 if (node.hasInitializer) { 899 if (node.hasInitializer) {
894 visit(node.body); 900 visit(node.body);
895 } 901 }
896 } 902 }
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
1056 processGetClosureVariable(node); 1062 processGetClosureVariable(node);
1057 } 1063 }
1058 1064
1059 processParameter(Parameter node) {} 1065 processParameter(Parameter node) {}
1060 visitParameter(Parameter node) => processParameter(node); 1066 visitParameter(Parameter node) => processParameter(node);
1061 1067
1062 processContinuation(Continuation node) {} 1068 processContinuation(Continuation node) {}
1063 visitContinuation(Continuation node) { 1069 visitContinuation(Continuation node) {
1064 processContinuation(node); 1070 processContinuation(node);
1065 node.parameters.forEach(visitParameter); 1071 node.parameters.forEach(visitParameter);
1066 visit(node.body); 1072 if (node.body != null) visit(node.body);
1067 } 1073 }
1068 1074
1069 // Conditions. 1075 // Conditions.
1070 1076
1071 processIsTrue(IsTrue node) {} 1077 processIsTrue(IsTrue node) {}
1072 visitIsTrue(IsTrue node) { 1078 visitIsTrue(IsTrue node) {
1073 processIsTrue(node); 1079 processIsTrue(node);
1074 processReference(node.value); 1080 processReference(node.value);
1075 } 1081 }
1076 1082
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
1336 1342
1337 void visitIdentical(Identical node) { 1343 void visitIdentical(Identical node) {
1338 visitReference(node.left); 1344 visitReference(node.left);
1339 visitReference(node.right); 1345 visitReference(node.right);
1340 } 1346 }
1341 1347
1342 void visitInterceptor(Interceptor node) { 1348 void visitInterceptor(Interceptor node) {
1343 visitReference(node.input); 1349 visitReference(node.input);
1344 } 1350 }
1345 } 1351 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698