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

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

Issue 2128613003: Devirtualize AssignFeedbackVectorSlots (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 5 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-numbering.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/ast/ast-value-factory.h" 8 #include "src/ast/ast-value-factory.h"
9 #include "src/ast/modules.h" 9 #include "src/ast/modules.h"
10 #include "src/ast/variables.h" 10 #include "src/ast/variables.h"
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 V8_INLINE bool Is##type() const; \ 206 V8_INLINE bool Is##type() const; \
207 V8_INLINE type* As##type(); \ 207 V8_INLINE type* As##type(); \
208 V8_INLINE const type* As##type() const; 208 V8_INLINE const type* As##type() const;
209 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) 209 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS)
210 #undef DECLARE_NODE_FUNCTIONS 210 #undef DECLARE_NODE_FUNCTIONS
211 211
212 virtual BreakableStatement* AsBreakableStatement() { return NULL; } 212 virtual BreakableStatement* AsBreakableStatement() { return NULL; }
213 virtual IterationStatement* AsIterationStatement() { return NULL; } 213 virtual IterationStatement* AsIterationStatement() { return NULL; }
214 virtual MaterializedLiteral* AsMaterializedLiteral() { return NULL; } 214 virtual MaterializedLiteral* AsMaterializedLiteral() { return NULL; }
215 215
216 // The interface for feedback slots, with default no-op implementations for
217 // node types which don't actually have this. Note that this is conceptually
218 // not really nice, but multiple inheritance would introduce yet another
219 // vtable entry per node, something we don't want for space reasons.
220 virtual void AssignFeedbackVectorSlots(Isolate* isolate,
221 FeedbackVectorSpec* spec,
222 FeedbackVectorSlotCache* cache) {}
223
224 private: 216 private:
225 // Hidden to prevent accidental usage. It would have to load the 217 // Hidden to prevent accidental usage. It would have to load the
226 // current zone from the TLS. 218 // current zone from the TLS.
227 void* operator new(size_t size); 219 void* operator new(size_t size);
228 220
229 friend class CaseClause; // Generates AST IDs. 221 friend class CaseClause; // Generates AST IDs.
230 222
231 int position_; 223 int position_;
232 }; 224 };
233 225
(...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after
797 } 789 }
798 790
799 Expression* each() const { return each_; } 791 Expression* each() const { return each_; }
800 Expression* subject() const { return subject_; } 792 Expression* subject() const { return subject_; }
801 793
802 void set_each(Expression* e) { each_ = e; } 794 void set_each(Expression* e) { each_ = e; }
803 void set_subject(Expression* e) { subject_ = e; } 795 void set_subject(Expression* e) { subject_ = e; }
804 796
805 // Type feedback information. 797 // Type feedback information.
806 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, 798 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec,
807 FeedbackVectorSlotCache* cache) override; 799 FeedbackVectorSlotCache* cache);
808 FeedbackVectorSlot EachFeedbackSlot() const { return each_slot_; } 800 FeedbackVectorSlot EachFeedbackSlot() const { return each_slot_; }
809 FeedbackVectorSlot ForInFeedbackSlot() { 801 FeedbackVectorSlot ForInFeedbackSlot() {
810 DCHECK(!for_in_feedback_slot_.IsInvalid()); 802 DCHECK(!for_in_feedback_slot_.IsInvalid());
811 return for_in_feedback_slot_; 803 return for_in_feedback_slot_;
812 } 804 }
813 805
814 enum ForInType { FAST_FOR_IN, SLOW_FOR_IN }; 806 enum ForInType { FAST_FOR_IN, SLOW_FOR_IN };
815 ForInType for_in_type() const { return for_in_type_; } 807 ForInType for_in_type() const { return for_in_type_; }
816 void set_for_in_type(ForInType type) { for_in_type_ = type; } 808 void set_for_in_type(ForInType type) { for_in_type_ = type; }
817 809
(...skipping 686 matching lines...) Expand 10 before | Expand all | Expand 10 after
1504 1496
1505 // Unlike other AST nodes, this number of bailout IDs allocated for an 1497 // Unlike other AST nodes, this number of bailout IDs allocated for an
1506 // ObjectLiteral can vary, so num_ids() is not a static method. 1498 // ObjectLiteral can vary, so num_ids() is not a static method.
1507 int num_ids() const { 1499 int num_ids() const {
1508 return parent_num_ids() + 1 + 2 * properties()->length(); 1500 return parent_num_ids() + 1 + 2 * properties()->length();
1509 } 1501 }
1510 1502
1511 // Object literals need one feedback slot for each non-trivial value, as well 1503 // Object literals need one feedback slot for each non-trivial value, as well
1512 // as some slots for home objects. 1504 // as some slots for home objects.
1513 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, 1505 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec,
1514 FeedbackVectorSlotCache* cache) override; 1506 FeedbackVectorSlotCache* cache);
1515 1507
1516 protected: 1508 protected:
1517 ObjectLiteral(Zone* zone, ZoneList<Property*>* properties, int literal_index, 1509 ObjectLiteral(Zone* zone, ZoneList<Property*>* properties, int literal_index,
1518 int boilerplate_properties, int pos) 1510 int boilerplate_properties, int pos)
1519 : MaterializedLiteral(zone, literal_index, pos), 1511 : MaterializedLiteral(zone, literal_index, pos),
1520 properties_(properties), 1512 properties_(properties),
1521 boilerplate_properties_(boilerplate_properties), 1513 boilerplate_properties_(boilerplate_properties),
1522 fast_elements_(false), 1514 fast_elements_(false),
1523 has_elements_(false), 1515 has_elements_(false),
1524 may_store_doubles_(false) {} 1516 may_store_doubles_(false) {}
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
1630 first_spread_index_ = -1; 1622 first_spread_index_ = -1;
1631 } 1623 }
1632 1624
1633 enum Flags { 1625 enum Flags {
1634 kNoFlags = 0, 1626 kNoFlags = 0,
1635 kShallowElements = 1, 1627 kShallowElements = 1,
1636 kDisableMementos = 1 << 1 1628 kDisableMementos = 1 << 1
1637 }; 1629 };
1638 1630
1639 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, 1631 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec,
1640 FeedbackVectorSlotCache* cache) override; 1632 FeedbackVectorSlotCache* cache);
1641 FeedbackVectorSlot LiteralFeedbackSlot() const { return literal_slot_; } 1633 FeedbackVectorSlot LiteralFeedbackSlot() const { return literal_slot_; }
1642 1634
1643 protected: 1635 protected:
1644 ArrayLiteral(Zone* zone, ZoneList<Expression*>* values, 1636 ArrayLiteral(Zone* zone, ZoneList<Expression*>* values,
1645 int first_spread_index, int literal_index, int pos) 1637 int first_spread_index, int literal_index, int pos)
1646 : MaterializedLiteral(zone, literal_index, pos), 1638 : MaterializedLiteral(zone, literal_index, pos),
1647 values_(values), 1639 values_(values),
1648 first_spread_index_(first_spread_index) {} 1640 first_spread_index_(first_spread_index) {}
1649 static int parent_num_ids() { return MaterializedLiteral::num_ids(); } 1641 static int parent_num_ids() { return MaterializedLiteral::num_ids(); }
1650 1642
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
1703 int end_position() const { return end_position_; } 1695 int end_position() const { return end_position_; }
1704 1696
1705 // Bind this proxy to the variable var. 1697 // Bind this proxy to the variable var.
1706 void BindTo(Variable* var); 1698 void BindTo(Variable* var);
1707 1699
1708 bool UsesVariableFeedbackSlot() const { 1700 bool UsesVariableFeedbackSlot() const {
1709 return var()->IsUnallocated() || var()->IsLookupSlot(); 1701 return var()->IsUnallocated() || var()->IsLookupSlot();
1710 } 1702 }
1711 1703
1712 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, 1704 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec,
1713 FeedbackVectorSlotCache* cache) override; 1705 FeedbackVectorSlotCache* cache);
1714 1706
1715 FeedbackVectorSlot VariableFeedbackSlot() { return variable_feedback_slot_; } 1707 FeedbackVectorSlot VariableFeedbackSlot() { return variable_feedback_slot_; }
1716 1708
1717 static int num_ids() { return parent_num_ids() + 1; } 1709 static int num_ids() { return parent_num_ids() + 1; }
1718 BailoutId BeforeId() const { return BailoutId(local_id(0)); } 1710 BailoutId BeforeId() const { return BailoutId(local_id(0)); }
1719 1711
1720 protected: 1712 protected:
1721 VariableProxy(Zone* zone, Variable* var, int start_position, 1713 VariableProxy(Zone* zone, Variable* var, int start_position,
1722 int end_position); 1714 int end_position);
1723 1715
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
1803 bit_field_ = InlineCacheStateField::update(bit_field_, state); 1795 bit_field_ = InlineCacheStateField::update(bit_field_, state);
1804 } 1796 }
1805 void mark_for_call() { 1797 void mark_for_call() {
1806 bit_field_ = IsForCallField::update(bit_field_, true); 1798 bit_field_ = IsForCallField::update(bit_field_, true);
1807 } 1799 }
1808 bool is_for_call() const { return IsForCallField::decode(bit_field_); } 1800 bool is_for_call() const { return IsForCallField::decode(bit_field_); }
1809 1801
1810 bool IsSuperAccess() { return obj()->IsSuperPropertyReference(); } 1802 bool IsSuperAccess() { return obj()->IsSuperPropertyReference(); }
1811 1803
1812 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, 1804 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec,
1813 FeedbackVectorSlotCache* cache) override { 1805 FeedbackVectorSlotCache* cache) {
1814 FeedbackVectorSlotKind kind = key()->IsPropertyName() 1806 FeedbackVectorSlotKind kind = key()->IsPropertyName()
1815 ? FeedbackVectorSlotKind::LOAD_IC 1807 ? FeedbackVectorSlotKind::LOAD_IC
1816 : FeedbackVectorSlotKind::KEYED_LOAD_IC; 1808 : FeedbackVectorSlotKind::KEYED_LOAD_IC;
1817 property_feedback_slot_ = spec->AddSlot(kind); 1809 property_feedback_slot_ = spec->AddSlot(kind);
1818 } 1810 }
1819 1811
1820 FeedbackVectorSlot PropertyFeedbackSlot() const { 1812 FeedbackVectorSlot PropertyFeedbackSlot() const {
1821 return property_feedback_slot_; 1813 return property_feedback_slot_;
1822 } 1814 }
1823 1815
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1858 public: 1850 public:
1859 DECLARE_NODE_TYPE(Call) 1851 DECLARE_NODE_TYPE(Call)
1860 1852
1861 Expression* expression() const { return expression_; } 1853 Expression* expression() const { return expression_; }
1862 ZoneList<Expression*>* arguments() const { return arguments_; } 1854 ZoneList<Expression*>* arguments() const { return arguments_; }
1863 1855
1864 void set_expression(Expression* e) { expression_ = e; } 1856 void set_expression(Expression* e) { expression_ = e; }
1865 1857
1866 // Type feedback information. 1858 // Type feedback information.
1867 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, 1859 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec,
1868 FeedbackVectorSlotCache* cache) override; 1860 FeedbackVectorSlotCache* cache);
1869 1861
1870 FeedbackVectorSlot CallFeedbackSlot() const { return stub_slot_; } 1862 FeedbackVectorSlot CallFeedbackSlot() const { return stub_slot_; }
1871 1863
1872 FeedbackVectorSlot CallFeedbackICSlot() const { return ic_slot_; } 1864 FeedbackVectorSlot CallFeedbackICSlot() const { return ic_slot_; }
1873 1865
1874 SmallMapList* GetReceiverTypes() override { 1866 SmallMapList* GetReceiverTypes() override {
1875 if (expression()->IsProperty()) { 1867 if (expression()->IsProperty()) {
1876 return expression()->AsProperty()->GetReceiverTypes(); 1868 return expression()->AsProperty()->GetReceiverTypes();
1877 } 1869 }
1878 return NULL; 1870 return NULL;
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
1982 public: 1974 public:
1983 DECLARE_NODE_TYPE(CallNew) 1975 DECLARE_NODE_TYPE(CallNew)
1984 1976
1985 Expression* expression() const { return expression_; } 1977 Expression* expression() const { return expression_; }
1986 ZoneList<Expression*>* arguments() const { return arguments_; } 1978 ZoneList<Expression*>* arguments() const { return arguments_; }
1987 1979
1988 void set_expression(Expression* e) { expression_ = e; } 1980 void set_expression(Expression* e) { expression_ = e; }
1989 1981
1990 // Type feedback information. 1982 // Type feedback information.
1991 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, 1983 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec,
1992 FeedbackVectorSlotCache* cache) override { 1984 FeedbackVectorSlotCache* cache) {
1993 callnew_feedback_slot_ = spec->AddGeneralSlot(); 1985 callnew_feedback_slot_ = spec->AddGeneralSlot();
1994 // Construct calls have two slots, one right after the other. 1986 // Construct calls have two slots, one right after the other.
1995 // The second slot stores the call count for monomorphic calls. 1987 // The second slot stores the call count for monomorphic calls.
1996 spec->AddGeneralSlot(); 1988 spec->AddGeneralSlot();
1997 } 1989 }
1998 1990
1999 FeedbackVectorSlot CallNewFeedbackSlot() { 1991 FeedbackVectorSlot CallNewFeedbackSlot() {
2000 DCHECK(!callnew_feedback_slot_.IsInvalid()); 1992 DCHECK(!callnew_feedback_slot_.IsInvalid());
2001 return callnew_feedback_slot_; 1993 return callnew_feedback_slot_;
2002 } 1994 }
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
2230 BailoutId AssignmentId() const { return BailoutId(local_id(0)); } 2222 BailoutId AssignmentId() const { return BailoutId(local_id(0)); }
2231 BailoutId ToNumberId() const { return BailoutId(local_id(1)); } 2223 BailoutId ToNumberId() const { return BailoutId(local_id(1)); }
2232 TypeFeedbackId CountBinOpFeedbackId() const { 2224 TypeFeedbackId CountBinOpFeedbackId() const {
2233 return TypeFeedbackId(local_id(2)); 2225 return TypeFeedbackId(local_id(2));
2234 } 2226 }
2235 TypeFeedbackId CountStoreFeedbackId() const { 2227 TypeFeedbackId CountStoreFeedbackId() const {
2236 return TypeFeedbackId(local_id(3)); 2228 return TypeFeedbackId(local_id(3));
2237 } 2229 }
2238 2230
2239 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, 2231 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec,
2240 FeedbackVectorSlotCache* cache) override; 2232 FeedbackVectorSlotCache* cache);
2241 FeedbackVectorSlot CountSlot() const { return slot_; } 2233 FeedbackVectorSlot CountSlot() const { return slot_; }
2242 2234
2243 protected: 2235 protected:
2244 CountOperation(Zone* zone, Token::Value op, bool is_prefix, Expression* expr, 2236 CountOperation(Zone* zone, Token::Value op, bool is_prefix, Expression* expr,
2245 int pos) 2237 int pos)
2246 : Expression(zone, pos), 2238 : Expression(zone, pos),
2247 bit_field_( 2239 bit_field_(
2248 IsPrefixField::encode(is_prefix) | KeyTypeField::encode(ELEMENT) | 2240 IsPrefixField::encode(is_prefix) | KeyTypeField::encode(ELEMENT) |
2249 StoreModeField::encode(STANDARD_STORE) | TokenField::encode(op)), 2241 StoreModeField::encode(STANDARD_STORE) | TokenField::encode(op)),
2250 type_(NULL), 2242 type_(NULL),
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
2422 bit_field_ = IsUninitializedField::update(bit_field_, b); 2414 bit_field_ = IsUninitializedField::update(bit_field_, b);
2423 } 2415 }
2424 void set_key_type(IcCheckType key_type) { 2416 void set_key_type(IcCheckType key_type) {
2425 bit_field_ = KeyTypeField::update(bit_field_, key_type); 2417 bit_field_ = KeyTypeField::update(bit_field_, key_type);
2426 } 2418 }
2427 void set_store_mode(KeyedAccessStoreMode mode) { 2419 void set_store_mode(KeyedAccessStoreMode mode) {
2428 bit_field_ = StoreModeField::update(bit_field_, mode); 2420 bit_field_ = StoreModeField::update(bit_field_, mode);
2429 } 2421 }
2430 2422
2431 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, 2423 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec,
2432 FeedbackVectorSlotCache* cache) override; 2424 FeedbackVectorSlotCache* cache);
2433 FeedbackVectorSlot AssignmentSlot() const { return slot_; } 2425 FeedbackVectorSlot AssignmentSlot() const { return slot_; }
2434 2426
2435 protected: 2427 protected:
2436 Assignment(Zone* zone, Token::Value op, Expression* target, Expression* value, 2428 Assignment(Zone* zone, Token::Value op, Expression* target, Expression* value,
2437 int pos); 2429 int pos);
2438 static int parent_num_ids() { return Expression::num_ids(); } 2430 static int parent_num_ids() { return Expression::num_ids(); }
2439 2431
2440 private: 2432 private:
2441 int local_id(int n) const { return base_id() + parent_num_ids() + n; } 2433 int local_id(int n) const { return base_id() + parent_num_ids() + n; }
2442 2434
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
2770 // Return an AST id for a property that is used in simulate instructions. 2762 // Return an AST id for a property that is used in simulate instructions.
2771 BailoutId GetIdForProperty(int i) { return BailoutId(local_id(i + 5)); } 2763 BailoutId GetIdForProperty(int i) { return BailoutId(local_id(i + 5)); }
2772 2764
2773 // Unlike other AST nodes, this number of bailout IDs allocated for an 2765 // Unlike other AST nodes, this number of bailout IDs allocated for an
2774 // ClassLiteral can vary, so num_ids() is not a static method. 2766 // ClassLiteral can vary, so num_ids() is not a static method.
2775 int num_ids() const { return parent_num_ids() + 5 + properties()->length(); } 2767 int num_ids() const { return parent_num_ids() + 5 + properties()->length(); }
2776 2768
2777 // Object literals need one feedback slot for each non-trivial value, as well 2769 // Object literals need one feedback slot for each non-trivial value, as well
2778 // as some slots for home objects. 2770 // as some slots for home objects.
2779 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, 2771 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec,
2780 FeedbackVectorSlotCache* cache) override; 2772 FeedbackVectorSlotCache* cache);
2781 2773
2782 bool NeedsProxySlot() const { 2774 bool NeedsProxySlot() const {
2783 return class_variable_proxy() != nullptr && 2775 return class_variable_proxy() != nullptr &&
2784 class_variable_proxy()->var()->IsUnallocated(); 2776 class_variable_proxy()->var()->IsUnallocated();
2785 } 2777 }
2786 2778
2787 FeedbackVectorSlot PrototypeSlot() const { return prototype_slot_; } 2779 FeedbackVectorSlot PrototypeSlot() const { return prototype_slot_; }
2788 FeedbackVectorSlot ProxySlot() const { return proxy_slot_; } 2780 FeedbackVectorSlot ProxySlot() const { return proxy_slot_; }
2789 2781
2790 bool IsAnonymousFunctionDefinition() const final { 2782 bool IsAnonymousFunctionDefinition() const final {
(...skipping 766 matching lines...) Expand 10 before | Expand all | Expand 10 after
3557 : NULL; \ 3549 : NULL; \
3558 } 3550 }
3559 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) 3551 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS)
3560 #undef DECLARE_NODE_FUNCTIONS 3552 #undef DECLARE_NODE_FUNCTIONS
3561 3553
3562 3554
3563 } // namespace internal 3555 } // namespace internal
3564 } // namespace v8 3556 } // namespace v8
3565 3557
3566 #endif // V8_AST_AST_H_ 3558 #endif // V8_AST_AST_H_
OLDNEW
« no previous file with comments | « no previous file | src/ast/ast-numbering.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698