| OLD | NEW |
| 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_AST_H_ | 5 #ifndef V8_AST_AST_H_ |
| 6 #define V8_AST_AST_H_ | 6 #define V8_AST_AST_H_ |
| 7 | 7 |
| 8 #include "src/ast/ast-types.h" | 8 #include "src/ast/ast-types.h" |
| 9 #include "src/ast/ast-value-factory.h" | 9 #include "src/ast/ast-value-factory.h" |
| 10 #include "src/ast/modules.h" | 10 #include "src/ast/modules.h" |
| (...skipping 886 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 897 | 897 |
| 898 class ReturnStatement final : public JumpStatement { | 898 class ReturnStatement final : public JumpStatement { |
| 899 public: | 899 public: |
| 900 enum Type { kNormal, kAsyncReturn }; | 900 enum Type { kNormal, kAsyncReturn }; |
| 901 Expression* expression() const { return expression_; } | 901 Expression* expression() const { return expression_; } |
| 902 | 902 |
| 903 void set_expression(Expression* e) { expression_ = e; } | 903 void set_expression(Expression* e) { expression_ = e; } |
| 904 Type type() const { return TypeField::decode(bit_field_); } | 904 Type type() const { return TypeField::decode(bit_field_); } |
| 905 bool is_async_return() const { return type() == kAsyncReturn; } | 905 bool is_async_return() const { return type() == kAsyncReturn; } |
| 906 | 906 |
| 907 FeedbackSlot TypeProfileSlot() const { | |
| 908 DCHECK(HasTypeProfileSlot()); | |
| 909 return type_profile_slot_; | |
| 910 } | |
| 911 | |
| 912 void SetTypeProfileSlot(FeedbackSlot slot) { type_profile_slot_ = slot; } | |
| 913 | |
| 914 bool HasTypeProfileSlot() const { return !type_profile_slot_.IsInvalid(); } | |
| 915 | |
| 916 private: | 907 private: |
| 917 friend class AstNodeFactory; | 908 friend class AstNodeFactory; |
| 918 | 909 |
| 919 ReturnStatement(Expression* expression, Type type, int pos) | 910 ReturnStatement(Expression* expression, Type type, int pos) |
| 920 : JumpStatement(pos, kReturnStatement), expression_(expression) { | 911 : JumpStatement(pos, kReturnStatement), expression_(expression) { |
| 921 bit_field_ |= TypeField::encode(type); | 912 bit_field_ |= TypeField::encode(type); |
| 922 } | 913 } |
| 923 | 914 |
| 924 FeedbackSlot type_profile_slot_; | |
| 925 | |
| 926 Expression* expression_; | 915 Expression* expression_; |
| 927 | 916 |
| 928 class TypeField | 917 class TypeField |
| 929 : public BitField<Type, JumpStatement::kNextBitFieldIndex, 1> {}; | 918 : public BitField<Type, JumpStatement::kNextBitFieldIndex, 1> {}; |
| 930 }; | 919 }; |
| 931 | 920 |
| 932 | 921 |
| 933 class WithStatement final : public Statement { | 922 class WithStatement final : public Statement { |
| 934 public: | 923 public: |
| 935 Scope* scope() { return scope_; } | 924 Scope* scope() { return scope_; } |
| (...skipping 1482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2418 bit_field_ = IsUninitializedField::update(bit_field_, b); | 2407 bit_field_ = IsUninitializedField::update(bit_field_, b); |
| 2419 } | 2408 } |
| 2420 void set_key_type(IcCheckType key_type) { | 2409 void set_key_type(IcCheckType key_type) { |
| 2421 bit_field_ = KeyTypeField::update(bit_field_, key_type); | 2410 bit_field_ = KeyTypeField::update(bit_field_, key_type); |
| 2422 } | 2411 } |
| 2423 void set_store_mode(KeyedAccessStoreMode mode) { | 2412 void set_store_mode(KeyedAccessStoreMode mode) { |
| 2424 bit_field_ = StoreModeField::update(bit_field_, mode); | 2413 bit_field_ = StoreModeField::update(bit_field_, mode); |
| 2425 } | 2414 } |
| 2426 | 2415 |
| 2427 void AssignFeedbackSlots(FeedbackVectorSpec* spec, LanguageMode language_mode, | 2416 void AssignFeedbackSlots(FeedbackVectorSpec* spec, LanguageMode language_mode, |
| 2428 FeedbackSlotCache* cache, | 2417 FeedbackSlotCache* cache); |
| 2429 bool collect_type_profile = false); | |
| 2430 FeedbackSlot AssignmentSlot() const { return slot_; } | 2418 FeedbackSlot AssignmentSlot() const { return slot_; } |
| 2431 | 2419 |
| 2432 FeedbackSlot TypeProfileSlot() const { | |
| 2433 DCHECK(HasTypeProfileSlot()); | |
| 2434 return type_profile_slot_; | |
| 2435 } | |
| 2436 | |
| 2437 bool HasTypeProfileSlot() const { return !type_profile_slot_.IsInvalid(); } | |
| 2438 | |
| 2439 private: | 2420 private: |
| 2440 friend class AstNodeFactory; | 2421 friend class AstNodeFactory; |
| 2441 | 2422 |
| 2442 Assignment(Token::Value op, Expression* target, Expression* value, int pos); | 2423 Assignment(Token::Value op, Expression* target, Expression* value, int pos); |
| 2443 | 2424 |
| 2444 static int parent_num_ids() { return Expression::num_ids(); } | 2425 static int parent_num_ids() { return Expression::num_ids(); } |
| 2445 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | 2426 int local_id(int n) const { return base_id() + parent_num_ids() + n; } |
| 2446 | 2427 |
| 2447 class IsUninitializedField | 2428 class IsUninitializedField |
| 2448 : public BitField<bool, Expression::kNextBitFieldIndex, 1> {}; | 2429 : public BitField<bool, Expression::kNextBitFieldIndex, 1> {}; |
| 2449 class KeyTypeField | 2430 class KeyTypeField |
| 2450 : public BitField<IcCheckType, IsUninitializedField::kNext, 1> {}; | 2431 : public BitField<IcCheckType, IsUninitializedField::kNext, 1> {}; |
| 2451 class StoreModeField | 2432 class StoreModeField |
| 2452 : public BitField<KeyedAccessStoreMode, KeyTypeField::kNext, 3> {}; | 2433 : public BitField<KeyedAccessStoreMode, KeyTypeField::kNext, 3> {}; |
| 2453 class TokenField : public BitField<Token::Value, StoreModeField::kNext, 7> {}; | 2434 class TokenField : public BitField<Token::Value, StoreModeField::kNext, 7> {}; |
| 2454 | 2435 |
| 2455 FeedbackSlot slot_; | 2436 FeedbackSlot slot_; |
| 2456 Expression* target_; | 2437 Expression* target_; |
| 2457 Expression* value_; | 2438 Expression* value_; |
| 2458 BinaryOperation* binary_operation_; | 2439 BinaryOperation* binary_operation_; |
| 2459 SmallMapList receiver_types_; | 2440 SmallMapList receiver_types_; |
| 2460 | |
| 2461 FeedbackSlot type_profile_slot_; | |
| 2462 }; | 2441 }; |
| 2463 | 2442 |
| 2464 | 2443 |
| 2465 // The RewritableExpression class is a wrapper for AST nodes that wait | 2444 // The RewritableExpression class is a wrapper for AST nodes that wait |
| 2466 // for some potential rewriting. However, even if such nodes are indeed | 2445 // for some potential rewriting. However, even if such nodes are indeed |
| 2467 // rewritten, the RewritableExpression wrapper nodes will survive in the | 2446 // rewritten, the RewritableExpression wrapper nodes will survive in the |
| 2468 // final AST and should be just ignored, i.e., they should be treated as | 2447 // final AST and should be just ignored, i.e., they should be treated as |
| 2469 // equivalent to the wrapped nodes. For this reason and to simplify later | 2448 // equivalent to the wrapped nodes. For this reason and to simplify later |
| 2470 // phases, RewritableExpressions are considered as exceptions of AST nodes | 2449 // phases, RewritableExpressions are considered as exceptions of AST nodes |
| 2471 // in the following sense: | 2450 // in the following sense: |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2599 bool is_anonymous_expression() const { | 2578 bool is_anonymous_expression() const { |
| 2600 return function_type() == kAnonymousExpression; | 2579 return function_type() == kAnonymousExpression; |
| 2601 } | 2580 } |
| 2602 LanguageMode language_mode() const; | 2581 LanguageMode language_mode() const; |
| 2603 | 2582 |
| 2604 void AssignFeedbackSlots(FeedbackVectorSpec* spec, LanguageMode language_mode, | 2583 void AssignFeedbackSlots(FeedbackVectorSpec* spec, LanguageMode language_mode, |
| 2605 FeedbackSlotCache* cache) { | 2584 FeedbackSlotCache* cache) { |
| 2606 literal_feedback_slot_ = spec->AddCreateClosureSlot(); | 2585 literal_feedback_slot_ = spec->AddCreateClosureSlot(); |
| 2607 } | 2586 } |
| 2608 | 2587 |
| 2588 void SetTypeProfileSlot(FeedbackSlot slot) { type_profile_slot_ = slot; } |
| 2589 |
| 2609 FeedbackSlot LiteralFeedbackSlot() const { return literal_feedback_slot_; } | 2590 FeedbackSlot LiteralFeedbackSlot() const { return literal_feedback_slot_; } |
| 2591 FeedbackSlot TypeProfileSlot() const { return type_profile_slot_; } |
| 2610 | 2592 |
| 2611 static bool NeedsHomeObject(Expression* expr); | 2593 static bool NeedsHomeObject(Expression* expr); |
| 2612 | 2594 |
| 2613 int expected_property_count() { return expected_property_count_; } | 2595 int expected_property_count() { return expected_property_count_; } |
| 2614 int parameter_count() { return parameter_count_; } | 2596 int parameter_count() { return parameter_count_; } |
| 2615 int function_length() { return function_length_; } | 2597 int function_length() { return function_length_; } |
| 2616 | 2598 |
| 2617 bool AllowsLazyCompilation(); | 2599 bool AllowsLazyCompilation(); |
| 2618 | 2600 |
| 2619 Handle<String> debug_name() const { | 2601 Handle<String> debug_name() const { |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2762 bool has_braces_; | 2744 bool has_braces_; |
| 2763 | 2745 |
| 2764 const AstString* raw_name_; | 2746 const AstString* raw_name_; |
| 2765 DeclarationScope* scope_; | 2747 DeclarationScope* scope_; |
| 2766 ZoneList<Statement*>* body_; | 2748 ZoneList<Statement*>* body_; |
| 2767 const AstString* raw_inferred_name_; | 2749 const AstString* raw_inferred_name_; |
| 2768 Handle<String> inferred_name_; | 2750 Handle<String> inferred_name_; |
| 2769 AstProperties ast_properties_; | 2751 AstProperties ast_properties_; |
| 2770 int function_literal_id_; | 2752 int function_literal_id_; |
| 2771 FeedbackSlot literal_feedback_slot_; | 2753 FeedbackSlot literal_feedback_slot_; |
| 2754 FeedbackSlot type_profile_slot_; |
| 2772 }; | 2755 }; |
| 2773 | 2756 |
| 2774 // Property is used for passing information | 2757 // Property is used for passing information |
| 2775 // about a class literal's properties from the parser to the code generator. | 2758 // about a class literal's properties from the parser to the code generator. |
| 2776 class ClassLiteralProperty final : public LiteralProperty { | 2759 class ClassLiteralProperty final : public LiteralProperty { |
| 2777 public: | 2760 public: |
| 2778 enum Kind : uint8_t { METHOD, GETTER, SETTER, FIELD }; | 2761 enum Kind : uint8_t { METHOD, GETTER, SETTER, FIELD }; |
| 2779 | 2762 |
| 2780 Kind kind() const { return kind_; } | 2763 Kind kind() const { return kind_; } |
| 2781 | 2764 |
| (...skipping 876 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3658 : NULL; \ | 3641 : NULL; \ |
| 3659 } | 3642 } |
| 3660 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) | 3643 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) |
| 3661 #undef DECLARE_NODE_FUNCTIONS | 3644 #undef DECLARE_NODE_FUNCTIONS |
| 3662 | 3645 |
| 3663 | 3646 |
| 3664 } // namespace internal | 3647 } // namespace internal |
| 3665 } // namespace v8 | 3648 } // namespace v8 |
| 3666 | 3649 |
| 3667 #endif // V8_AST_AST_H_ | 3650 #endif // V8_AST_AST_H_ |
| OLD | NEW |