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

Side by Side Diff: src/ast.h

Issue 717923003: Remove dead AST code in For and While statements (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 1 month 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_AST_H_ 5 #ifndef V8_AST_H_
6 #define V8_AST_H_ 6 #define V8_AST_H_
7 7
8 #include "src/v8.h" 8 #include "src/v8.h"
9 9
10 #include "src/assembler.h" 10 #include "src/assembler.h"
(...skipping 811 matching lines...) Expand 10 before | Expand all | Expand 10 after
822 class WhileStatement FINAL : public IterationStatement { 822 class WhileStatement FINAL : public IterationStatement {
823 public: 823 public:
824 DECLARE_NODE_TYPE(WhileStatement) 824 DECLARE_NODE_TYPE(WhileStatement)
825 825
826 void Initialize(Expression* cond, Statement* body) { 826 void Initialize(Expression* cond, Statement* body) {
827 IterationStatement::Initialize(body); 827 IterationStatement::Initialize(body);
828 cond_ = cond; 828 cond_ = cond;
829 } 829 }
830 830
831 Expression* cond() const { return cond_; } 831 Expression* cond() const { return cond_; }
832 bool may_have_function_literal() const {
833 return may_have_function_literal_;
834 }
835 void set_may_have_function_literal(bool value) {
836 may_have_function_literal_ = value;
837 }
838 832
839 static int num_ids() { return parent_num_ids() + 1; } 833 static int num_ids() { return parent_num_ids() + 1; }
840 virtual BailoutId ContinueId() const OVERRIDE { return EntryId(); } 834 virtual BailoutId ContinueId() const OVERRIDE { return EntryId(); }
841 virtual BailoutId StackCheckId() const OVERRIDE { return BodyId(); } 835 virtual BailoutId StackCheckId() const OVERRIDE { return BodyId(); }
842 BailoutId BodyId() const { return BailoutId(local_id(0)); } 836 BailoutId BodyId() const { return BailoutId(local_id(0)); }
843 837
844 protected: 838 protected:
845 WhileStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos) 839 WhileStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos)
846 : IterationStatement(zone, labels, pos), 840 : IterationStatement(zone, labels, pos), cond_(NULL) {}
847 cond_(NULL),
848 may_have_function_literal_(true) {}
849 static int parent_num_ids() { return IterationStatement::num_ids(); } 841 static int parent_num_ids() { return IterationStatement::num_ids(); }
850 842
851 private: 843 private:
852 int local_id(int n) const { return base_id() + parent_num_ids() + n; } 844 int local_id(int n) const { return base_id() + parent_num_ids() + n; }
853 845
854 Expression* cond_; 846 Expression* cond_;
855
856 // True if there is a function literal subexpression in the condition.
857 bool may_have_function_literal_;
858 }; 847 };
859 848
860 849
861 class ForStatement FINAL : public IterationStatement { 850 class ForStatement FINAL : public IterationStatement {
862 public: 851 public:
863 DECLARE_NODE_TYPE(ForStatement) 852 DECLARE_NODE_TYPE(ForStatement)
864 853
865 void Initialize(Statement* init, 854 void Initialize(Statement* init,
866 Expression* cond, 855 Expression* cond,
867 Statement* next, 856 Statement* next,
868 Statement* body) { 857 Statement* body) {
869 IterationStatement::Initialize(body); 858 IterationStatement::Initialize(body);
870 init_ = init; 859 init_ = init;
871 cond_ = cond; 860 cond_ = cond;
872 next_ = next; 861 next_ = next;
873 } 862 }
874 863
875 Statement* init() const { return init_; } 864 Statement* init() const { return init_; }
876 Expression* cond() const { return cond_; } 865 Expression* cond() const { return cond_; }
877 Statement* next() const { return next_; } 866 Statement* next() const { return next_; }
878 867
879 bool may_have_function_literal() const {
880 return may_have_function_literal_;
881 }
882 void set_may_have_function_literal(bool value) {
883 may_have_function_literal_ = value;
884 }
885
886 static int num_ids() { return parent_num_ids() + 2; } 868 static int num_ids() { return parent_num_ids() + 2; }
887 virtual BailoutId ContinueId() const OVERRIDE { 869 virtual BailoutId ContinueId() const OVERRIDE {
888 return BailoutId(local_id(0)); 870 return BailoutId(local_id(0));
889 } 871 }
890 virtual BailoutId StackCheckId() const OVERRIDE { return BodyId(); } 872 virtual BailoutId StackCheckId() const OVERRIDE { return BodyId(); }
891 BailoutId BodyId() const { return BailoutId(local_id(1)); } 873 BailoutId BodyId() const { return BailoutId(local_id(1)); }
892 874
893 bool is_fast_smi_loop() { return loop_variable_ != NULL; }
894 Variable* loop_variable() { return loop_variable_; }
895 void set_loop_variable(Variable* var) { loop_variable_ = var; }
896
897 protected: 875 protected:
898 ForStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos) 876 ForStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos)
899 : IterationStatement(zone, labels, pos), 877 : IterationStatement(zone, labels, pos),
900 init_(NULL), 878 init_(NULL),
901 cond_(NULL), 879 cond_(NULL),
902 next_(NULL), 880 next_(NULL) {}
903 may_have_function_literal_(true),
904 loop_variable_(NULL) {}
905 static int parent_num_ids() { return IterationStatement::num_ids(); } 881 static int parent_num_ids() { return IterationStatement::num_ids(); }
906 882
907 private: 883 private:
908 int local_id(int n) const { return base_id() + parent_num_ids() + n; } 884 int local_id(int n) const { return base_id() + parent_num_ids() + n; }
909 885
910 Statement* init_; 886 Statement* init_;
911 Expression* cond_; 887 Expression* cond_;
912 Statement* next_; 888 Statement* next_;
913
914 // True if there is a function literal subexpression in the condition.
915 bool may_have_function_literal_;
916 Variable* loop_variable_;
917 }; 889 };
918 890
919 891
920 class ForEachStatement : public IterationStatement { 892 class ForEachStatement : public IterationStatement {
921 public: 893 public:
922 enum VisitMode { 894 enum VisitMode {
923 ENUMERATE, // for (each in subject) body; 895 ENUMERATE, // for (each in subject) body;
924 ITERATE // for (each of subject) body; 896 ITERATE // for (each of subject) body;
925 }; 897 };
926 898
(...skipping 2777 matching lines...) Expand 10 before | Expand all | Expand 10 after
3704 private: 3676 private:
3705 Zone* zone_; 3677 Zone* zone_;
3706 Visitor visitor_; 3678 Visitor visitor_;
3707 AstValueFactory* ast_value_factory_; 3679 AstValueFactory* ast_value_factory_;
3708 }; 3680 };
3709 3681
3710 3682
3711 } } // namespace v8::internal 3683 } } // namespace v8::internal
3712 3684
3713 #endif // V8_AST_H_ 3685 #endif // V8_AST_H_
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698