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 2123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 } |
2317 | 2316 |
2317 bool dont_optimize() { return dont_optimize_reason_ != kNoReason; } | |
2318 BailoutReason dont_optimize_reason() { return dont_optimize_reason_; } | |
2319 void set_dont_optimize_reason(BailoutReason reason) { | |
2320 dont_optimize_reason_ = reason; | |
2321 } | |
2322 | |
2318 protected: | 2323 protected: |
2319 FunctionLiteral(Isolate* isolate, | 2324 FunctionLiteral(Isolate* isolate, |
2320 Handle<String> name, | 2325 Handle<String> name, |
2321 Scope* scope, | 2326 Scope* scope, |
2322 ZoneList<Statement*>* body, | 2327 ZoneList<Statement*>* body, |
2323 int materialized_literal_count, | 2328 int materialized_literal_count, |
2324 int expected_property_count, | 2329 int expected_property_count, |
2325 int handler_count, | 2330 int handler_count, |
2326 int parameter_count, | 2331 int parameter_count, |
2327 FunctionType function_type, | 2332 FunctionType function_type, |
2328 ParameterFlag has_duplicate_parameters, | 2333 ParameterFlag has_duplicate_parameters, |
2329 IsFunctionFlag is_function, | 2334 IsFunctionFlag is_function, |
2330 IsParenthesizedFlag is_parenthesized, | 2335 IsParenthesizedFlag is_parenthesized, |
2331 IsGeneratorFlag is_generator) | 2336 IsGeneratorFlag is_generator) |
2332 : Expression(isolate), | 2337 : Expression(isolate), |
2333 name_(name), | 2338 name_(name), |
2334 scope_(scope), | 2339 scope_(scope), |
2335 body_(body), | 2340 body_(body), |
2336 inferred_name_(isolate->factory()->empty_string()), | 2341 inferred_name_(isolate->factory()->empty_string()), |
2342 dont_optimize_reason_(kNoReason), | |
2337 materialized_literal_count_(materialized_literal_count), | 2343 materialized_literal_count_(materialized_literal_count), |
2338 expected_property_count_(expected_property_count), | 2344 expected_property_count_(expected_property_count), |
2339 handler_count_(handler_count), | 2345 handler_count_(handler_count), |
2340 parameter_count_(parameter_count), | 2346 parameter_count_(parameter_count), |
2341 function_token_position_(RelocInfo::kNoPosition) { | 2347 function_token_position_(RelocInfo::kNoPosition) { |
2342 bitfield_ = | 2348 bitfield_ = |
2343 IsExpression::encode(function_type != DECLARATION) | | 2349 IsExpression::encode(function_type != DECLARATION) | |
2344 IsAnonymous::encode(function_type == ANONYMOUS_EXPRESSION) | | 2350 IsAnonymous::encode(function_type == ANONYMOUS_EXPRESSION) | |
2345 Pretenure::encode(false) | | 2351 Pretenure::encode(false) | |
2346 HasDuplicateParameters::encode(has_duplicate_parameters) | | 2352 HasDuplicateParameters::encode(has_duplicate_parameters) | |
2347 IsFunction::encode(is_function) | | 2353 IsFunction::encode(is_function) | |
2348 IsParenthesized::encode(is_parenthesized) | | 2354 IsParenthesized::encode(is_parenthesized) | |
2349 IsGenerator::encode(is_generator); | 2355 IsGenerator::encode(is_generator); |
2350 } | 2356 } |
2351 | 2357 |
2352 private: | 2358 private: |
2353 Handle<String> name_; | 2359 Handle<String> name_; |
2354 Scope* scope_; | 2360 Scope* scope_; |
2355 ZoneList<Statement*>* body_; | 2361 ZoneList<Statement*>* body_; |
2356 Handle<String> inferred_name_; | 2362 Handle<String> inferred_name_; |
2357 AstProperties ast_properties_; | 2363 AstProperties ast_properties_; |
2364 BailoutReason dont_optimize_reason_; | |
2358 | 2365 |
2359 int materialized_literal_count_; | 2366 int materialized_literal_count_; |
2360 int expected_property_count_; | 2367 int expected_property_count_; |
2361 int handler_count_; | 2368 int handler_count_; |
2362 int parameter_count_; | 2369 int parameter_count_; |
2363 int function_token_position_; | 2370 int function_token_position_; |
2364 | 2371 |
2365 unsigned bitfield_; | 2372 unsigned bitfield_; |
2366 class IsExpression: public BitField<bool, 0, 1> {}; | 2373 class IsExpression: public BitField<bool, 0, 1> {}; |
2367 class IsAnonymous: public BitField<bool, 1, 1> {}; | 2374 class IsAnonymous: public BitField<bool, 1, 1> {}; |
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2822 \ | 2829 \ |
2823 Isolate* isolate_; \ | 2830 Isolate* isolate_; \ |
2824 bool stack_overflow_ | 2831 bool stack_overflow_ |
2825 | 2832 |
2826 | 2833 |
2827 // ---------------------------------------------------------------------------- | 2834 // ---------------------------------------------------------------------------- |
2828 // Construction time visitor. | 2835 // Construction time visitor. |
2829 | 2836 |
2830 class AstConstructionVisitor BASE_EMBEDDED { | 2837 class AstConstructionVisitor BASE_EMBEDDED { |
2831 public: | 2838 public: |
2832 AstConstructionVisitor() { } | 2839 AstConstructionVisitor() : dont_optimize_reason_(kNoReason) { |
2840 } | |
Yang
2013/09/04 15:18:56
you can put that } on the previous line.
loislo
2013/09/05 07:47:58
Done.
| |
2833 | 2841 |
2834 AstProperties* ast_properties() { return &properties_; } | 2842 AstProperties* ast_properties() { return &properties_; } |
2843 BailoutReason dont_optimize_reason() { return dont_optimize_reason_; } | |
2835 | 2844 |
2836 private: | 2845 private: |
2837 template<class> friend class AstNodeFactory; | 2846 template<class> friend class AstNodeFactory; |
2838 | 2847 |
2839 // Node visitors. | 2848 // Node visitors. |
2840 #define DEF_VISIT(type) \ | 2849 #define DEF_VISIT(type) \ |
2841 void Visit##type(type* node); | 2850 void Visit##type(type* node); |
2842 AST_NODE_LIST(DEF_VISIT) | 2851 AST_NODE_LIST(DEF_VISIT) |
2843 #undef DEF_VISIT | 2852 #undef DEF_VISIT |
2844 | 2853 |
2845 void increase_node_count() { properties_.add_node_count(1); } | 2854 void increase_node_count() { properties_.add_node_count(1); } |
2846 void add_flag(AstPropertiesFlag flag) { properties_.flags()->Add(flag); } | 2855 void add_flag(AstPropertiesFlag flag) { properties_.flags()->Add(flag); } |
2856 void set_dont_optimize_reason(BailoutReason reason) { | |
2857 dont_optimize_reason_ = reason; | |
2858 } | |
2847 | 2859 |
2848 AstProperties properties_; | 2860 AstProperties properties_; |
2861 BailoutReason dont_optimize_reason_; | |
2849 }; | 2862 }; |
2850 | 2863 |
2851 | 2864 |
2852 class AstNullVisitor BASE_EMBEDDED { | 2865 class AstNullVisitor BASE_EMBEDDED { |
2853 public: | 2866 public: |
2854 // Node visitors. | 2867 // Node visitors. |
2855 #define DEF_VISIT(type) \ | 2868 #define DEF_VISIT(type) \ |
2856 void Visit##type(type* node) {} | 2869 void Visit##type(type* node) {} |
2857 AST_NODE_LIST(DEF_VISIT) | 2870 AST_NODE_LIST(DEF_VISIT) |
2858 #undef DEF_VISIT | 2871 #undef DEF_VISIT |
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3242 private: | 3255 private: |
3243 Isolate* isolate_; | 3256 Isolate* isolate_; |
3244 Zone* zone_; | 3257 Zone* zone_; |
3245 Visitor visitor_; | 3258 Visitor visitor_; |
3246 }; | 3259 }; |
3247 | 3260 |
3248 | 3261 |
3249 } } // namespace v8::internal | 3262 } } // namespace v8::internal |
3250 | 3263 |
3251 #endif // V8_AST_H_ | 3264 #endif // V8_AST_H_ |
OLD | NEW |