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

Side by Side Diff: src/ast.h

Issue 754303003: Flesh out vector ic state query and set mechanisms. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: REBASE. Created 6 years 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-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_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 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 private: 167 private:
168 int slots_; 168 int slots_;
169 int ic_slots_; 169 int ic_slots_;
170 }; 170 };
171 171
172 172
173 class AstProperties FINAL BASE_EMBEDDED { 173 class AstProperties FINAL BASE_EMBEDDED {
174 public: 174 public:
175 class Flags : public EnumSet<AstPropertiesFlag, int> {}; 175 class Flags : public EnumSet<AstPropertiesFlag, int> {};
176 176
177 AstProperties() : node_count_(0), feedback_slots_(0), ic_feedback_slots_(0) {} 177 AstProperties() : node_count_(0) {}
178 178
179 Flags* flags() { return &flags_; } 179 Flags* flags() { return &flags_; }
180 int node_count() { return node_count_; } 180 int node_count() { return node_count_; }
181 void add_node_count(int count) { node_count_ += count; } 181 void add_node_count(int count) { node_count_ += count; }
182 182
183 int feedback_slots() const { return feedback_slots_; } 183 int slots() const { return spec_.slots(); }
184 void increase_feedback_slots(int count) { 184 void increase_slots(int count) { spec_.increase_slots(count); }
185 feedback_slots_ += count;
186 }
187 185
188 int ic_feedback_slots() const { return ic_feedback_slots_; } 186 int ic_slots() const { return spec_.ic_slots(); }
189 void increase_ic_feedback_slots(int count) { ic_feedback_slots_ += count; } 187 void increase_ic_slots(int count) { spec_.increase_ic_slots(count); }
188 void SetKind(int ic_slot, Code::Kind kind) { spec_.SetKind(ic_slot, kind); }
189 const FeedbackVectorSpec& get_spec() const { return spec_; }
190 190
191 private: 191 private:
192 Flags flags_; 192 Flags flags_;
193 int node_count_; 193 int node_count_;
194 int feedback_slots_; 194 FeedbackVectorSpec spec_;
195 int ic_feedback_slots_;
196 }; 195 };
197 196
198 197
199 class AstNode: public ZoneObject { 198 class AstNode: public ZoneObject {
200 public: 199 public:
201 #define DECLARE_TYPE_ENUM(type) k##type, 200 #define DECLARE_TYPE_ENUM(type) k##type,
202 enum NodeType { 201 enum NodeType {
203 AST_NODE_LIST(DECLARE_TYPE_ENUM) 202 AST_NODE_LIST(DECLARE_TYPE_ENUM)
204 kInvalid = -1 203 kInvalid = -1
205 }; 204 };
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 // not really nice, but multiple inheritance would introduce yet another 237 // not really nice, but multiple inheritance would introduce yet another
239 // vtable entry per node, something we don't want for space reasons. 238 // vtable entry per node, something we don't want for space reasons.
240 virtual FeedbackVectorRequirements ComputeFeedbackRequirements( 239 virtual FeedbackVectorRequirements ComputeFeedbackRequirements(
241 Isolate* isolate) { 240 Isolate* isolate) {
242 return FeedbackVectorRequirements(0, 0); 241 return FeedbackVectorRequirements(0, 0);
243 } 242 }
244 virtual void SetFirstFeedbackSlot(FeedbackVectorSlot slot) { UNREACHABLE(); } 243 virtual void SetFirstFeedbackSlot(FeedbackVectorSlot slot) { UNREACHABLE(); }
245 virtual void SetFirstFeedbackICSlot(FeedbackVectorICSlot slot) { 244 virtual void SetFirstFeedbackICSlot(FeedbackVectorICSlot slot) {
246 UNREACHABLE(); 245 UNREACHABLE();
247 } 246 }
247 // Each ICSlot stores a kind of IC which the participating node should know.
248 virtual Code::Kind FeedbackICSlotKind(int index) {
249 UNREACHABLE();
250 return Code::NUMBER_OF_KINDS;
251 }
248 252
249 private: 253 private:
250 // Hidden to prevent accidental usage. It would have to load the 254 // Hidden to prevent accidental usage. It would have to load the
251 // current zone from the TLS. 255 // current zone from the TLS.
252 void* operator new(size_t size); 256 void* operator new(size_t size);
253 257
254 friend class CaseClause; // Generates AST IDs. 258 friend class CaseClause; // Generates AST IDs.
255 259
256 int position_; 260 int position_;
257 }; 261 };
(...skipping 1433 matching lines...) Expand 10 before | Expand all | Expand 10 after
1691 bool is_resolved() const { return IsResolvedField::decode(bit_field_); } 1695 bool is_resolved() const { return IsResolvedField::decode(bit_field_); }
1692 void set_is_resolved() { 1696 void set_is_resolved() {
1693 bit_field_ = IsResolvedField::update(bit_field_, true); 1697 bit_field_ = IsResolvedField::update(bit_field_, true);
1694 } 1698 }
1695 1699
1696 Interface* interface() const { return interface_; } 1700 Interface* interface() const { return interface_; }
1697 1701
1698 // Bind this proxy to the variable var. Interfaces must match. 1702 // Bind this proxy to the variable var. Interfaces must match.
1699 void BindTo(Variable* var); 1703 void BindTo(Variable* var);
1700 1704
1705 bool UsesVariableFeedbackSlot() const {
1706 return FLAG_vector_ics && (var()->IsUnallocated() || var()->IsLookupSlot());
1707 }
1708
1701 virtual FeedbackVectorRequirements ComputeFeedbackRequirements( 1709 virtual FeedbackVectorRequirements ComputeFeedbackRequirements(
1702 Isolate* isolate) OVERRIDE { 1710 Isolate* isolate) OVERRIDE {
1703 return FeedbackVectorRequirements(0, FLAG_vector_ics ? 1 : 0); 1711 return FeedbackVectorRequirements(0, UsesVariableFeedbackSlot() ? 1 : 0);
1704 } 1712 }
1713
1705 virtual void SetFirstFeedbackICSlot(FeedbackVectorICSlot slot) OVERRIDE { 1714 virtual void SetFirstFeedbackICSlot(FeedbackVectorICSlot slot) OVERRIDE {
1706 variable_feedback_slot_ = slot; 1715 variable_feedback_slot_ = slot;
1707 } 1716 }
1708 1717 virtual Code::Kind FeedbackICSlotKind(int index) OVERRIDE {
1718 return Code::LOAD_IC;
1719 }
1709 FeedbackVectorICSlot VariableFeedbackSlot() { 1720 FeedbackVectorICSlot VariableFeedbackSlot() {
1710 DCHECK(!FLAG_vector_ics || !variable_feedback_slot_.IsInvalid()); 1721 DCHECK(!UsesVariableFeedbackSlot() || !variable_feedback_slot_.IsInvalid());
1711 return variable_feedback_slot_; 1722 return variable_feedback_slot_;
1712 } 1723 }
1713 1724
1714 protected: 1725 protected:
1715 VariableProxy(Zone* zone, Variable* var, int position); 1726 VariableProxy(Zone* zone, Variable* var, int position);
1716 1727
1717 VariableProxy(Zone* zone, const AstRawString* name, bool is_this, 1728 VariableProxy(Zone* zone, const AstRawString* name, bool is_this,
1718 Interface* interface, int position); 1729 Interface* interface, int position);
1719 1730
1720 class IsThisField : public BitField8<bool, 0, 1> {}; 1731 class IsThisField : public BitField8<bool, 0, 1> {};
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
1785 return obj()->IsSuperReference(); 1796 return obj()->IsSuperReference();
1786 } 1797 }
1787 1798
1788 virtual FeedbackVectorRequirements ComputeFeedbackRequirements( 1799 virtual FeedbackVectorRequirements ComputeFeedbackRequirements(
1789 Isolate* isolate) OVERRIDE { 1800 Isolate* isolate) OVERRIDE {
1790 return FeedbackVectorRequirements(0, FLAG_vector_ics ? 1 : 0); 1801 return FeedbackVectorRequirements(0, FLAG_vector_ics ? 1 : 0);
1791 } 1802 }
1792 virtual void SetFirstFeedbackICSlot(FeedbackVectorICSlot slot) OVERRIDE { 1803 virtual void SetFirstFeedbackICSlot(FeedbackVectorICSlot slot) OVERRIDE {
1793 property_feedback_slot_ = slot; 1804 property_feedback_slot_ = slot;
1794 } 1805 }
1806 virtual Code::Kind FeedbackICSlotKind(int index) OVERRIDE {
1807 return key()->IsPropertyName() ? Code::LOAD_IC : Code::KEYED_LOAD_IC;
1808 }
1795 1809
1796 FeedbackVectorICSlot PropertyFeedbackSlot() const { 1810 FeedbackVectorICSlot PropertyFeedbackSlot() const {
1797 DCHECK(!FLAG_vector_ics || !property_feedback_slot_.IsInvalid()); 1811 DCHECK(!FLAG_vector_ics || !property_feedback_slot_.IsInvalid());
1798 return property_feedback_slot_; 1812 return property_feedback_slot_;
1799 } 1813 }
1800 1814
1801 protected: 1815 protected:
1802 Property(Zone* zone, Expression* obj, Expression* key, int pos) 1816 Property(Zone* zone, Expression* obj, Expression* key, int pos)
1803 : Expression(zone, pos), 1817 : Expression(zone, pos),
1804 bit_field_(IsForCallField::encode(false) | 1818 bit_field_(IsForCallField::encode(false) |
(...skipping 24 matching lines...) Expand all
1829 1843
1830 Expression* expression() const { return expression_; } 1844 Expression* expression() const { return expression_; }
1831 ZoneList<Expression*>* arguments() const { return arguments_; } 1845 ZoneList<Expression*>* arguments() const { return arguments_; }
1832 1846
1833 // Type feedback information. 1847 // Type feedback information.
1834 virtual FeedbackVectorRequirements ComputeFeedbackRequirements( 1848 virtual FeedbackVectorRequirements ComputeFeedbackRequirements(
1835 Isolate* isolate) OVERRIDE; 1849 Isolate* isolate) OVERRIDE;
1836 virtual void SetFirstFeedbackICSlot(FeedbackVectorICSlot slot) OVERRIDE { 1850 virtual void SetFirstFeedbackICSlot(FeedbackVectorICSlot slot) OVERRIDE {
1837 call_feedback_slot_ = slot; 1851 call_feedback_slot_ = slot;
1838 } 1852 }
1853 virtual Code::Kind FeedbackICSlotKind(int index) OVERRIDE {
1854 return Code::CALL_IC;
1855 }
1839 1856
1840 bool HasCallFeedbackSlot() const { return !call_feedback_slot_.IsInvalid(); } 1857 bool HasCallFeedbackSlot() const { return !call_feedback_slot_.IsInvalid(); }
1841 FeedbackVectorICSlot CallFeedbackSlot() const { 1858 FeedbackVectorICSlot CallFeedbackSlot() const {
1842 DCHECK(!call_feedback_slot_.IsInvalid()); 1859 DCHECK(!call_feedback_slot_.IsInvalid());
1843 return call_feedback_slot_; 1860 return call_feedback_slot_;
1844 } 1861 }
1845 1862
1846 virtual SmallMapList* GetReceiverTypes() OVERRIDE { 1863 virtual SmallMapList* GetReceiverTypes() OVERRIDE {
1847 if (expression()->IsProperty()) { 1864 if (expression()->IsProperty()) {
1848 return expression()->AsProperty()->GetReceiverTypes(); 1865 return expression()->AsProperty()->GetReceiverTypes();
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
2002 public: 2019 public:
2003 DECLARE_NODE_TYPE(CallRuntime) 2020 DECLARE_NODE_TYPE(CallRuntime)
2004 2021
2005 Handle<String> name() const { return raw_name_->string(); } 2022 Handle<String> name() const { return raw_name_->string(); }
2006 const AstRawString* raw_name() const { return raw_name_; } 2023 const AstRawString* raw_name() const { return raw_name_; }
2007 const Runtime::Function* function() const { return function_; } 2024 const Runtime::Function* function() const { return function_; }
2008 ZoneList<Expression*>* arguments() const { return arguments_; } 2025 ZoneList<Expression*>* arguments() const { return arguments_; }
2009 bool is_jsruntime() const { return function_ == NULL; } 2026 bool is_jsruntime() const { return function_ == NULL; }
2010 2027
2011 // Type feedback information. 2028 // Type feedback information.
2029 bool HasCallRuntimeFeedbackSlot() const {
2030 return FLAG_vector_ics && is_jsruntime();
2031 }
2012 virtual FeedbackVectorRequirements ComputeFeedbackRequirements( 2032 virtual FeedbackVectorRequirements ComputeFeedbackRequirements(
2013 Isolate* isolate) OVERRIDE { 2033 Isolate* isolate) OVERRIDE {
2014 return FeedbackVectorRequirements( 2034 return FeedbackVectorRequirements(0, HasCallRuntimeFeedbackSlot() ? 1 : 0);
2015 0, (FLAG_vector_ics && is_jsruntime()) ? 1 : 0);
2016 } 2035 }
2017 virtual void SetFirstFeedbackICSlot(FeedbackVectorICSlot slot) OVERRIDE { 2036 virtual void SetFirstFeedbackICSlot(FeedbackVectorICSlot slot) OVERRIDE {
2018 callruntime_feedback_slot_ = slot; 2037 callruntime_feedback_slot_ = slot;
2019 } 2038 }
2039 virtual Code::Kind FeedbackICSlotKind(int index) OVERRIDE {
2040 return Code::LOAD_IC;
2041 }
2020 2042
2021 FeedbackVectorICSlot CallRuntimeFeedbackSlot() { 2043 FeedbackVectorICSlot CallRuntimeFeedbackSlot() {
2022 DCHECK(!(FLAG_vector_ics && is_jsruntime()) || 2044 DCHECK(!HasCallRuntimeFeedbackSlot() ||
2023 !callruntime_feedback_slot_.IsInvalid()); 2045 !callruntime_feedback_slot_.IsInvalid());
2024 return callruntime_feedback_slot_; 2046 return callruntime_feedback_slot_;
2025 } 2047 }
2026 2048
2027 static int num_ids() { return parent_num_ids() + 1; } 2049 static int num_ids() { return parent_num_ids() + 1; }
2028 TypeFeedbackId CallRuntimeFeedbackId() const { 2050 TypeFeedbackId CallRuntimeFeedbackId() const {
2029 return TypeFeedbackId(local_id(0)); 2051 return TypeFeedbackId(local_id(0));
2030 } 2052 }
2031 2053
2032 protected: 2054 protected:
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
2382 int index() const { 2404 int index() const {
2383 DCHECK_EQ(kDelegating, yield_kind()); 2405 DCHECK_EQ(kDelegating, yield_kind());
2384 return index_; 2406 return index_;
2385 } 2407 }
2386 void set_index(int index) { 2408 void set_index(int index) {
2387 DCHECK_EQ(kDelegating, yield_kind()); 2409 DCHECK_EQ(kDelegating, yield_kind());
2388 index_ = index; 2410 index_ = index;
2389 } 2411 }
2390 2412
2391 // Type feedback information. 2413 // Type feedback information.
2414 bool HasFeedbackSlots() const {
2415 return FLAG_vector_ics && (yield_kind() == kDelegating);
2416 }
2392 virtual FeedbackVectorRequirements ComputeFeedbackRequirements( 2417 virtual FeedbackVectorRequirements ComputeFeedbackRequirements(
2393 Isolate* isolate) OVERRIDE { 2418 Isolate* isolate) OVERRIDE {
2394 return FeedbackVectorRequirements( 2419 return FeedbackVectorRequirements(0, HasFeedbackSlots() ? 3 : 0);
2395 0, (FLAG_vector_ics && yield_kind() == kDelegating) ? 3 : 0);
2396 } 2420 }
2397 virtual void SetFirstFeedbackICSlot(FeedbackVectorICSlot slot) OVERRIDE { 2421 virtual void SetFirstFeedbackICSlot(FeedbackVectorICSlot slot) OVERRIDE {
2398 yield_first_feedback_slot_ = slot; 2422 yield_first_feedback_slot_ = slot;
2399 } 2423 }
2424 virtual Code::Kind FeedbackICSlotKind(int index) OVERRIDE {
2425 return index == 0 ? Code::KEYED_LOAD_IC : Code::LOAD_IC;
2426 }
2400 2427
2401 FeedbackVectorICSlot KeyedLoadFeedbackSlot() { 2428 FeedbackVectorICSlot KeyedLoadFeedbackSlot() {
2402 DCHECK(!FLAG_vector_ics || !yield_first_feedback_slot_.IsInvalid()); 2429 DCHECK(!HasFeedbackSlots() || !yield_first_feedback_slot_.IsInvalid());
2403 return yield_first_feedback_slot_; 2430 return yield_first_feedback_slot_;
2404 } 2431 }
2405 2432
2406 FeedbackVectorICSlot DoneFeedbackSlot() { 2433 FeedbackVectorICSlot DoneFeedbackSlot() {
2407 return KeyedLoadFeedbackSlot().next(); 2434 return KeyedLoadFeedbackSlot().next();
2408 } 2435 }
2409 2436
2410 FeedbackVectorICSlot ValueFeedbackSlot() { return DoneFeedbackSlot().next(); } 2437 FeedbackVectorICSlot ValueFeedbackSlot() { return DoneFeedbackSlot().next(); }
2411 2438
2412 protected: 2439 protected:
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
2573 } 2600 }
2574 bool is_default_constructor() { 2601 bool is_default_constructor() {
2575 return IsDefaultConstructor(FunctionKindBits::decode(bitfield_)); 2602 return IsDefaultConstructor(FunctionKindBits::decode(bitfield_));
2576 } 2603 }
2577 2604
2578 int ast_node_count() { return ast_properties_.node_count(); } 2605 int ast_node_count() { return ast_properties_.node_count(); }
2579 AstProperties::Flags* flags() { return ast_properties_.flags(); } 2606 AstProperties::Flags* flags() { return ast_properties_.flags(); }
2580 void set_ast_properties(AstProperties* ast_properties) { 2607 void set_ast_properties(AstProperties* ast_properties) {
2581 ast_properties_ = *ast_properties; 2608 ast_properties_ = *ast_properties;
2582 } 2609 }
2583 int slot_count() { 2610 const FeedbackVectorSpec& feedback_vector_spec() const {
2584 return ast_properties_.feedback_slots(); 2611 return ast_properties_.get_spec();
2585 } 2612 }
2586 int ic_slot_count() { return ast_properties_.ic_feedback_slots(); }
2587 bool dont_optimize() { return dont_optimize_reason_ != kNoReason; } 2613 bool dont_optimize() { return dont_optimize_reason_ != kNoReason; }
2588 BailoutReason dont_optimize_reason() { return dont_optimize_reason_; } 2614 BailoutReason dont_optimize_reason() { return dont_optimize_reason_; }
2589 void set_dont_optimize_reason(BailoutReason reason) { 2615 void set_dont_optimize_reason(BailoutReason reason) {
2590 dont_optimize_reason_ = reason; 2616 dont_optimize_reason_ = reason;
2591 } 2617 }
2592 2618
2593 protected: 2619 protected:
2594 FunctionLiteral(Zone* zone, const AstRawString* name, 2620 FunctionLiteral(Zone* zone, const AstRawString* name,
2595 AstValueFactory* ast_value_factory, Scope* scope, 2621 AstValueFactory* ast_value_factory, Scope* scope,
2596 ZoneList<Statement*>* body, int materialized_literal_count, 2622 ZoneList<Statement*>* body, int materialized_literal_count,
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
2727 TypeFeedbackId HomeObjectFeedbackId() { return TypeFeedbackId(local_id(0)); } 2753 TypeFeedbackId HomeObjectFeedbackId() { return TypeFeedbackId(local_id(0)); }
2728 2754
2729 // Type feedback information. 2755 // Type feedback information.
2730 virtual FeedbackVectorRequirements ComputeFeedbackRequirements( 2756 virtual FeedbackVectorRequirements ComputeFeedbackRequirements(
2731 Isolate* isolate) OVERRIDE { 2757 Isolate* isolate) OVERRIDE {
2732 return FeedbackVectorRequirements(0, FLAG_vector_ics ? 1 : 0); 2758 return FeedbackVectorRequirements(0, FLAG_vector_ics ? 1 : 0);
2733 } 2759 }
2734 virtual void SetFirstFeedbackICSlot(FeedbackVectorICSlot slot) OVERRIDE { 2760 virtual void SetFirstFeedbackICSlot(FeedbackVectorICSlot slot) OVERRIDE {
2735 homeobject_feedback_slot_ = slot; 2761 homeobject_feedback_slot_ = slot;
2736 } 2762 }
2763 virtual Code::Kind FeedbackICSlotKind(int index) OVERRIDE {
2764 return Code::LOAD_IC;
2765 }
2737 2766
2738 FeedbackVectorICSlot HomeObjectFeedbackSlot() { 2767 FeedbackVectorICSlot HomeObjectFeedbackSlot() {
2739 DCHECK(!FLAG_vector_ics || !homeobject_feedback_slot_.IsInvalid()); 2768 DCHECK(!FLAG_vector_ics || !homeobject_feedback_slot_.IsInvalid());
2740 return homeobject_feedback_slot_; 2769 return homeobject_feedback_slot_;
2741 } 2770 }
2742 2771
2743 protected: 2772 protected:
2744 SuperReference(Zone* zone, VariableProxy* this_var, int pos) 2773 SuperReference(Zone* zone, VariableProxy* this_var, int pos)
2745 : Expression(zone, pos), 2774 : Expression(zone, pos),
2746 this_var_(this_var), 2775 this_var_(this_var),
(...skipping 803 matching lines...) Expand 10 before | Expand all | Expand 10 after
3550 3579
3551 private: 3580 private:
3552 Zone* zone_; 3581 Zone* zone_;
3553 AstValueFactory* ast_value_factory_; 3582 AstValueFactory* ast_value_factory_;
3554 }; 3583 };
3555 3584
3556 3585
3557 } } // namespace v8::internal 3586 } } // namespace v8::internal
3558 3587
3559 #endif // V8_AST_H_ 3588 #endif // V8_AST_H_
OLDNEW
« no previous file with comments | « no previous file | src/ast-numbering.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698