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 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
170 | 170 |
171 | 171 |
172 enum AstPropertiesFlag { | 172 enum AstPropertiesFlag { |
173 kDontInline, | 173 kDontInline, |
174 kDontSelfOptimize, | 174 kDontSelfOptimize, |
175 kDontSoftInline, | 175 kDontSoftInline, |
176 kDontCache | 176 kDontCache |
177 }; | 177 }; |
178 | 178 |
179 | 179 |
180 class FeedbackSlotInterface { | |
181 public: | |
182 virtual ~FeedbackSlotInterface() {} | |
183 virtual int GetFeedbackSlotCount(Isolate* isolate) = 0; | |
184 virtual void SetFirstFeedbackSlot(int slot) = 0; | |
185 }; | |
186 | |
187 | |
180 class AstProperties V8_FINAL BASE_EMBEDDED { | 188 class AstProperties V8_FINAL BASE_EMBEDDED { |
181 public: | 189 public: |
182 class Flags : public EnumSet<AstPropertiesFlag, int> {}; | 190 class Flags : public EnumSet<AstPropertiesFlag, int> {}; |
183 | 191 |
184 AstProperties() : node_count_(0) { } | 192 AstProperties() : node_count_(0), slot_nodes_(NULL), slot_count_(-1) { |
193 } | |
194 | |
195 ZoneList<FeedbackSlotInterface*>* slot_nodes() { | |
196 ASSERT(slot_count_ == -1); | |
197 return slot_nodes_; | |
198 } | |
199 void set_slot_count(int count) { | |
200 ASSERT(slot_count_ == -1); | |
201 slot_count_ = count; | |
202 slot_nodes_ = NULL; // We are done with this funny list. | |
203 } | |
204 | |
205 // Returns -1 if the work hasn't been done yet. | |
206 int slot_count() { | |
207 return slot_count_; | |
208 } | |
185 | 209 |
186 Flags* flags() { return &flags_; } | 210 Flags* flags() { return &flags_; } |
187 int node_count() { return node_count_; } | 211 int node_count() { return node_count_; } |
188 void add_node_count(int count) { node_count_ += count; } | 212 void add_node_count(int count) { node_count_ += count; } |
213 void add_slot_node(Zone* zone, FeedbackSlotInterface* slot) { | |
214 if (slot_nodes_ == NULL) { | |
215 slot_nodes_ = new(zone) ZoneList<FeedbackSlotInterface*>(10, zone); | |
216 } | |
217 slot_nodes_->Add(slot, zone); | |
218 } | |
189 | 219 |
190 private: | 220 private: |
191 Flags flags_; | 221 Flags flags_; |
192 int node_count_; | 222 int node_count_; |
223 ZoneList<FeedbackSlotInterface*>* slot_nodes_; | |
224 int slot_count_; | |
193 }; | 225 }; |
194 | 226 |
195 | 227 |
196 class AstNode: public ZoneObject { | 228 class AstNode: public ZoneObject { |
197 public: | 229 public: |
198 #define DECLARE_TYPE_ENUM(type) k##type, | 230 #define DECLARE_TYPE_ENUM(type) k##type, |
199 enum NodeType { | 231 enum NodeType { |
200 AST_NODE_LIST(DECLARE_TYPE_ENUM) | 232 AST_NODE_LIST(DECLARE_TYPE_ENUM) |
201 kInvalid = -1 | 233 kInvalid = -1 |
202 }; | 234 }; |
203 #undef DECLARE_TYPE_ENUM | 235 #undef DECLARE_TYPE_ENUM |
204 | 236 |
205 void* operator new(size_t size, Zone* zone) { | 237 void* operator new(size_t size, Zone* zone) { |
206 return zone->New(static_cast<int>(size)); | 238 return zone->New(static_cast<int>(size)); |
207 } | 239 } |
208 | 240 |
209 explicit AstNode(int position): position_(position) {} | 241 explicit AstNode(int position): position_(position) {} |
210 virtual ~AstNode() {} | 242 virtual ~AstNode() {} |
211 | 243 |
212 virtual void Accept(AstVisitor* v) = 0; | 244 virtual void Accept(AstVisitor* v) = 0; |
213 virtual NodeType node_type() const = 0; | 245 virtual NodeType node_type() const = 0; |
214 int position() const { return position_; } | 246 int position() const { return position_; } |
215 | 247 |
248 static const int kInvalidFeedbackSlot = -1; | |
249 virtual FeedbackSlotInterface* SupportsFeedbackSlots() { return NULL; } | |
250 | |
216 // Type testing & conversion functions overridden by concrete subclasses. | 251 // Type testing & conversion functions overridden by concrete subclasses. |
217 #define DECLARE_NODE_FUNCTIONS(type) \ | 252 #define DECLARE_NODE_FUNCTIONS(type) \ |
218 bool Is##type() { return node_type() == AstNode::k##type; } \ | 253 bool Is##type() { return node_type() == AstNode::k##type; } \ |
219 type* As##type() { return Is##type() ? reinterpret_cast<type*>(this) : NULL; } | 254 type* As##type() { return Is##type() ? reinterpret_cast<type*>(this) : NULL; } |
220 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) | 255 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) |
221 #undef DECLARE_NODE_FUNCTIONS | 256 #undef DECLARE_NODE_FUNCTIONS |
222 | 257 |
223 virtual TargetCollector* AsTargetCollector() { return NULL; } | 258 virtual TargetCollector* AsTargetCollector() { return NULL; } |
224 virtual BreakableStatement* AsBreakableStatement() { return NULL; } | 259 virtual BreakableStatement* AsBreakableStatement() { return NULL; } |
225 virtual IterationStatement* AsIterationStatement() { return NULL; } | 260 virtual IterationStatement* AsIterationStatement() { return NULL; } |
(...skipping 681 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
907 each_(NULL), | 942 each_(NULL), |
908 subject_(NULL) { | 943 subject_(NULL) { |
909 } | 944 } |
910 | 945 |
911 private: | 946 private: |
912 Expression* each_; | 947 Expression* each_; |
913 Expression* subject_; | 948 Expression* subject_; |
914 }; | 949 }; |
915 | 950 |
916 | 951 |
917 class ForInStatement V8_FINAL : public ForEachStatement { | 952 class ForInStatement V8_FINAL : public ForEachStatement, |
953 public FeedbackSlotInterface { | |
918 public: | 954 public: |
919 DECLARE_NODE_TYPE(ForInStatement) | 955 DECLARE_NODE_TYPE(ForInStatement) |
920 | 956 |
921 Expression* enumerable() const { | 957 Expression* enumerable() const { |
922 return subject(); | 958 return subject(); |
923 } | 959 } |
924 | 960 |
925 TypeFeedbackId ForInFeedbackId() const { return reuse(PrepareId()); } | 961 // Type feedback information. |
962 virtual FeedbackSlotInterface* SupportsFeedbackSlots() { return this; } | |
963 virtual int GetFeedbackSlotCount(Isolate* isolate) { return 1; } | |
964 virtual void SetFirstFeedbackSlot(int slot) { for_in_feedback_slot_ = slot; } | |
965 | |
966 int ForInFeedbackSlot() { | |
967 ASSERT(for_in_feedback_slot_ != kInvalidFeedbackSlot); | |
968 return for_in_feedback_slot_; | |
969 } | |
970 | |
926 enum ForInType { FAST_FOR_IN, SLOW_FOR_IN }; | 971 enum ForInType { FAST_FOR_IN, SLOW_FOR_IN }; |
927 ForInType for_in_type() const { return for_in_type_; } | 972 ForInType for_in_type() const { return for_in_type_; } |
928 void set_for_in_type(ForInType type) { for_in_type_ = type; } | 973 void set_for_in_type(ForInType type) { for_in_type_ = type; } |
929 | 974 |
930 BailoutId BodyId() const { return body_id_; } | 975 BailoutId BodyId() const { return body_id_; } |
931 BailoutId PrepareId() const { return prepare_id_; } | 976 BailoutId PrepareId() const { return prepare_id_; } |
932 virtual BailoutId ContinueId() const V8_OVERRIDE { return EntryId(); } | 977 virtual BailoutId ContinueId() const V8_OVERRIDE { return EntryId(); } |
933 virtual BailoutId StackCheckId() const V8_OVERRIDE { return body_id_; } | 978 virtual BailoutId StackCheckId() const V8_OVERRIDE { return body_id_; } |
934 | 979 |
935 protected: | 980 protected: |
936 ForInStatement(Zone* zone, ZoneStringList* labels, int pos) | 981 ForInStatement(Zone* zone, ZoneStringList* labels, int pos) |
937 : ForEachStatement(zone, labels, pos), | 982 : ForEachStatement(zone, labels, pos), |
938 for_in_type_(SLOW_FOR_IN), | 983 for_in_type_(SLOW_FOR_IN), |
984 for_in_feedback_slot_(kInvalidFeedbackSlot), | |
939 body_id_(GetNextId(zone)), | 985 body_id_(GetNextId(zone)), |
940 prepare_id_(GetNextId(zone)) { | 986 prepare_id_(GetNextId(zone)) { |
941 } | 987 } |
942 | 988 |
943 ForInType for_in_type_; | 989 ForInType for_in_type_; |
990 int for_in_feedback_slot_; | |
944 const BailoutId body_id_; | 991 const BailoutId body_id_; |
945 const BailoutId prepare_id_; | 992 const BailoutId prepare_id_; |
946 }; | 993 }; |
947 | 994 |
948 | 995 |
949 class ForOfStatement V8_FINAL : public ForEachStatement { | 996 class ForOfStatement V8_FINAL : public ForEachStatement { |
950 public: | 997 public: |
951 DECLARE_NODE_TYPE(ForOfStatement) | 998 DECLARE_NODE_TYPE(ForOfStatement) |
952 | 999 |
953 void Initialize(Expression* each, | 1000 void Initialize(Expression* each, |
(...skipping 772 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1726 const BailoutId load_id_; | 1773 const BailoutId load_id_; |
1727 | 1774 |
1728 SmallMapList receiver_types_; | 1775 SmallMapList receiver_types_; |
1729 bool is_pre_monomorphic_ : 1; | 1776 bool is_pre_monomorphic_ : 1; |
1730 bool is_uninitialized_ : 1; | 1777 bool is_uninitialized_ : 1; |
1731 bool is_string_access_ : 1; | 1778 bool is_string_access_ : 1; |
1732 bool is_function_prototype_ : 1; | 1779 bool is_function_prototype_ : 1; |
1733 }; | 1780 }; |
1734 | 1781 |
1735 | 1782 |
1736 class Call V8_FINAL : public Expression { | 1783 class Call V8_FINAL : public Expression, public FeedbackSlotInterface { |
1737 public: | 1784 public: |
1738 DECLARE_NODE_TYPE(Call) | 1785 DECLARE_NODE_TYPE(Call) |
1739 | 1786 |
1740 Expression* expression() const { return expression_; } | 1787 Expression* expression() const { return expression_; } |
1741 ZoneList<Expression*>* arguments() const { return arguments_; } | 1788 ZoneList<Expression*>* arguments() const { return arguments_; } |
1742 | 1789 |
1743 // Type feedback information. | 1790 // Type feedback information. |
1791 virtual FeedbackSlotInterface* SupportsFeedbackSlots() { return this; } | |
1792 virtual int GetFeedbackSlotCount(Isolate* isolate); | |
1793 virtual void SetFirstFeedbackSlot(int slot) { | |
1794 call_feedback_slot_ = slot; | |
1795 } | |
1796 | |
1797 bool HasCallFeedbackSlot() const { | |
1798 return call_feedback_slot_ != kInvalidFeedbackSlot; | |
1799 } | |
1800 int CallFeedbackSlot() const { return call_feedback_slot_; } | |
1801 | |
1802 // Type feedback information. | |
1744 TypeFeedbackId CallFeedbackId() const { return reuse(id()); } | 1803 TypeFeedbackId CallFeedbackId() const { return reuse(id()); } |
1745 void RecordTypeFeedback(TypeFeedbackOracle* oracle); | 1804 void RecordTypeFeedback(TypeFeedbackOracle* oracle); |
1746 virtual SmallMapList* GetReceiverTypes() V8_OVERRIDE { | 1805 virtual SmallMapList* GetReceiverTypes() V8_OVERRIDE { |
1747 return &receiver_types_; | 1806 return &receiver_types_; |
1748 } | 1807 } |
1749 virtual bool IsMonomorphic() V8_OVERRIDE { return is_monomorphic_; } | 1808 virtual bool IsMonomorphic() V8_OVERRIDE { return is_monomorphic_; } |
1750 bool KeyedArrayCallIsHoley() { return keyed_array_call_is_holey_; } | 1809 bool KeyedArrayCallIsHoley() { return keyed_array_call_is_holey_; } |
1751 CheckType check_type() const { return check_type_; } | 1810 CheckType check_type() const { return check_type_; } |
1752 | 1811 |
1753 void set_string_check(Handle<JSObject> holder) { | 1812 void set_string_check(Handle<JSObject> holder) { |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1804 Call(Zone* zone, | 1863 Call(Zone* zone, |
1805 Expression* expression, | 1864 Expression* expression, |
1806 ZoneList<Expression*>* arguments, | 1865 ZoneList<Expression*>* arguments, |
1807 int pos) | 1866 int pos) |
1808 : Expression(zone, pos), | 1867 : Expression(zone, pos), |
1809 expression_(expression), | 1868 expression_(expression), |
1810 arguments_(arguments), | 1869 arguments_(arguments), |
1811 is_monomorphic_(false), | 1870 is_monomorphic_(false), |
1812 keyed_array_call_is_holey_(true), | 1871 keyed_array_call_is_holey_(true), |
1813 check_type_(RECEIVER_MAP_CHECK), | 1872 check_type_(RECEIVER_MAP_CHECK), |
1873 call_feedback_slot_(kInvalidFeedbackSlot), | |
1814 return_id_(GetNextId(zone)) { } | 1874 return_id_(GetNextId(zone)) { } |
1815 | 1875 |
1816 private: | 1876 private: |
1817 Expression* expression_; | 1877 Expression* expression_; |
1818 ZoneList<Expression*>* arguments_; | 1878 ZoneList<Expression*>* arguments_; |
1819 | 1879 |
1820 bool is_monomorphic_; | 1880 bool is_monomorphic_; |
1821 bool keyed_array_call_is_holey_; | 1881 bool keyed_array_call_is_holey_; |
1822 CheckType check_type_; | 1882 CheckType check_type_; |
1823 SmallMapList receiver_types_; | 1883 SmallMapList receiver_types_; |
1824 Handle<JSFunction> target_; | 1884 Handle<JSFunction> target_; |
1825 Handle<JSObject> holder_; | 1885 Handle<JSObject> holder_; |
1826 Handle<Cell> cell_; | 1886 Handle<Cell> cell_; |
1887 int call_feedback_slot_; | |
1827 | 1888 |
1828 const BailoutId return_id_; | 1889 const BailoutId return_id_; |
1829 }; | 1890 }; |
1830 | 1891 |
1831 | 1892 |
1832 class CallNew V8_FINAL : public Expression { | 1893 class CallNew V8_FINAL : public Expression, public FeedbackSlotInterface { |
1833 public: | 1894 public: |
1834 DECLARE_NODE_TYPE(CallNew) | 1895 DECLARE_NODE_TYPE(CallNew) |
1835 | 1896 |
1836 Expression* expression() const { return expression_; } | 1897 Expression* expression() const { return expression_; } |
1837 ZoneList<Expression*>* arguments() const { return arguments_; } | 1898 ZoneList<Expression*>* arguments() const { return arguments_; } |
1838 | 1899 |
1839 // Type feedback information. | 1900 // Type feedback information. |
1901 virtual FeedbackSlotInterface* SupportsFeedbackSlots() { return this; } | |
1902 virtual int GetFeedbackSlotCount(Isolate* isolate) { return 1; } | |
1903 virtual void SetFirstFeedbackSlot(int slot) { | |
1904 callnew_feedback_slot_ = slot; | |
1905 } | |
1906 | |
1907 int CallNewFeedbackSlot() { | |
1908 ASSERT(callnew_feedback_slot_ != kInvalidFeedbackSlot); | |
1909 return callnew_feedback_slot_; | |
1910 } | |
1911 | |
1840 TypeFeedbackId CallNewFeedbackId() const { return reuse(id()); } | 1912 TypeFeedbackId CallNewFeedbackId() const { return reuse(id()); } |
1841 void RecordTypeFeedback(TypeFeedbackOracle* oracle); | 1913 void RecordTypeFeedback(TypeFeedbackOracle* oracle); |
1842 virtual bool IsMonomorphic() V8_OVERRIDE { return is_monomorphic_; } | 1914 virtual bool IsMonomorphic() V8_OVERRIDE { return is_monomorphic_; } |
1843 Handle<JSFunction> target() const { return target_; } | 1915 Handle<JSFunction> target() const { return target_; } |
1844 ElementsKind elements_kind() const { return elements_kind_; } | 1916 ElementsKind elements_kind() const { return elements_kind_; } |
1845 Handle<AllocationSite> allocation_site() const { | 1917 Handle<AllocationSite> allocation_site() const { |
1846 return allocation_site_; | 1918 return allocation_site_; |
1847 } | 1919 } |
1848 | 1920 |
1921 static int feedback_slots() { return 1; } | |
1922 | |
1849 BailoutId ReturnId() const { return return_id_; } | 1923 BailoutId ReturnId() const { return return_id_; } |
1850 | 1924 |
1851 protected: | 1925 protected: |
1852 CallNew(Zone* zone, | 1926 CallNew(Zone* zone, |
1853 Expression* expression, | 1927 Expression* expression, |
1854 ZoneList<Expression*>* arguments, | 1928 ZoneList<Expression*>* arguments, |
1855 int pos) | 1929 int pos) |
1856 : Expression(zone, pos), | 1930 : Expression(zone, pos), |
1857 expression_(expression), | 1931 expression_(expression), |
1858 arguments_(arguments), | 1932 arguments_(arguments), |
1859 is_monomorphic_(false), | 1933 is_monomorphic_(false), |
1860 elements_kind_(GetInitialFastElementsKind()), | 1934 elements_kind_(GetInitialFastElementsKind()), |
1935 callnew_feedback_slot_(kInvalidFeedbackSlot), | |
1861 return_id_(GetNextId(zone)) { } | 1936 return_id_(GetNextId(zone)) { } |
1862 | 1937 |
1863 private: | 1938 private: |
1864 Expression* expression_; | 1939 Expression* expression_; |
1865 ZoneList<Expression*>* arguments_; | 1940 ZoneList<Expression*>* arguments_; |
1866 | 1941 |
1867 bool is_monomorphic_; | 1942 bool is_monomorphic_; |
1868 Handle<JSFunction> target_; | 1943 Handle<JSFunction> target_; |
1869 ElementsKind elements_kind_; | 1944 ElementsKind elements_kind_; |
1870 Handle<AllocationSite> allocation_site_; | 1945 Handle<AllocationSite> allocation_site_; |
1946 Handle<Cell> allocation_info_cell_; | |
1947 int callnew_feedback_slot_; | |
1871 | 1948 |
1872 const BailoutId return_id_; | 1949 const BailoutId return_id_; |
1873 }; | 1950 }; |
1874 | 1951 |
1875 | 1952 |
1876 // The CallRuntime class does not represent any official JavaScript | 1953 // The CallRuntime class does not represent any official JavaScript |
1877 // language construct. Instead it is used to call a C or JS function | 1954 // language construct. Instead it is used to call a C or JS function |
1878 // with a set of arguments. This is used from the builtins that are | 1955 // with a set of arguments. This is used from the builtins that are |
1879 // implemented in JavaScript (see "v8natives.js"). | 1956 // implemented in JavaScript (see "v8natives.js"). |
1880 class CallRuntime V8_FINAL : public Expression { | 1957 class CallRuntime V8_FINAL : public Expression { |
(...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2350 | 2427 |
2351 bool is_generator() { | 2428 bool is_generator() { |
2352 return IsGenerator::decode(bitfield_) == kIsGenerator; | 2429 return IsGenerator::decode(bitfield_) == kIsGenerator; |
2353 } | 2430 } |
2354 | 2431 |
2355 int ast_node_count() { return ast_properties_.node_count(); } | 2432 int ast_node_count() { return ast_properties_.node_count(); } |
2356 AstProperties::Flags* flags() { return ast_properties_.flags(); } | 2433 AstProperties::Flags* flags() { return ast_properties_.flags(); } |
2357 void set_ast_properties(AstProperties* ast_properties) { | 2434 void set_ast_properties(AstProperties* ast_properties) { |
2358 ast_properties_ = *ast_properties; | 2435 ast_properties_ = *ast_properties; |
2359 } | 2436 } |
2360 | 2437 ZoneList<FeedbackSlotInterface*>* slot_nodes() { |
2438 return ast_properties_.slot_nodes(); | |
2439 } | |
2440 int slot_count() { | |
2441 return ast_properties_.slot_count(); | |
2442 } | |
2443 void set_slot_count(int count) { | |
2444 ast_properties_.set_slot_count(count); | |
2445 } | |
2361 bool dont_optimize() { return dont_optimize_reason_ != kNoReason; } | 2446 bool dont_optimize() { return dont_optimize_reason_ != kNoReason; } |
2362 BailoutReason dont_optimize_reason() { return dont_optimize_reason_; } | 2447 BailoutReason dont_optimize_reason() { return dont_optimize_reason_; } |
2363 void set_dont_optimize_reason(BailoutReason reason) { | 2448 void set_dont_optimize_reason(BailoutReason reason) { |
2364 dont_optimize_reason_ = reason; | 2449 dont_optimize_reason_ = reason; |
2365 } | 2450 } |
2366 | 2451 |
2367 protected: | 2452 protected: |
2368 FunctionLiteral(Zone* zone, | 2453 FunctionLiteral(Zone* zone, |
2369 Handle<String> name, | 2454 Handle<String> name, |
2370 Scope* scope, | 2455 Scope* scope, |
(...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2874 \ | 2959 \ |
2875 Zone* zone_; \ | 2960 Zone* zone_; \ |
2876 bool stack_overflow_ | 2961 bool stack_overflow_ |
2877 | 2962 |
2878 | 2963 |
2879 // ---------------------------------------------------------------------------- | 2964 // ---------------------------------------------------------------------------- |
2880 // Construction time visitor. | 2965 // Construction time visitor. |
2881 | 2966 |
2882 class AstConstructionVisitor BASE_EMBEDDED { | 2967 class AstConstructionVisitor BASE_EMBEDDED { |
2883 public: | 2968 public: |
2884 AstConstructionVisitor() : dont_optimize_reason_(kNoReason) { } | 2969 explicit AstConstructionVisitor(Zone* zone) |
2970 : dont_optimize_reason_(kNoReason), | |
mvstanton
2014/01/30 15:13:41
pass the deferred worker here.
mvstanton
2014/01/30 17:37:41
As it turns out, the AstConstructionVisitor can cr
| |
2971 zone_(zone) { } | |
2885 | 2972 |
2886 AstProperties* ast_properties() { return &properties_; } | 2973 AstProperties* ast_properties() { return &properties_; } |
2887 BailoutReason dont_optimize_reason() { return dont_optimize_reason_; } | 2974 BailoutReason dont_optimize_reason() { return dont_optimize_reason_; } |
2888 | 2975 |
2889 private: | 2976 private: |
2890 template<class> friend class AstNodeFactory; | 2977 template<class> friend class AstNodeFactory; |
2891 | 2978 |
2892 // Node visitors. | 2979 // Node visitors. |
2893 #define DEF_VISIT(type) \ | 2980 #define DEF_VISIT(type) \ |
2894 void Visit##type(type* node); | 2981 void Visit##type(type* node); |
2895 AST_NODE_LIST(DEF_VISIT) | 2982 AST_NODE_LIST(DEF_VISIT) |
2896 #undef DEF_VISIT | 2983 #undef DEF_VISIT |
2897 | 2984 |
2898 void increase_node_count() { properties_.add_node_count(1); } | 2985 void increase_node_count() { properties_.add_node_count(1); } |
2899 void add_flag(AstPropertiesFlag flag) { properties_.flags()->Add(flag); } | 2986 void add_flag(AstPropertiesFlag flag) { properties_.flags()->Add(flag); } |
2900 void set_dont_optimize_reason(BailoutReason reason) { | 2987 void set_dont_optimize_reason(BailoutReason reason) { |
2901 dont_optimize_reason_ = reason; | 2988 dont_optimize_reason_ = reason; |
2902 } | 2989 } |
2903 | 2990 |
2991 void AddFeedbackSlotInterface(FeedbackSlotInterface* fsi) { | |
2992 if (fsi != NULL) { | |
2993 properties_.add_slot_node(zone_, fsi); | |
2994 } | |
2995 } | |
2996 | |
2904 AstProperties properties_; | 2997 AstProperties properties_; |
2905 BailoutReason dont_optimize_reason_; | 2998 BailoutReason dont_optimize_reason_; |
2999 Zone* zone_; | |
2906 }; | 3000 }; |
2907 | 3001 |
2908 | 3002 |
2909 class AstNullVisitor BASE_EMBEDDED { | 3003 class AstNullVisitor BASE_EMBEDDED { |
2910 public: | 3004 public: |
3005 explicit AstNullVisitor(Zone* zone) {} | |
3006 | |
2911 // Node visitors. | 3007 // Node visitors. |
2912 #define DEF_VISIT(type) \ | 3008 #define DEF_VISIT(type) \ |
2913 void Visit##type(type* node) {} | 3009 void Visit##type(type* node) {} |
2914 AST_NODE_LIST(DEF_VISIT) | 3010 AST_NODE_LIST(DEF_VISIT) |
2915 #undef DEF_VISIT | 3011 #undef DEF_VISIT |
2916 }; | 3012 }; |
2917 | 3013 |
2918 | 3014 |
2919 | 3015 |
2920 // ---------------------------------------------------------------------------- | 3016 // ---------------------------------------------------------------------------- |
2921 // AstNode factory | 3017 // AstNode factory |
2922 | 3018 |
2923 template<class Visitor> | 3019 template<class Visitor> |
2924 class AstNodeFactory V8_FINAL BASE_EMBEDDED { | 3020 class AstNodeFactory V8_FINAL BASE_EMBEDDED { |
2925 public: | 3021 public: |
2926 explicit AstNodeFactory(Zone* zone) : zone_(zone) { } | 3022 explicit AstNodeFactory(Zone* zone) |
3023 : zone_(zone), | |
3024 visitor_(zone) { } | |
2927 | 3025 |
2928 Visitor* visitor() { return &visitor_; } | 3026 Visitor* visitor() { return &visitor_; } |
2929 | 3027 |
2930 #define VISIT_AND_RETURN(NodeType, node) \ | 3028 #define VISIT_AND_RETURN(NodeType, node) \ |
2931 visitor_.Visit##NodeType((node)); \ | 3029 visitor_.Visit##NodeType((node)); \ |
2932 return node; | 3030 return node; |
2933 | 3031 |
2934 VariableDeclaration* NewVariableDeclaration(VariableProxy* proxy, | 3032 VariableDeclaration* NewVariableDeclaration(VariableProxy* proxy, |
2935 VariableMode mode, | 3033 VariableMode mode, |
2936 Scope* scope, | 3034 Scope* scope, |
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3321 | 3419 |
3322 private: | 3420 private: |
3323 Zone* zone_; | 3421 Zone* zone_; |
3324 Visitor visitor_; | 3422 Visitor visitor_; |
3325 }; | 3423 }; |
3326 | 3424 |
3327 | 3425 |
3328 } } // namespace v8::internal | 3426 } } // namespace v8::internal |
3329 | 3427 |
3330 #endif // V8_AST_H_ | 3428 #endif // V8_AST_H_ |
OLD | NEW |