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

Side by Side Diff: src/ast.h

Issue 1376443002: Refactored interface of FeedbackVectorSpec and friends. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix Created 5 years, 2 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.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_H_ 5 #ifndef V8_AST_H_
6 #define V8_AST_H_ 6 #define V8_AST_H_
7 7
8 #include "src/assembler.h" 8 #include "src/assembler.h"
9 #include "src/ast-value-factory.h" 9 #include "src/ast-value-factory.h"
10 #include "src/bailout-reason.h" 10 #include "src/bailout-reason.h"
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 typedef ZoneList<Handle<String>> ZoneStringList; 131 typedef ZoneList<Handle<String>> ZoneStringList;
132 typedef ZoneList<Handle<Object>> ZoneObjectList; 132 typedef ZoneList<Handle<Object>> ZoneObjectList;
133 133
134 134
135 #define DECLARE_NODE_TYPE(type) \ 135 #define DECLARE_NODE_TYPE(type) \
136 void Accept(AstVisitor* v) override; \ 136 void Accept(AstVisitor* v) override; \
137 AstNode::NodeType node_type() const final { return AstNode::k##type; } \ 137 AstNode::NodeType node_type() const final { return AstNode::k##type; } \
138 friend class AstNodeFactory; 138 friend class AstNodeFactory;
139 139
140 140
141 class FeedbackVectorRequirements {
142 public:
143 FeedbackVectorRequirements(int slots, int ic_slots)
144 : slots_(slots), ic_slots_(ic_slots) {}
145
146 int slots() const { return slots_; }
147 int ic_slots() const { return ic_slots_; }
148
149 private:
150 int slots_;
151 int ic_slots_;
152 };
153
154
155 class ICSlotCache { 141 class ICSlotCache {
156 public: 142 public:
157 explicit ICSlotCache(Zone* zone) 143 explicit ICSlotCache(Zone* zone)
158 : zone_(zone), 144 : zone_(zone),
159 hash_map_(HashMap::PointersMatch, ZoneHashMap::kDefaultHashMapCapacity, 145 hash_map_(HashMap::PointersMatch, ZoneHashMap::kDefaultHashMapCapacity,
160 ZoneAllocationPolicy(zone)) {} 146 ZoneAllocationPolicy(zone)) {}
161 147
162 void Put(Variable* variable, FeedbackVectorICSlot slot) { 148 void Put(Variable* variable, FeedbackVectorICSlot slot) {
163 ZoneHashMap::Entry* entry = hash_map_.LookupOrInsert( 149 ZoneHashMap::Entry* entry = hash_map_.LookupOrInsert(
164 variable, ComputePointerHash(variable), ZoneAllocationPolicy(zone_)); 150 variable, ComputePointerHash(variable), ZoneAllocationPolicy(zone_));
(...skipping 20 matching lines...) Expand all
185 171
186 typedef base::Flags<Flag> Flags; 172 typedef base::Flags<Flag> Flags;
187 173
188 explicit AstProperties(Zone* zone) : node_count_(0), spec_(zone) {} 174 explicit AstProperties(Zone* zone) : node_count_(0), spec_(zone) {}
189 175
190 Flags& flags() { return flags_; } 176 Flags& flags() { return flags_; }
191 Flags flags() const { return flags_; } 177 Flags flags() const { return flags_; }
192 int node_count() { return node_count_; } 178 int node_count() { return node_count_; }
193 void add_node_count(int count) { node_count_ += count; } 179 void add_node_count(int count) { node_count_ += count; }
194 180
195 int slots() const { return spec_.slots(); } 181 const FeedbackVectorSpec* get_spec() const { return &spec_; }
196 void increase_slots(int count) { spec_.increase_slots(count); } 182 FeedbackVectorSpec* get_spec() { return &spec_; }
197
198 int ic_slots() const { return spec_.ic_slots(); }
199 void increase_ic_slots(int count) { spec_.increase_ic_slots(count); }
200 void SetKind(int ic_slot, FeedbackVectorSlotKind kind) {
201 spec_.SetKind(ic_slot, kind);
202 }
203 const ZoneFeedbackVectorSpec* get_spec() const { return &spec_; }
204 183
205 private: 184 private:
206 Flags flags_; 185 Flags flags_;
207 int node_count_; 186 int node_count_;
208 ZoneFeedbackVectorSpec spec_; 187 FeedbackVectorSpec spec_;
209 }; 188 };
210 189
211 DEFINE_OPERATORS_FOR_FLAGS(AstProperties::Flags) 190 DEFINE_OPERATORS_FOR_FLAGS(AstProperties::Flags)
212 191
213 192
214 class AstNode: public ZoneObject { 193 class AstNode: public ZoneObject {
215 public: 194 public:
216 #define DECLARE_TYPE_ENUM(type) k##type, 195 #define DECLARE_TYPE_ENUM(type) k##type,
217 enum NodeType { 196 enum NodeType {
218 AST_NODE_LIST(DECLARE_TYPE_ENUM) 197 AST_NODE_LIST(DECLARE_TYPE_ENUM)
(...skipping 23 matching lines...) Expand all
242 #undef DECLARE_NODE_FUNCTIONS 221 #undef DECLARE_NODE_FUNCTIONS
243 222
244 virtual BreakableStatement* AsBreakableStatement() { return NULL; } 223 virtual BreakableStatement* AsBreakableStatement() { return NULL; }
245 virtual IterationStatement* AsIterationStatement() { return NULL; } 224 virtual IterationStatement* AsIterationStatement() { return NULL; }
246 virtual MaterializedLiteral* AsMaterializedLiteral() { return NULL; } 225 virtual MaterializedLiteral* AsMaterializedLiteral() { return NULL; }
247 226
248 // The interface for feedback slots, with default no-op implementations for 227 // The interface for feedback slots, with default no-op implementations for
249 // node types which don't actually have this. Note that this is conceptually 228 // node types which don't actually have this. Note that this is conceptually
250 // not really nice, but multiple inheritance would introduce yet another 229 // not really nice, but multiple inheritance would introduce yet another
251 // vtable entry per node, something we don't want for space reasons. 230 // vtable entry per node, something we don't want for space reasons.
252 virtual FeedbackVectorRequirements ComputeFeedbackRequirements( 231 virtual void AssignFeedbackVectorSlots(Isolate* isolate,
253 Isolate* isolate, const ICSlotCache* cache) { 232 FeedbackVectorSpec* spec,
254 return FeedbackVectorRequirements(0, 0); 233 ICSlotCache* cache) {}
255 } 234
256 virtual void SetFirstFeedbackSlot(FeedbackVectorSlot slot) { UNREACHABLE(); }
257 virtual void SetFirstFeedbackICSlot(FeedbackVectorICSlot slot,
258 ICSlotCache* cache) {
259 UNREACHABLE();
260 }
261 // Each ICSlot stores a kind of IC which the participating node should know. 235 // Each ICSlot stores a kind of IC which the participating node should know.
262 virtual FeedbackVectorSlotKind FeedbackICSlotKind(int index) { 236 virtual FeedbackVectorSlotKind FeedbackICSlotKind(int index) {
263 UNREACHABLE(); 237 UNREACHABLE();
264 return FeedbackVectorSlotKind::UNUSED; 238 return FeedbackVectorSlotKind::UNUSED;
265 } 239 }
266 240
267 private: 241 private:
268 // Hidden to prevent accidental usage. It would have to load the 242 // Hidden to prevent accidental usage. It would have to load the
269 // current zone from the TLS. 243 // current zone from the TLS.
270 void* operator new(size_t size); 244 void* operator new(size_t size);
(...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after
801 775
802 void Initialize(Expression* each, Expression* subject, Statement* body) { 776 void Initialize(Expression* each, Expression* subject, Statement* body) {
803 IterationStatement::Initialize(body); 777 IterationStatement::Initialize(body);
804 each_ = each; 778 each_ = each;
805 subject_ = subject; 779 subject_ = subject;
806 } 780 }
807 781
808 Expression* each() const { return each_; } 782 Expression* each() const { return each_; }
809 Expression* subject() const { return subject_; } 783 Expression* subject() const { return subject_; }
810 784
811 FeedbackVectorRequirements ComputeFeedbackRequirements( 785 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec,
812 Isolate* isolate, const ICSlotCache* cache) override; 786 ICSlotCache* cache) override;
813 void SetFirstFeedbackICSlot(FeedbackVectorICSlot slot,
814 ICSlotCache* cache) override {
815 each_slot_ = slot;
816 }
817 FeedbackVectorSlotKind FeedbackICSlotKind(int index) override;
818 FeedbackVectorICSlot EachFeedbackSlot() const { return each_slot_; } 787 FeedbackVectorICSlot EachFeedbackSlot() const { return each_slot_; }
819 788
820 protected: 789 protected:
821 ForEachStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos) 790 ForEachStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos)
822 : IterationStatement(zone, labels, pos), 791 : IterationStatement(zone, labels, pos),
823 each_(NULL), 792 each_(NULL),
824 subject_(NULL), 793 subject_(NULL),
825 each_slot_(FeedbackVectorICSlot::Invalid()) {} 794 each_slot_(FeedbackVectorICSlot::Invalid()) {}
826 795
827 private: 796 private:
828 Expression* each_; 797 Expression* each_;
829 Expression* subject_; 798 Expression* subject_;
830 FeedbackVectorICSlot each_slot_; 799 FeedbackVectorICSlot each_slot_;
831 }; 800 };
832 801
833 802
834 class ForInStatement final : public ForEachStatement { 803 class ForInStatement final : public ForEachStatement {
835 public: 804 public:
836 DECLARE_NODE_TYPE(ForInStatement) 805 DECLARE_NODE_TYPE(ForInStatement)
837 806
838 Expression* enumerable() const { 807 Expression* enumerable() const {
839 return subject(); 808 return subject();
840 } 809 }
841 810
842 // Type feedback information. 811 // Type feedback information.
843 FeedbackVectorRequirements ComputeFeedbackRequirements( 812 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec,
844 Isolate* isolate, const ICSlotCache* cache) override { 813 ICSlotCache* cache) override {
845 FeedbackVectorRequirements base = 814 ForEachStatement::AssignFeedbackVectorSlots(isolate, spec, cache);
846 ForEachStatement::ComputeFeedbackRequirements(isolate, cache); 815 for_in_feedback_slot_ = spec->AddStubSlot();
847 DCHECK(base.slots() == 0 && base.ic_slots() <= 1);
848 return FeedbackVectorRequirements(1, base.ic_slots());
849 }
850 void SetFirstFeedbackSlot(FeedbackVectorSlot slot) override {
851 for_in_feedback_slot_ = slot;
852 } 816 }
853 817
854 FeedbackVectorSlot ForInFeedbackSlot() { 818 FeedbackVectorSlot ForInFeedbackSlot() {
855 DCHECK(!for_in_feedback_slot_.IsInvalid()); 819 DCHECK(!for_in_feedback_slot_.IsInvalid());
856 return for_in_feedback_slot_; 820 return for_in_feedback_slot_;
857 } 821 }
858 822
859 enum ForInType { FAST_FOR_IN, SLOW_FOR_IN }; 823 enum ForInType { FAST_FOR_IN, SLOW_FOR_IN };
860 ForInType for_in_type() const { return for_in_type_; } 824 ForInType for_in_type() const { return for_in_type_; }
861 void set_for_in_type(ForInType type) { for_in_type_ = type; } 825 void set_for_in_type(ForInType type) { for_in_type_ = type; }
(...skipping 681 matching lines...) Expand 10 before | Expand all | Expand 10 after
1543 1507
1544 // Return an AST id for a property that is used in simulate instructions. 1508 // Return an AST id for a property that is used in simulate instructions.
1545 BailoutId GetIdForProperty(int i) { return BailoutId(local_id(i + 1)); } 1509 BailoutId GetIdForProperty(int i) { return BailoutId(local_id(i + 1)); }
1546 1510
1547 // Unlike other AST nodes, this number of bailout IDs allocated for an 1511 // Unlike other AST nodes, this number of bailout IDs allocated for an
1548 // ObjectLiteral can vary, so num_ids() is not a static method. 1512 // ObjectLiteral can vary, so num_ids() is not a static method.
1549 int num_ids() const { return parent_num_ids() + 1 + properties()->length(); } 1513 int num_ids() const { return parent_num_ids() + 1 + properties()->length(); }
1550 1514
1551 // Object literals need one feedback slot for each non-trivial value, as well 1515 // Object literals need one feedback slot for each non-trivial value, as well
1552 // as some slots for home objects. 1516 // as some slots for home objects.
1553 FeedbackVectorRequirements ComputeFeedbackRequirements( 1517 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec,
1554 Isolate* isolate, const ICSlotCache* cache) override; 1518 ICSlotCache* cache) override;
1555 void SetFirstFeedbackICSlot(FeedbackVectorICSlot slot,
1556 ICSlotCache* cache) override {
1557 slot_ = slot;
1558 }
1559 FeedbackVectorSlotKind FeedbackICSlotKind(int index) override {
1560 return FeedbackVectorSlotKind::STORE_IC;
1561 }
1562 1519
1563 // After feedback slots were assigned, propagate information to the properties 1520 // After feedback slots were assigned, propagate information to the properties
1564 // which need it. 1521 // which need it.
1565 void LayoutFeedbackSlots(); 1522 void LayoutFeedbackSlots();
1566 1523
1567 protected: 1524 protected:
1568 ObjectLiteral(Zone* zone, ZoneList<Property*>* properties, int literal_index, 1525 ObjectLiteral(Zone* zone, ZoneList<Property*>* properties, int literal_index,
1569 int boilerplate_properties, bool has_function, bool is_strong, 1526 int boilerplate_properties, bool has_function, bool is_strong,
1570 int pos) 1527 int pos)
1571 : MaterializedLiteral(zone, literal_index, is_strong, pos), 1528 : MaterializedLiteral(zone, literal_index, is_strong, pos),
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
1724 1681
1725 int end_position() const { return end_position_; } 1682 int end_position() const { return end_position_; }
1726 1683
1727 // Bind this proxy to the variable var. 1684 // Bind this proxy to the variable var.
1728 void BindTo(Variable* var); 1685 void BindTo(Variable* var);
1729 1686
1730 bool UsesVariableFeedbackSlot() const { 1687 bool UsesVariableFeedbackSlot() const {
1731 return var()->IsUnallocated() || var()->IsLookupSlot(); 1688 return var()->IsUnallocated() || var()->IsLookupSlot();
1732 } 1689 }
1733 1690
1734 virtual FeedbackVectorRequirements ComputeFeedbackRequirements( 1691 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec,
1735 Isolate* isolate, const ICSlotCache* cache) override; 1692 ICSlotCache* cache) override;
1736 1693
1737 void SetFirstFeedbackICSlot(FeedbackVectorICSlot slot,
1738 ICSlotCache* cache) override;
1739 FeedbackVectorSlotKind FeedbackICSlotKind(int index) override {
1740 return FeedbackVectorSlotKind::LOAD_IC;
1741 }
1742 FeedbackVectorICSlot VariableFeedbackSlot() { 1694 FeedbackVectorICSlot VariableFeedbackSlot() {
1743 return variable_feedback_slot_; 1695 return variable_feedback_slot_;
1744 } 1696 }
1745 1697
1746 static int num_ids() { return parent_num_ids() + 1; } 1698 static int num_ids() { return parent_num_ids() + 1; }
1747 BailoutId BeforeId() const { return BailoutId(local_id(0)); } 1699 BailoutId BeforeId() const { return BailoutId(local_id(0)); }
1748 1700
1749 protected: 1701 protected:
1750 VariableProxy(Zone* zone, Variable* var, int start_position, 1702 VariableProxy(Zone* zone, Variable* var, int start_position,
1751 int end_position); 1703 int end_position);
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
1828 void set_inline_cache_state(InlineCacheState state) { 1780 void set_inline_cache_state(InlineCacheState state) {
1829 bit_field_ = InlineCacheStateField::update(bit_field_, state); 1781 bit_field_ = InlineCacheStateField::update(bit_field_, state);
1830 } 1782 }
1831 void mark_for_call() { 1783 void mark_for_call() {
1832 bit_field_ = IsForCallField::update(bit_field_, true); 1784 bit_field_ = IsForCallField::update(bit_field_, true);
1833 } 1785 }
1834 bool is_for_call() const { return IsForCallField::decode(bit_field_); } 1786 bool is_for_call() const { return IsForCallField::decode(bit_field_); }
1835 1787
1836 bool IsSuperAccess() { return obj()->IsSuperPropertyReference(); } 1788 bool IsSuperAccess() { return obj()->IsSuperPropertyReference(); }
1837 1789
1838 virtual FeedbackVectorRequirements ComputeFeedbackRequirements( 1790 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec,
1839 Isolate* isolate, const ICSlotCache* cache) override { 1791 ICSlotCache* cache) override {
1840 return FeedbackVectorRequirements(0, 1); 1792 FeedbackVectorSlotKind kind = key()->IsPropertyName()
1841 } 1793 ? FeedbackVectorSlotKind::LOAD_IC
1842 void SetFirstFeedbackICSlot(FeedbackVectorICSlot slot, 1794 : FeedbackVectorSlotKind::KEYED_LOAD_IC;
1843 ICSlotCache* cache) override { 1795 property_feedback_slot_ = spec->AddSlot(kind);
1844 property_feedback_slot_ = slot;
1845 }
1846 FeedbackVectorSlotKind FeedbackICSlotKind(int index) override {
1847 return key()->IsPropertyName() ? FeedbackVectorSlotKind::LOAD_IC
1848 : FeedbackVectorSlotKind::KEYED_LOAD_IC;
1849 } 1796 }
1850 1797
1851 FeedbackVectorICSlot PropertyFeedbackSlot() const { 1798 FeedbackVectorICSlot PropertyFeedbackSlot() const {
1852 return property_feedback_slot_; 1799 return property_feedback_slot_;
1853 } 1800 }
1854 1801
1855 static LhsKind GetAssignType(Property* property) { 1802 static LhsKind GetAssignType(Property* property) {
1856 if (property == NULL) return VARIABLE; 1803 if (property == NULL) return VARIABLE;
1857 bool super_access = property->IsSuperAccess(); 1804 bool super_access = property->IsSuperAccess();
1858 return (property->key()->IsPropertyName()) 1805 return (property->key()->IsPropertyName())
(...skipping 28 matching lines...) Expand all
1887 1834
1888 1835
1889 class Call final : public Expression { 1836 class Call final : public Expression {
1890 public: 1837 public:
1891 DECLARE_NODE_TYPE(Call) 1838 DECLARE_NODE_TYPE(Call)
1892 1839
1893 Expression* expression() const { return expression_; } 1840 Expression* expression() const { return expression_; }
1894 ZoneList<Expression*>* arguments() const { return arguments_; } 1841 ZoneList<Expression*>* arguments() const { return arguments_; }
1895 1842
1896 // Type feedback information. 1843 // Type feedback information.
1897 virtual FeedbackVectorRequirements ComputeFeedbackRequirements( 1844 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec,
1898 Isolate* isolate, const ICSlotCache* cache) override; 1845 ICSlotCache* cache) override;
1899 void SetFirstFeedbackICSlot(FeedbackVectorICSlot slot,
1900 ICSlotCache* cache) override {
1901 ic_slot_ = slot;
1902 }
1903 void SetFirstFeedbackSlot(FeedbackVectorSlot slot) override { slot_ = slot; }
1904 FeedbackVectorSlotKind FeedbackICSlotKind(int index) override {
1905 return FeedbackVectorSlotKind::CALL_IC;
1906 }
1907 1846
1908 FeedbackVectorSlot CallFeedbackSlot() const { return slot_; } 1847 FeedbackVectorSlot CallFeedbackSlot() const { return slot_; }
1909 1848
1910 FeedbackVectorICSlot CallFeedbackICSlot() const { return ic_slot_; } 1849 FeedbackVectorICSlot CallFeedbackICSlot() const { return ic_slot_; }
1911 1850
1912 SmallMapList* GetReceiverTypes() override { 1851 SmallMapList* GetReceiverTypes() override {
1913 if (expression()->IsProperty()) { 1852 if (expression()->IsProperty()) {
1914 return expression()->AsProperty()->GetReceiverTypes(); 1853 return expression()->AsProperty()->GetReceiverTypes();
1915 } 1854 }
1916 return NULL; 1855 return NULL;
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
2006 1945
2007 1946
2008 class CallNew final : public Expression { 1947 class CallNew final : public Expression {
2009 public: 1948 public:
2010 DECLARE_NODE_TYPE(CallNew) 1949 DECLARE_NODE_TYPE(CallNew)
2011 1950
2012 Expression* expression() const { return expression_; } 1951 Expression* expression() const { return expression_; }
2013 ZoneList<Expression*>* arguments() const { return arguments_; } 1952 ZoneList<Expression*>* arguments() const { return arguments_; }
2014 1953
2015 // Type feedback information. 1954 // Type feedback information.
2016 virtual FeedbackVectorRequirements ComputeFeedbackRequirements( 1955 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec,
2017 Isolate* isolate, const ICSlotCache* cache) override { 1956 ICSlotCache* cache) override {
2018 return FeedbackVectorRequirements(1, 0); 1957 callnew_feedback_slot_ = spec->AddStubSlot();
2019 }
2020 void SetFirstFeedbackSlot(FeedbackVectorSlot slot) override {
2021 callnew_feedback_slot_ = slot;
2022 } 1958 }
2023 1959
2024 FeedbackVectorSlot CallNewFeedbackSlot() { 1960 FeedbackVectorSlot CallNewFeedbackSlot() {
2025 DCHECK(!callnew_feedback_slot_.IsInvalid()); 1961 DCHECK(!callnew_feedback_slot_.IsInvalid());
2026 return callnew_feedback_slot_; 1962 return callnew_feedback_slot_;
2027 } 1963 }
2028 1964
2029 bool IsMonomorphic() override { return is_monomorphic_; } 1965 bool IsMonomorphic() override { return is_monomorphic_; }
2030 Handle<JSFunction> target() const { return target_; } 1966 Handle<JSFunction> target() const { return target_; }
2031 Handle<AllocationSite> allocation_site() const { 1967 Handle<AllocationSite> allocation_site() const {
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
2240 static int num_ids() { return parent_num_ids() + 4; } 2176 static int num_ids() { return parent_num_ids() + 4; }
2241 BailoutId AssignmentId() const { return BailoutId(local_id(0)); } 2177 BailoutId AssignmentId() const { return BailoutId(local_id(0)); }
2242 BailoutId ToNumberId() const { return BailoutId(local_id(1)); } 2178 BailoutId ToNumberId() const { return BailoutId(local_id(1)); }
2243 TypeFeedbackId CountBinOpFeedbackId() const { 2179 TypeFeedbackId CountBinOpFeedbackId() const {
2244 return TypeFeedbackId(local_id(2)); 2180 return TypeFeedbackId(local_id(2));
2245 } 2181 }
2246 TypeFeedbackId CountStoreFeedbackId() const { 2182 TypeFeedbackId CountStoreFeedbackId() const {
2247 return TypeFeedbackId(local_id(3)); 2183 return TypeFeedbackId(local_id(3));
2248 } 2184 }
2249 2185
2250 FeedbackVectorRequirements ComputeFeedbackRequirements( 2186 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec,
2251 Isolate* isolate, const ICSlotCache* cache) override; 2187 ICSlotCache* cache) override;
2252 void SetFirstFeedbackICSlot(FeedbackVectorICSlot slot,
2253 ICSlotCache* cache) override {
2254 slot_ = slot;
2255 }
2256 FeedbackVectorSlotKind FeedbackICSlotKind(int index) override;
2257 FeedbackVectorICSlot CountSlot() const { return slot_; } 2188 FeedbackVectorICSlot CountSlot() const { return slot_; }
2258 2189
2259 protected: 2190 protected:
2260 CountOperation(Zone* zone, Token::Value op, bool is_prefix, Expression* expr, 2191 CountOperation(Zone* zone, Token::Value op, bool is_prefix, Expression* expr,
2261 int pos) 2192 int pos)
2262 : Expression(zone, pos), 2193 : Expression(zone, pos),
2263 bit_field_( 2194 bit_field_(
2264 IsPrefixField::encode(is_prefix) | KeyTypeField::encode(ELEMENT) | 2195 IsPrefixField::encode(is_prefix) | KeyTypeField::encode(ELEMENT) |
2265 StoreModeField::encode(STANDARD_STORE) | TokenField::encode(op)), 2196 StoreModeField::encode(STANDARD_STORE) | TokenField::encode(op)),
2266 type_(NULL), 2197 type_(NULL),
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
2418 void set_is_uninitialized(bool b) { 2349 void set_is_uninitialized(bool b) {
2419 bit_field_ = IsUninitializedField::update(bit_field_, b); 2350 bit_field_ = IsUninitializedField::update(bit_field_, b);
2420 } 2351 }
2421 void set_key_type(IcCheckType key_type) { 2352 void set_key_type(IcCheckType key_type) {
2422 bit_field_ = KeyTypeField::update(bit_field_, key_type); 2353 bit_field_ = KeyTypeField::update(bit_field_, key_type);
2423 } 2354 }
2424 void set_store_mode(KeyedAccessStoreMode mode) { 2355 void set_store_mode(KeyedAccessStoreMode mode) {
2425 bit_field_ = StoreModeField::update(bit_field_, mode); 2356 bit_field_ = StoreModeField::update(bit_field_, mode);
2426 } 2357 }
2427 2358
2428 FeedbackVectorRequirements ComputeFeedbackRequirements( 2359 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec,
2429 Isolate* isolate, const ICSlotCache* cache) override; 2360 ICSlotCache* cache) override;
2430 void SetFirstFeedbackICSlot(FeedbackVectorICSlot slot,
2431 ICSlotCache* cache) override {
2432 slot_ = slot;
2433 }
2434 FeedbackVectorSlotKind FeedbackICSlotKind(int index) override;
2435 FeedbackVectorICSlot AssignmentSlot() const { return slot_; } 2361 FeedbackVectorICSlot AssignmentSlot() const { return slot_; }
2436 2362
2437 protected: 2363 protected:
2438 Assignment(Zone* zone, Token::Value op, Expression* target, Expression* value, 2364 Assignment(Zone* zone, Token::Value op, Expression* target, Expression* value,
2439 int pos); 2365 int pos);
2440 static int parent_num_ids() { return Expression::num_ids(); } 2366 static int parent_num_ids() { return Expression::num_ids(); }
2441 2367
2442 private: 2368 private:
2443 int local_id(int n) const { return base_id() + parent_num_ids() + n; } 2369 int local_id(int n) const { return base_id() + parent_num_ids() + n; }
2444 2370
(...skipping 23 matching lines...) Expand all
2468 kDelegating, // A yield*. 2394 kDelegating, // A yield*.
2469 kFinal // A return: { value: EXPRESSION, done: true } 2395 kFinal // A return: { value: EXPRESSION, done: true }
2470 }; 2396 };
2471 2397
2472 Expression* generator_object() const { return generator_object_; } 2398 Expression* generator_object() const { return generator_object_; }
2473 Expression* expression() const { return expression_; } 2399 Expression* expression() const { return expression_; }
2474 Kind yield_kind() const { return yield_kind_; } 2400 Kind yield_kind() const { return yield_kind_; }
2475 2401
2476 // Type feedback information. 2402 // Type feedback information.
2477 bool HasFeedbackSlots() const { return yield_kind() == kDelegating; } 2403 bool HasFeedbackSlots() const { return yield_kind() == kDelegating; }
2478 virtual FeedbackVectorRequirements ComputeFeedbackRequirements( 2404 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec,
2479 Isolate* isolate, const ICSlotCache* cache) override { 2405 ICSlotCache* cache) override {
2480 return FeedbackVectorRequirements(0, HasFeedbackSlots() ? 3 : 0); 2406 if (HasFeedbackSlots()) {
2481 } 2407 yield_first_feedback_slot_ = spec->AddKeyedLoadICSlot();
2482 void SetFirstFeedbackICSlot(FeedbackVectorICSlot slot, 2408 spec->AddLoadICSlots(2);
2483 ICSlotCache* cache) override { 2409 }
2484 yield_first_feedback_slot_ = slot;
2485 }
2486 FeedbackVectorSlotKind FeedbackICSlotKind(int index) override {
2487 return index == 0 ? FeedbackVectorSlotKind::KEYED_LOAD_IC
2488 : FeedbackVectorSlotKind::LOAD_IC;
2489 } 2410 }
2490 2411
2491 FeedbackVectorICSlot KeyedLoadFeedbackSlot() { 2412 FeedbackVectorICSlot KeyedLoadFeedbackSlot() {
2492 DCHECK(!HasFeedbackSlots() || !yield_first_feedback_slot_.IsInvalid()); 2413 DCHECK(!HasFeedbackSlots() || !yield_first_feedback_slot_.IsInvalid());
2493 return yield_first_feedback_slot_; 2414 return yield_first_feedback_slot_;
2494 } 2415 }
2495 2416
2496 FeedbackVectorICSlot DoneFeedbackSlot() { 2417 FeedbackVectorICSlot DoneFeedbackSlot() {
2497 return KeyedLoadFeedbackSlot().next(); 2418 return KeyedLoadFeedbackSlot().next();
2498 } 2419 }
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
2647 bitfield_ = ShouldBeUsedOnceHintBit::update(bitfield_, kShouldBeUsedOnce); 2568 bitfield_ = ShouldBeUsedOnceHintBit::update(bitfield_, kShouldBeUsedOnce);
2648 } 2569 }
2649 2570
2650 FunctionKind kind() const { return FunctionKindBits::decode(bitfield_); } 2571 FunctionKind kind() const { return FunctionKindBits::decode(bitfield_); }
2651 2572
2652 int ast_node_count() { return ast_properties_.node_count(); } 2573 int ast_node_count() { return ast_properties_.node_count(); }
2653 AstProperties::Flags flags() const { return ast_properties_.flags(); } 2574 AstProperties::Flags flags() const { return ast_properties_.flags(); }
2654 void set_ast_properties(AstProperties* ast_properties) { 2575 void set_ast_properties(AstProperties* ast_properties) {
2655 ast_properties_ = *ast_properties; 2576 ast_properties_ = *ast_properties;
2656 } 2577 }
2657 const ZoneFeedbackVectorSpec* feedback_vector_spec() const { 2578 const FeedbackVectorSpec* feedback_vector_spec() const {
2658 return ast_properties_.get_spec(); 2579 return ast_properties_.get_spec();
2659 } 2580 }
2660 bool dont_optimize() { return dont_optimize_reason_ != kNoReason; } 2581 bool dont_optimize() { return dont_optimize_reason_ != kNoReason; }
2661 BailoutReason dont_optimize_reason() { return dont_optimize_reason_; } 2582 BailoutReason dont_optimize_reason() { return dont_optimize_reason_; }
2662 void set_dont_optimize_reason(BailoutReason reason) { 2583 void set_dont_optimize_reason(BailoutReason reason) {
2663 dont_optimize_reason_ = reason; 2584 dont_optimize_reason_ = reason;
2664 } 2585 }
2665 2586
2666 protected: 2587 protected:
2667 FunctionLiteral(Zone* zone, const AstRawString* name, 2588 FunctionLiteral(Zone* zone, const AstRawString* name,
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
2746 2667
2747 // Return an AST id for a property that is used in simulate instructions. 2668 // Return an AST id for a property that is used in simulate instructions.
2748 BailoutId GetIdForProperty(int i) { return BailoutId(local_id(i + 4)); } 2669 BailoutId GetIdForProperty(int i) { return BailoutId(local_id(i + 4)); }
2749 2670
2750 // Unlike other AST nodes, this number of bailout IDs allocated for an 2671 // Unlike other AST nodes, this number of bailout IDs allocated for an
2751 // ClassLiteral can vary, so num_ids() is not a static method. 2672 // ClassLiteral can vary, so num_ids() is not a static method.
2752 int num_ids() const { return parent_num_ids() + 4 + properties()->length(); } 2673 int num_ids() const { return parent_num_ids() + 4 + properties()->length(); }
2753 2674
2754 // Object literals need one feedback slot for each non-trivial value, as well 2675 // Object literals need one feedback slot for each non-trivial value, as well
2755 // as some slots for home objects. 2676 // as some slots for home objects.
2756 FeedbackVectorRequirements ComputeFeedbackRequirements( 2677 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec,
2757 Isolate* isolate, const ICSlotCache* cache) override; 2678 ICSlotCache* cache) override;
2758 void SetFirstFeedbackICSlot(FeedbackVectorICSlot slot,
2759 ICSlotCache* cache) override {
2760 slot_ = slot;
2761 }
2762 FeedbackVectorSlotKind FeedbackICSlotKind(int index) override {
2763 return FeedbackVectorSlotKind::STORE_IC;
2764 }
2765 2679
2766 bool NeedsProxySlot() const { 2680 bool NeedsProxySlot() const {
2767 return FLAG_vector_stores && scope() != NULL && 2681 return FLAG_vector_stores && scope() != NULL &&
2768 class_variable_proxy()->var()->IsUnallocated(); 2682 class_variable_proxy()->var()->IsUnallocated();
2769 } 2683 }
2770 2684
2771 FeedbackVectorICSlot ProxySlot() const { return slot_; } 2685 FeedbackVectorICSlot ProxySlot() const { return slot_; }
2772 2686
2773 // After feedback slots were assigned, propagate information to the properties 2687 // After feedback slots were assigned, propagate information to the properties
2774 // which need it. 2688 // which need it.
(...skipping 966 matching lines...) Expand 10 before | Expand all | Expand 10 after
3741 // ZoneObjects which need to persist until scope analysis must be allocated in 3655 // ZoneObjects which need to persist until scope analysis must be allocated in
3742 // the parser-level zone. 3656 // the parser-level zone.
3743 Zone* parser_zone_; 3657 Zone* parser_zone_;
3744 AstValueFactory* ast_value_factory_; 3658 AstValueFactory* ast_value_factory_;
3745 }; 3659 };
3746 3660
3747 3661
3748 } } // namespace v8::internal 3662 } } // namespace v8::internal
3749 3663
3750 #endif // V8_AST_H_ 3664 #endif // V8_AST_H_
OLDNEW
« no previous file with comments | « no previous file | src/ast.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698