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

Side by Side Diff: src/ast/ast.h

Issue 1742013002: [cleanup] Move ForEach vector feedback slots to ForInStatement (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 9 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
« no previous file with comments | « no previous file | src/ast/ast.cc » ('j') | 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_AST_H_ 5 #ifndef V8_AST_AST_H_
6 #define V8_AST_AST_H_ 6 #define V8_AST_AST_H_
7 7
8 #include "src/assembler.h" 8 #include "src/assembler.h"
9 #include "src/ast/ast-value-factory.h" 9 #include "src/ast/ast-value-factory.h"
10 #include "src/ast/modules.h" 10 #include "src/ast/modules.h"
(...skipping 772 matching lines...) Expand 10 before | Expand all | Expand 10 after
783 each_ = each; 783 each_ = each;
784 subject_ = subject; 784 subject_ = subject;
785 } 785 }
786 786
787 Expression* each() const { return each_; } 787 Expression* each() const { return each_; }
788 Expression* subject() const { return subject_; } 788 Expression* subject() const { return subject_; }
789 789
790 void set_each(Expression* e) { each_ = e; } 790 void set_each(Expression* e) { each_ = e; }
791 void set_subject(Expression* e) { subject_ = e; } 791 void set_subject(Expression* e) { subject_ = e; }
792 792
793 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec,
794 FeedbackVectorSlotCache* cache) override;
795 FeedbackVectorSlot EachFeedbackSlot() const { return each_slot_; }
796
797 static const char* VisitModeString(VisitMode mode) { 793 static const char* VisitModeString(VisitMode mode) {
798 return mode == ITERATE ? "for-of" : "for-in"; 794 return mode == ITERATE ? "for-of" : "for-in";
799 } 795 }
800 796
801 protected: 797 protected:
802 ForEachStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos) 798 ForEachStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos)
803 : IterationStatement(zone, labels, pos), each_(NULL), subject_(NULL) {} 799 : IterationStatement(zone, labels, pos), each_(NULL), subject_(NULL) {}
804 800
805 private: 801 private:
806 Expression* each_; 802 Expression* each_;
807 Expression* subject_; 803 Expression* subject_;
808 FeedbackVectorSlot each_slot_;
809 }; 804 };
810 805
811 806
812 class ForInStatement final : public ForEachStatement { 807 class ForInStatement final : public ForEachStatement {
813 public: 808 public:
814 DECLARE_NODE_TYPE(ForInStatement) 809 DECLARE_NODE_TYPE(ForInStatement)
815 810
816 Expression* enumerable() const { 811 Expression* enumerable() const {
817 return subject(); 812 return subject();
818 } 813 }
819 814
820 // Type feedback information. 815 // Type feedback information.
821 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, 816 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec,
822 FeedbackVectorSlotCache* cache) override { 817 FeedbackVectorSlotCache* cache) override;
823 ForEachStatement::AssignFeedbackVectorSlots(isolate, spec, cache); 818 FeedbackVectorSlot EachFeedbackSlot() const { return each_slot_; }
824 for_in_feedback_slot_ = spec->AddGeneralSlot();
825 }
826
827 FeedbackVectorSlot ForInFeedbackSlot() { 819 FeedbackVectorSlot ForInFeedbackSlot() {
828 DCHECK(!for_in_feedback_slot_.IsInvalid()); 820 DCHECK(!for_in_feedback_slot_.IsInvalid());
829 return for_in_feedback_slot_; 821 return for_in_feedback_slot_;
830 } 822 }
831 823
832 enum ForInType { FAST_FOR_IN, SLOW_FOR_IN }; 824 enum ForInType { FAST_FOR_IN, SLOW_FOR_IN };
833 ForInType for_in_type() const { return for_in_type_; } 825 ForInType for_in_type() const { return for_in_type_; }
834 void set_for_in_type(ForInType type) { for_in_type_ = type; } 826 void set_for_in_type(ForInType type) { for_in_type_ = type; }
835 827
836 static int num_ids() { return parent_num_ids() + 6; } 828 static int num_ids() { return parent_num_ids() + 6; }
837 BailoutId BodyId() const { return BailoutId(local_id(0)); } 829 BailoutId BodyId() const { return BailoutId(local_id(0)); }
838 BailoutId EnumId() const { return BailoutId(local_id(1)); } 830 BailoutId EnumId() const { return BailoutId(local_id(1)); }
839 BailoutId ToObjectId() const { return BailoutId(local_id(2)); } 831 BailoutId ToObjectId() const { return BailoutId(local_id(2)); }
840 BailoutId PrepareId() const { return BailoutId(local_id(3)); } 832 BailoutId PrepareId() const { return BailoutId(local_id(3)); }
841 BailoutId FilterId() const { return BailoutId(local_id(4)); } 833 BailoutId FilterId() const { return BailoutId(local_id(4)); }
842 BailoutId AssignmentId() const { return BailoutId(local_id(5)); } 834 BailoutId AssignmentId() const { return BailoutId(local_id(5)); }
843 BailoutId ContinueId() const override { return EntryId(); } 835 BailoutId ContinueId() const override { return EntryId(); }
844 BailoutId StackCheckId() const override { return BodyId(); } 836 BailoutId StackCheckId() const override { return BodyId(); }
845 837
846 protected: 838 protected:
847 ForInStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos) 839 ForInStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos)
848 : ForEachStatement(zone, labels, pos), for_in_type_(SLOW_FOR_IN) {} 840 : ForEachStatement(zone, labels, pos), for_in_type_(SLOW_FOR_IN) {}
849 static int parent_num_ids() { return ForEachStatement::num_ids(); } 841 static int parent_num_ids() { return ForEachStatement::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 ForInType for_in_type_; 846 ForInType for_in_type_;
847 FeedbackVectorSlot each_slot_;
855 FeedbackVectorSlot for_in_feedback_slot_; 848 FeedbackVectorSlot for_in_feedback_slot_;
856 }; 849 };
857 850
858 851
859 class ForOfStatement final : public ForEachStatement { 852 class ForOfStatement final : public ForEachStatement {
860 public: 853 public:
861 DECLARE_NODE_TYPE(ForOfStatement) 854 DECLARE_NODE_TYPE(ForOfStatement)
862 855
863 void Initialize(Expression* each, 856 void Initialize(Expression* each,
864 Expression* subject, 857 Expression* subject,
(...skipping 2671 matching lines...) Expand 10 before | Expand all | Expand 10 after
3536 : NULL; \ 3529 : NULL; \
3537 } 3530 }
3538 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) 3531 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS)
3539 #undef DECLARE_NODE_FUNCTIONS 3532 #undef DECLARE_NODE_FUNCTIONS
3540 3533
3541 3534
3542 } // namespace internal 3535 } // namespace internal
3543 } // namespace v8 3536 } // namespace v8
3544 3537
3545 #endif // V8_AST_AST_H_ 3538 #endif // V8_AST_AST_H_
OLDNEW
« no previous file with comments | « no previous file | src/ast/ast.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698