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 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
164 #define DECLARE_NODE_TYPE(type) \ | 164 #define DECLARE_NODE_TYPE(type) \ |
165 virtual void Accept(AstVisitor* v) V8_OVERRIDE; \ | 165 virtual void Accept(AstVisitor* v) V8_OVERRIDE; \ |
166 virtual AstNode::NodeType node_type() const V8_FINAL V8_OVERRIDE { \ | 166 virtual AstNode::NodeType node_type() const V8_FINAL V8_OVERRIDE { \ |
167 return AstNode::k##type; \ | 167 return AstNode::k##type; \ |
168 } \ | 168 } \ |
169 template<class> friend class AstNodeFactory; | 169 template<class> friend class AstNodeFactory; |
170 | 170 |
171 | 171 |
172 enum AstPropertiesFlag { | 172 enum AstPropertiesFlag { |
173 kDontInline, | 173 kDontInline, |
174 kDontOptimize, | |
175 kDontSelfOptimize, | 174 kDontSelfOptimize, |
176 kDontSoftInline, | 175 kDontSoftInline, |
177 kDontCache | 176 kDontCache |
178 }; | 177 }; |
179 | 178 |
180 | 179 |
181 class AstProperties V8_FINAL BASE_EMBEDDED { | 180 class AstProperties V8_FINAL BASE_EMBEDDED { |
182 public: | 181 public: |
183 class Flags : public EnumSet<AstPropertiesFlag, int> {}; | 182 class Flags : public EnumSet<AstPropertiesFlag, int> {}; |
184 | 183 |
(...skipping 2122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2307 | 2306 |
2308 bool is_generator() { | 2307 bool is_generator() { |
2309 return IsGenerator::decode(bitfield_) == kIsGenerator; | 2308 return IsGenerator::decode(bitfield_) == kIsGenerator; |
2310 } | 2309 } |
2311 | 2310 |
2312 int ast_node_count() { return ast_properties_.node_count(); } | 2311 int ast_node_count() { return ast_properties_.node_count(); } |
2313 AstProperties::Flags* flags() { return ast_properties_.flags(); } | 2312 AstProperties::Flags* flags() { return ast_properties_.flags(); } |
2314 void set_ast_properties(AstProperties* ast_properties) { | 2313 void set_ast_properties(AstProperties* ast_properties) { |
2315 ast_properties_ = *ast_properties; | 2314 ast_properties_ = *ast_properties; |
2316 } | 2315 } |
2316 inline BailoutReason dont_optimize_reason() { | |
yurys
2013/09/02 14:40:05
No need to add inline, the compiler should be smar
loislo
2013/09/02 16:03:45
Done.
| |
2317 return dont_optimize_reason_; | |
2318 } | |
2319 inline void set_dont_optimize_reason(BailoutReason reason) { | |
2320 dont_optimize_reason_ = reason; | |
2321 } | |
2322 inline bool dont_optimize() { | |
2323 return dont_optimize_reason_ != kNoReason; | |
2324 } | |
2317 | 2325 |
2318 protected: | 2326 protected: |
2319 FunctionLiteral(Isolate* isolate, | 2327 FunctionLiteral(Isolate* isolate, |
2320 Handle<String> name, | 2328 Handle<String> name, |
2321 Scope* scope, | 2329 Scope* scope, |
2322 ZoneList<Statement*>* body, | 2330 ZoneList<Statement*>* body, |
2323 int materialized_literal_count, | 2331 int materialized_literal_count, |
2324 int expected_property_count, | 2332 int expected_property_count, |
2325 int handler_count, | 2333 int handler_count, |
2326 int parameter_count, | 2334 int parameter_count, |
2327 FunctionType function_type, | 2335 FunctionType function_type, |
2328 ParameterFlag has_duplicate_parameters, | 2336 ParameterFlag has_duplicate_parameters, |
2329 IsFunctionFlag is_function, | 2337 IsFunctionFlag is_function, |
2330 IsParenthesizedFlag is_parenthesized, | 2338 IsParenthesizedFlag is_parenthesized, |
2331 IsGeneratorFlag is_generator) | 2339 IsGeneratorFlag is_generator) |
2332 : Expression(isolate), | 2340 : Expression(isolate), |
2333 name_(name), | 2341 name_(name), |
2334 scope_(scope), | 2342 scope_(scope), |
2335 body_(body), | 2343 body_(body), |
2336 inferred_name_(isolate->factory()->empty_string()), | 2344 inferred_name_(isolate->factory()->empty_string()), |
2345 dont_optimize_reason_(kNoReason), | |
2337 materialized_literal_count_(materialized_literal_count), | 2346 materialized_literal_count_(materialized_literal_count), |
2338 expected_property_count_(expected_property_count), | 2347 expected_property_count_(expected_property_count), |
2339 handler_count_(handler_count), | 2348 handler_count_(handler_count), |
2340 parameter_count_(parameter_count), | 2349 parameter_count_(parameter_count), |
2341 function_token_position_(RelocInfo::kNoPosition) { | 2350 function_token_position_(RelocInfo::kNoPosition) { |
2342 bitfield_ = | 2351 bitfield_ = |
2343 IsExpression::encode(function_type != DECLARATION) | | 2352 IsExpression::encode(function_type != DECLARATION) | |
2344 IsAnonymous::encode(function_type == ANONYMOUS_EXPRESSION) | | 2353 IsAnonymous::encode(function_type == ANONYMOUS_EXPRESSION) | |
2345 Pretenure::encode(false) | | 2354 Pretenure::encode(false) | |
2346 HasDuplicateParameters::encode(has_duplicate_parameters) | | 2355 HasDuplicateParameters::encode(has_duplicate_parameters) | |
2347 IsFunction::encode(is_function) | | 2356 IsFunction::encode(is_function) | |
2348 IsParenthesized::encode(is_parenthesized) | | 2357 IsParenthesized::encode(is_parenthesized) | |
2349 IsGenerator::encode(is_generator); | 2358 IsGenerator::encode(is_generator); |
2350 } | 2359 } |
2351 | 2360 |
2352 private: | 2361 private: |
2353 Handle<String> name_; | 2362 Handle<String> name_; |
2354 Scope* scope_; | 2363 Scope* scope_; |
2355 ZoneList<Statement*>* body_; | 2364 ZoneList<Statement*>* body_; |
2356 Handle<String> inferred_name_; | 2365 Handle<String> inferred_name_; |
2357 AstProperties ast_properties_; | 2366 AstProperties ast_properties_; |
2367 BailoutReason dont_optimize_reason_; | |
2358 | 2368 |
2359 int materialized_literal_count_; | 2369 int materialized_literal_count_; |
2360 int expected_property_count_; | 2370 int expected_property_count_; |
2361 int handler_count_; | 2371 int handler_count_; |
2362 int parameter_count_; | 2372 int parameter_count_; |
2363 int function_token_position_; | 2373 int function_token_position_; |
2364 | 2374 |
2365 unsigned bitfield_; | 2375 unsigned bitfield_; |
2366 class IsExpression: public BitField<bool, 0, 1> {}; | 2376 class IsExpression: public BitField<bool, 0, 1> {}; |
2367 class IsAnonymous: public BitField<bool, 1, 1> {}; | 2377 class IsAnonymous: public BitField<bool, 1, 1> {}; |
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2822 \ | 2832 \ |
2823 Isolate* isolate_; \ | 2833 Isolate* isolate_; \ |
2824 bool stack_overflow_ | 2834 bool stack_overflow_ |
2825 | 2835 |
2826 | 2836 |
2827 // ---------------------------------------------------------------------------- | 2837 // ---------------------------------------------------------------------------- |
2828 // Construction time visitor. | 2838 // Construction time visitor. |
2829 | 2839 |
2830 class AstConstructionVisitor BASE_EMBEDDED { | 2840 class AstConstructionVisitor BASE_EMBEDDED { |
2831 public: | 2841 public: |
2832 AstConstructionVisitor() { } | 2842 AstConstructionVisitor() : dont_optimize_reason_(kNoReason) { |
2843 } | |
2833 | 2844 |
2834 AstProperties* ast_properties() { return &properties_; } | 2845 AstProperties* ast_properties() { return &properties_; } |
2846 BailoutReason dont_optimize_reason() { return dont_optimize_reason_; } | |
2835 | 2847 |
2836 private: | 2848 private: |
2837 template<class> friend class AstNodeFactory; | 2849 template<class> friend class AstNodeFactory; |
2838 | 2850 |
2839 // Node visitors. | 2851 // Node visitors. |
2840 #define DEF_VISIT(type) \ | 2852 #define DEF_VISIT(type) \ |
2841 void Visit##type(type* node); | 2853 void Visit##type(type* node); |
2842 AST_NODE_LIST(DEF_VISIT) | 2854 AST_NODE_LIST(DEF_VISIT) |
2843 #undef DEF_VISIT | 2855 #undef DEF_VISIT |
2844 | 2856 |
2845 void increase_node_count() { properties_.add_node_count(1); } | 2857 void increase_node_count() { properties_.add_node_count(1); } |
2846 void add_flag(AstPropertiesFlag flag) { properties_.flags()->Add(flag); } | 2858 void add_flag(AstPropertiesFlag flag) { properties_.flags()->Add(flag); } |
2859 void set_dont_optimize_reason(BailoutReason reason) { | |
2860 dont_optimize_reason_ = reason; | |
2861 } | |
2847 | 2862 |
2848 AstProperties properties_; | 2863 AstProperties properties_; |
2864 BailoutReason dont_optimize_reason_; | |
2849 }; | 2865 }; |
2850 | 2866 |
2851 | 2867 |
2852 class AstNullVisitor BASE_EMBEDDED { | 2868 class AstNullVisitor BASE_EMBEDDED { |
2853 public: | 2869 public: |
2854 // Node visitors. | 2870 // Node visitors. |
2855 #define DEF_VISIT(type) \ | 2871 #define DEF_VISIT(type) \ |
2856 void Visit##type(type* node) {} | 2872 void Visit##type(type* node) {} |
2857 AST_NODE_LIST(DEF_VISIT) | 2873 AST_NODE_LIST(DEF_VISIT) |
2858 #undef DEF_VISIT | 2874 #undef DEF_VISIT |
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3242 private: | 3258 private: |
3243 Isolate* isolate_; | 3259 Isolate* isolate_; |
3244 Zone* zone_; | 3260 Zone* zone_; |
3245 Visitor visitor_; | 3261 Visitor visitor_; |
3246 }; | 3262 }; |
3247 | 3263 |
3248 | 3264 |
3249 } } // namespace v8::internal | 3265 } } // namespace v8::internal |
3250 | 3266 |
3251 #endif // V8_AST_H_ | 3267 #endif // V8_AST_H_ |
OLD | NEW |