OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 kDontSelfOptimize, | 175 kDontSelfOptimize, |
176 kDontSoftInline, | 176 kDontSoftInline, |
177 kDontCache | 177 kDontCache |
178 }; | 178 }; |
179 | 179 |
180 | 180 |
181 class AstProperties V8_FINAL BASE_EMBEDDED { | 181 class AstProperties V8_FINAL BASE_EMBEDDED { |
182 public: | 182 public: |
183 class Flags : public EnumSet<AstPropertiesFlag, int> {}; | 183 class Flags : public EnumSet<AstPropertiesFlag, int> {}; |
184 | 184 |
185 AstProperties() : node_count_(0) {} | 185 AstProperties() : node_count_(0), feedback_slots_(0) {} |
186 | 186 |
187 Flags* flags() { return &flags_; } | 187 Flags* flags() { return &flags_; } |
188 int node_count() { return node_count_; } | 188 int node_count() { return node_count_; } |
189 void add_node_count(int count) { node_count_ += count; } | 189 void add_node_count(int count) { node_count_ += count; } |
190 | 190 |
| 191 int feedback_slots() const { return feedback_slots_; } |
| 192 void increase_feedback_slots(int count) { |
| 193 feedback_slots_ += count; |
| 194 } |
| 195 |
191 private: | 196 private: |
192 Flags flags_; | 197 Flags flags_; |
193 int node_count_; | 198 int node_count_; |
| 199 int feedback_slots_; |
194 }; | 200 }; |
195 | 201 |
196 | 202 |
197 class AstNode: public ZoneObject { | 203 class AstNode: public ZoneObject { |
198 public: | 204 public: |
199 #define DECLARE_TYPE_ENUM(type) k##type, | 205 #define DECLARE_TYPE_ENUM(type) k##type, |
200 enum NodeType { | 206 enum NodeType { |
201 AST_NODE_LIST(DECLARE_TYPE_ENUM) | 207 AST_NODE_LIST(DECLARE_TYPE_ENUM) |
202 kInvalid = -1 | 208 kInvalid = -1 |
203 }; | 209 }; |
(...skipping 718 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
922 class ForInStatement V8_FINAL : public ForEachStatement, | 928 class ForInStatement V8_FINAL : public ForEachStatement, |
923 public FeedbackSlotInterface { | 929 public FeedbackSlotInterface { |
924 public: | 930 public: |
925 DECLARE_NODE_TYPE(ForInStatement) | 931 DECLARE_NODE_TYPE(ForInStatement) |
926 | 932 |
927 Expression* enumerable() const { | 933 Expression* enumerable() const { |
928 return subject(); | 934 return subject(); |
929 } | 935 } |
930 | 936 |
931 // Type feedback information. | 937 // Type feedback information. |
932 virtual ComputablePhase GetComputablePhase() { return DURING_PARSE; } | 938 virtual int ComputeFeedbackSlotCount() { return 1; } |
933 virtual int ComputeFeedbackSlotCount(Isolate* isolate) { return 1; } | |
934 virtual void SetFirstFeedbackSlot(int slot) { for_in_feedback_slot_ = slot; } | 939 virtual void SetFirstFeedbackSlot(int slot) { for_in_feedback_slot_ = slot; } |
935 | 940 |
936 int ForInFeedbackSlot() { | 941 int ForInFeedbackSlot() { |
937 ASSERT(for_in_feedback_slot_ != kInvalidFeedbackSlot); | 942 ASSERT(for_in_feedback_slot_ != kInvalidFeedbackSlot); |
938 return for_in_feedback_slot_; | 943 return for_in_feedback_slot_; |
939 } | 944 } |
940 | 945 |
941 enum ForInType { FAST_FOR_IN, SLOW_FOR_IN }; | 946 enum ForInType { FAST_FOR_IN, SLOW_FOR_IN }; |
942 ForInType for_in_type() const { return for_in_type_; } | 947 ForInType for_in_type() const { return for_in_type_; } |
943 void set_for_in_type(ForInType type) { for_in_type_ = type; } | 948 void set_for_in_type(ForInType type) { for_in_type_ = type; } |
(...skipping 805 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1749 | 1754 |
1750 | 1755 |
1751 class Call V8_FINAL : public Expression, public FeedbackSlotInterface { | 1756 class Call V8_FINAL : public Expression, public FeedbackSlotInterface { |
1752 public: | 1757 public: |
1753 DECLARE_NODE_TYPE(Call) | 1758 DECLARE_NODE_TYPE(Call) |
1754 | 1759 |
1755 Expression* expression() const { return expression_; } | 1760 Expression* expression() const { return expression_; } |
1756 ZoneList<Expression*>* arguments() const { return arguments_; } | 1761 ZoneList<Expression*>* arguments() const { return arguments_; } |
1757 | 1762 |
1758 // Type feedback information. | 1763 // Type feedback information. |
1759 virtual ComputablePhase GetComputablePhase() { return AFTER_SCOPING; } | 1764 virtual int ComputeFeedbackSlotCount() { return 1; } |
1760 virtual int ComputeFeedbackSlotCount(Isolate* isolate); | |
1761 virtual void SetFirstFeedbackSlot(int slot) { | 1765 virtual void SetFirstFeedbackSlot(int slot) { |
1762 call_feedback_slot_ = slot; | 1766 call_feedback_slot_ = slot; |
1763 } | 1767 } |
1764 | 1768 |
1765 bool HasCallFeedbackSlot() const { | 1769 bool HasCallFeedbackSlot() const { |
1766 return call_feedback_slot_ != kInvalidFeedbackSlot; | 1770 return call_feedback_slot_ != kInvalidFeedbackSlot; |
1767 } | 1771 } |
1768 int CallFeedbackSlot() const { return call_feedback_slot_; } | 1772 int CallFeedbackSlot() const { return call_feedback_slot_; } |
1769 | 1773 |
1770 virtual SmallMapList* GetReceiverTypes() V8_OVERRIDE { | 1774 virtual SmallMapList* GetReceiverTypes() V8_OVERRIDE { |
(...skipping 22 matching lines...) Expand all Loading... |
1793 enum CallType { | 1797 enum CallType { |
1794 POSSIBLY_EVAL_CALL, | 1798 POSSIBLY_EVAL_CALL, |
1795 GLOBAL_CALL, | 1799 GLOBAL_CALL, |
1796 LOOKUP_SLOT_CALL, | 1800 LOOKUP_SLOT_CALL, |
1797 PROPERTY_CALL, | 1801 PROPERTY_CALL, |
1798 OTHER_CALL | 1802 OTHER_CALL |
1799 }; | 1803 }; |
1800 | 1804 |
1801 // Helpers to determine how to handle the call. | 1805 // Helpers to determine how to handle the call. |
1802 CallType GetCallType(Isolate* isolate) const; | 1806 CallType GetCallType(Isolate* isolate) const; |
| 1807 bool IsUsingCallFeedbackSlot(Isolate* isolate) const; |
1803 | 1808 |
1804 #ifdef DEBUG | 1809 #ifdef DEBUG |
1805 // Used to assert that the FullCodeGenerator records the return site. | 1810 // Used to assert that the FullCodeGenerator records the return site. |
1806 bool return_is_recorded_; | 1811 bool return_is_recorded_; |
1807 #endif | 1812 #endif |
1808 | 1813 |
1809 protected: | 1814 protected: |
1810 Call(Zone* zone, | 1815 Call(Zone* zone, |
1811 Expression* expression, | 1816 Expression* expression, |
1812 ZoneList<Expression*>* arguments, | 1817 ZoneList<Expression*>* arguments, |
(...skipping 21 matching lines...) Expand all Loading... |
1834 | 1839 |
1835 | 1840 |
1836 class CallNew V8_FINAL : public Expression, public FeedbackSlotInterface { | 1841 class CallNew V8_FINAL : public Expression, public FeedbackSlotInterface { |
1837 public: | 1842 public: |
1838 DECLARE_NODE_TYPE(CallNew) | 1843 DECLARE_NODE_TYPE(CallNew) |
1839 | 1844 |
1840 Expression* expression() const { return expression_; } | 1845 Expression* expression() const { return expression_; } |
1841 ZoneList<Expression*>* arguments() const { return arguments_; } | 1846 ZoneList<Expression*>* arguments() const { return arguments_; } |
1842 | 1847 |
1843 // Type feedback information. | 1848 // Type feedback information. |
1844 virtual ComputablePhase GetComputablePhase() { return DURING_PARSE; } | 1849 virtual int ComputeFeedbackSlotCount() { |
1845 virtual int ComputeFeedbackSlotCount(Isolate* isolate) { | |
1846 return FLAG_pretenuring_call_new ? 2 : 1; | 1850 return FLAG_pretenuring_call_new ? 2 : 1; |
1847 } | 1851 } |
1848 virtual void SetFirstFeedbackSlot(int slot) { | 1852 virtual void SetFirstFeedbackSlot(int slot) { |
1849 callnew_feedback_slot_ = slot; | 1853 callnew_feedback_slot_ = slot; |
1850 } | 1854 } |
1851 | 1855 |
1852 int CallNewFeedbackSlot() { | 1856 int CallNewFeedbackSlot() { |
1853 ASSERT(callnew_feedback_slot_ != kInvalidFeedbackSlot); | 1857 ASSERT(callnew_feedback_slot_ != kInvalidFeedbackSlot); |
1854 return callnew_feedback_slot_; | 1858 return callnew_feedback_slot_; |
1855 } | 1859 } |
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2371 | 2375 |
2372 bool is_generator() { | 2376 bool is_generator() { |
2373 return IsGenerator::decode(bitfield_) == kIsGenerator; | 2377 return IsGenerator::decode(bitfield_) == kIsGenerator; |
2374 } | 2378 } |
2375 | 2379 |
2376 int ast_node_count() { return ast_properties_.node_count(); } | 2380 int ast_node_count() { return ast_properties_.node_count(); } |
2377 AstProperties::Flags* flags() { return ast_properties_.flags(); } | 2381 AstProperties::Flags* flags() { return ast_properties_.flags(); } |
2378 void set_ast_properties(AstProperties* ast_properties) { | 2382 void set_ast_properties(AstProperties* ast_properties) { |
2379 ast_properties_ = *ast_properties; | 2383 ast_properties_ = *ast_properties; |
2380 } | 2384 } |
2381 void set_slot_processor(DeferredFeedbackSlotProcessor* slot_processor) { | |
2382 slot_processor_ = *slot_processor; | |
2383 } | |
2384 void ProcessFeedbackSlots(Isolate* isolate) { | |
2385 slot_processor_.ProcessFeedbackSlots(isolate); | |
2386 } | |
2387 int slot_count() { | 2385 int slot_count() { |
2388 return slot_processor_.slot_count(); | 2386 return ast_properties_.feedback_slots(); |
2389 } | 2387 } |
2390 bool dont_optimize() { return dont_optimize_reason_ != kNoReason; } | 2388 bool dont_optimize() { return dont_optimize_reason_ != kNoReason; } |
2391 BailoutReason dont_optimize_reason() { return dont_optimize_reason_; } | 2389 BailoutReason dont_optimize_reason() { return dont_optimize_reason_; } |
2392 void set_dont_optimize_reason(BailoutReason reason) { | 2390 void set_dont_optimize_reason(BailoutReason reason) { |
2393 dont_optimize_reason_ = reason; | 2391 dont_optimize_reason_ = reason; |
2394 } | 2392 } |
2395 | 2393 |
2396 protected: | 2394 protected: |
2397 FunctionLiteral(Zone* zone, | 2395 FunctionLiteral(Zone* zone, |
2398 Handle<String> name, | 2396 Handle<String> name, |
(...skipping 30 matching lines...) Expand all Loading... |
2429 IsGenerator::encode(is_generator); | 2427 IsGenerator::encode(is_generator); |
2430 } | 2428 } |
2431 | 2429 |
2432 private: | 2430 private: |
2433 Handle<String> name_; | 2431 Handle<String> name_; |
2434 Handle<SharedFunctionInfo> shared_info_; | 2432 Handle<SharedFunctionInfo> shared_info_; |
2435 Scope* scope_; | 2433 Scope* scope_; |
2436 ZoneList<Statement*>* body_; | 2434 ZoneList<Statement*>* body_; |
2437 Handle<String> inferred_name_; | 2435 Handle<String> inferred_name_; |
2438 AstProperties ast_properties_; | 2436 AstProperties ast_properties_; |
2439 DeferredFeedbackSlotProcessor slot_processor_; | |
2440 BailoutReason dont_optimize_reason_; | 2437 BailoutReason dont_optimize_reason_; |
2441 | 2438 |
2442 int materialized_literal_count_; | 2439 int materialized_literal_count_; |
2443 int expected_property_count_; | 2440 int expected_property_count_; |
2444 int handler_count_; | 2441 int handler_count_; |
2445 int parameter_count_; | 2442 int parameter_count_; |
2446 int function_token_position_; | 2443 int function_token_position_; |
2447 | 2444 |
2448 unsigned bitfield_; | 2445 unsigned bitfield_; |
2449 class IsExpression: public BitField<bool, 0, 1> {}; | 2446 class IsExpression: public BitField<bool, 0, 1> {}; |
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2910 // Construction time visitor. | 2907 // Construction time visitor. |
2911 | 2908 |
2912 class AstConstructionVisitor BASE_EMBEDDED { | 2909 class AstConstructionVisitor BASE_EMBEDDED { |
2913 public: | 2910 public: |
2914 explicit AstConstructionVisitor(Zone* zone) | 2911 explicit AstConstructionVisitor(Zone* zone) |
2915 : dont_optimize_reason_(kNoReason), | 2912 : dont_optimize_reason_(kNoReason), |
2916 zone_(zone) { } | 2913 zone_(zone) { } |
2917 | 2914 |
2918 AstProperties* ast_properties() { return &properties_; } | 2915 AstProperties* ast_properties() { return &properties_; } |
2919 BailoutReason dont_optimize_reason() { return dont_optimize_reason_; } | 2916 BailoutReason dont_optimize_reason() { return dont_optimize_reason_; } |
2920 DeferredFeedbackSlotProcessor* slot_processor() { return &slot_processor_; } | |
2921 | 2917 |
2922 private: | 2918 private: |
2923 template<class> friend class AstNodeFactory; | 2919 template<class> friend class AstNodeFactory; |
2924 | 2920 |
2925 // Node visitors. | 2921 // Node visitors. |
2926 #define DEF_VISIT(type) \ | 2922 #define DEF_VISIT(type) \ |
2927 void Visit##type(type* node); | 2923 void Visit##type(type* node); |
2928 AST_NODE_LIST(DEF_VISIT) | 2924 AST_NODE_LIST(DEF_VISIT) |
2929 #undef DEF_VISIT | 2925 #undef DEF_VISIT |
2930 | 2926 |
2931 void increase_node_count() { properties_.add_node_count(1); } | 2927 void increase_node_count() { properties_.add_node_count(1); } |
2932 void add_flag(AstPropertiesFlag flag) { properties_.flags()->Add(flag); } | 2928 void add_flag(AstPropertiesFlag flag) { properties_.flags()->Add(flag); } |
2933 void set_dont_optimize_reason(BailoutReason reason) { | 2929 void set_dont_optimize_reason(BailoutReason reason) { |
2934 dont_optimize_reason_ = reason; | 2930 dont_optimize_reason_ = reason; |
2935 } | 2931 } |
2936 | 2932 |
2937 void add_slot_node(FeedbackSlotInterface* slot_node) { | 2933 void add_slot_node(FeedbackSlotInterface* slot_node) { |
2938 slot_processor_.add_slot_node(zone_, slot_node); | 2934 int count = slot_node->ComputeFeedbackSlotCount(); |
| 2935 if (count > 0) { |
| 2936 slot_node->SetFirstFeedbackSlot(properties_.feedback_slots()); |
| 2937 properties_.increase_feedback_slots(count); |
| 2938 } |
2939 } | 2939 } |
2940 | 2940 |
2941 AstProperties properties_; | 2941 AstProperties properties_; |
2942 DeferredFeedbackSlotProcessor slot_processor_; | |
2943 BailoutReason dont_optimize_reason_; | 2942 BailoutReason dont_optimize_reason_; |
2944 Zone* zone_; | 2943 Zone* zone_; |
2945 }; | 2944 }; |
2946 | 2945 |
2947 | 2946 |
2948 class AstNullVisitor BASE_EMBEDDED { | 2947 class AstNullVisitor BASE_EMBEDDED { |
2949 public: | 2948 public: |
2950 explicit AstNullVisitor(Zone* zone) {} | 2949 explicit AstNullVisitor(Zone* zone) {} |
2951 | 2950 |
2952 // Node visitors. | 2951 // Node visitors. |
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3364 | 3363 |
3365 private: | 3364 private: |
3366 Zone* zone_; | 3365 Zone* zone_; |
3367 Visitor visitor_; | 3366 Visitor visitor_; |
3368 }; | 3367 }; |
3369 | 3368 |
3370 | 3369 |
3371 } } // namespace v8::internal | 3370 } } // namespace v8::internal |
3372 | 3371 |
3373 #endif // V8_AST_H_ | 3372 #endif // V8_AST_H_ |
OLD | NEW |