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

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

Issue 869223003: Revert "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
636 // from the parent.
637 int parent_index;
638
639 accept(Visitor visitor) => visitor.visitParameter(this); 633 accept(Visitor visitor) => visitor.visitParameter(this);
640 } 634 }
641 635
642 /// Continuations are normally bound by 'let cont'. A continuation with one 636 /// Continuations are normally bound by 'let cont'. A continuation with one
643 /// parameter and no body is used to represent a function's return continuation. 637 /// parameter and no body is used to represent a function's return continuation.
644 /// The return continuation is bound by the Function, not by 'let cont'. 638 /// The return continuation is bound by the Function, not by 'let cont'.
645 class Continuation extends Definition<Continuation> implements InteriorNode { 639 class Continuation extends Definition<Continuation> implements InteriorNode {
646 final List<Parameter> parameters; 640 final List<Parameter> parameters;
647 Expression body = null; 641 Expression body = null;
648 642
(...skipping 30 matching lines...) Expand all
679 FieldDefinition(this.element, this.body); 673 FieldDefinition(this.element, this.body);
680 674
681 FieldDefinition.withoutInitializer(this.element) 675 FieldDefinition.withoutInitializer(this.element)
682 : this.body = null; 676 : this.body = null;
683 677
684 accept(Visitor visitor) => visitor.visitFieldDefinition(this); 678 accept(Visitor visitor) => visitor.visitFieldDefinition(this);
685 applyPass(Pass pass) => pass.rewriteFieldDefinition(this); 679 applyPass(Pass pass) => pass.rewriteFieldDefinition(this);
686 680
687 /// `true` if this field has no initializer. 681 /// `true` if this field has no initializer.
688 /// 682 ///
689 /// If `true` [body] is `null`. 683 /// If `true` [body] and [returnContinuation] are `null`.
690 /// 684 ///
691 /// This is different from a initializer that is `null`. Consider this class: 685 /// This is different from a initializer that is `null`. Consider this class:
692 /// 686 ///
693 /// class Class { 687 /// class Class {
694 /// final field; 688 /// final field;
695 /// Class.a(this.field); 689 /// Class.a(this.field);
696 /// Class.b() : this.field = null; 690 /// Class.b() : this.field = null;
697 /// Class.c(); 691 /// Class.c();
698 /// } 692 /// }
699 /// 693 ///
(...skipping 16 matching lines...) Expand all
716 } 710 }
717 711
718 class RunnableBody extends InteriorNode { 712 class RunnableBody extends InteriorNode {
719 Expression body; 713 Expression body;
720 final Continuation returnContinuation; 714 final Continuation returnContinuation;
721 RunnableBody(this.body, this.returnContinuation); 715 RunnableBody(this.body, this.returnContinuation);
722 accept(Visitor visitor) => visitor.visitRunnableBody(this); 716 accept(Visitor visitor) => visitor.visitRunnableBody(this);
723 } 717 }
724 718
725 /// A function definition, consisting of parameters and a body. The parameters 719 /// A function definition, consisting of parameters and a body. The parameters
726 /// include a distinguished continuation parameter (held by the body). 720 /// include a distinguished continuation parameter.
727 class FunctionDefinition extends Node 721 class FunctionDefinition extends Node
728 implements ExecutableDefinition { 722 implements ExecutableDefinition {
729 final FunctionElement element; 723 final FunctionElement element;
730 /// Mixed list of [Parameter]s and [ClosureVariable]s. 724 /// Mixed list of [Parameter]s and [ClosureVariable]s.
731 final List<Definition> parameters; 725 final List<Definition> parameters;
732 final RunnableBody body; 726 final RunnableBody body;
733 final List<ConstDeclaration> localConstants; 727 final List<ConstDeclaration> localConstants;
734 728
735 /// Values for optional parameters. 729 /// Values for optional parameters.
736 final List<ConstantExpression> defaultParameterValues; 730 final List<ConstantExpression> defaultParameterValues;
(...skipping 13 matching lines...) Expand all
750 this.defaultParameterValues) 744 this.defaultParameterValues)
751 : body = null, 745 : body = null,
752 localConstants = const <ConstDeclaration>[], 746 localConstants = const <ConstDeclaration>[],
753 closureVariables = const <ClosureVariable>[]; 747 closureVariables = const <ClosureVariable>[];
754 748
755 accept(Visitor visitor) => visitor.visitFunctionDefinition(this); 749 accept(Visitor visitor) => visitor.visitFunctionDefinition(this);
756 applyPass(Pass pass) => pass.rewriteFunctionDefinition(this); 750 applyPass(Pass pass) => pass.rewriteFunctionDefinition(this);
757 751
758 /// Returns `true` if this function is abstract or external. 752 /// Returns `true` if this function is abstract or external.
759 /// 753 ///
760 /// If `true`, [body] is `null` and [localConstants] is empty. 754 /// If `true`, [body] and [returnContinuation] are `null` and [localConstants]
755 /// is empty.
761 bool get isAbstract => body == null; 756 bool get isAbstract => body == null;
762 } 757 }
763 758
764 abstract class Initializer extends Node {} 759 abstract class Initializer extends Node {}
765 760
766 class FieldInitializer extends Initializer { 761 class FieldInitializer extends Initializer {
767 final FieldElement element; 762 final FieldElement element;
768 final RunnableBody body; 763 final RunnableBody body;
769 764
770 FieldInitializer(this.element, this.body); 765 FieldInitializer(this.element, this.body);
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
882 // while leaving other nodes for subclasses (i.e., visitLiteralList). 877 // while leaving other nodes for subclasses (i.e., visitLiteralList).
883 visitNode(Node node) { 878 visitNode(Node node) {
884 throw "$this is stale, add missing visit override for $node"; 879 throw "$this is stale, add missing visit override for $node";
885 } 880 }
886 881
887 processReference(Reference ref) {} 882 processReference(Reference ref) {}
888 883
889 processRunnableBody(RunnableBody node) {} 884 processRunnableBody(RunnableBody node) {}
890 visitRunnableBody(RunnableBody node) { 885 visitRunnableBody(RunnableBody node) {
891 processRunnableBody(node); 886 processRunnableBody(node);
892 visit(node.returnContinuation);
893 visit(node.body); 887 visit(node.body);
894 } 888 }
895 889
896 processFieldDefinition(FieldDefinition node) {} 890 processFieldDefinition(FieldDefinition node) {}
897 visitFieldDefinition(FieldDefinition node) { 891 visitFieldDefinition(FieldDefinition node) {
898 processFieldDefinition(node); 892 processFieldDefinition(node);
899 if (node.hasInitializer) { 893 if (node.hasInitializer) {
900 visit(node.body); 894 visit(node.body);
901 } 895 }
902 } 896 }
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
1062 processGetClosureVariable(node); 1056 processGetClosureVariable(node);
1063 } 1057 }
1064 1058
1065 processParameter(Parameter node) {} 1059 processParameter(Parameter node) {}
1066 visitParameter(Parameter node) => processParameter(node); 1060 visitParameter(Parameter node) => processParameter(node);
1067 1061
1068 processContinuation(Continuation node) {} 1062 processContinuation(Continuation node) {}
1069 visitContinuation(Continuation node) { 1063 visitContinuation(Continuation node) {
1070 processContinuation(node); 1064 processContinuation(node);
1071 node.parameters.forEach(visitParameter); 1065 node.parameters.forEach(visitParameter);
1072 if (node.body != null) visit(node.body); 1066 visit(node.body);
1073 } 1067 }
1074 1068
1075 // Conditions. 1069 // Conditions.
1076 1070
1077 processIsTrue(IsTrue node) {} 1071 processIsTrue(IsTrue node) {}
1078 visitIsTrue(IsTrue node) { 1072 visitIsTrue(IsTrue node) {
1079 processIsTrue(node); 1073 processIsTrue(node);
1080 processReference(node.value); 1074 processReference(node.value);
1081 } 1075 }
1082 1076
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
1342 1336
1343 void visitIdentical(Identical node) { 1337 void visitIdentical(Identical node) {
1344 visitReference(node.left); 1338 visitReference(node.left);
1345 visitReference(node.right); 1339 visitReference(node.right);
1346 } 1340 }
1347 1341
1348 void visitInterceptor(Interceptor node) { 1342 void visitInterceptor(Interceptor node) {
1349 visitReference(node.input); 1343 visitReference(node.input);
1350 } 1344 }
1351 } 1345 }
OLDNEW
« no previous file with comments | « pkg/analyzer2dart/test/sexpr_data.dart ('k') | pkg/compiler/lib/src/cps_ir/cps_ir_nodes_sexpr.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698