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 2654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2665 bit_field_ = DontOptimizeReasonField::update(bit_field_, reason); | 2665 bit_field_ = DontOptimizeReasonField::update(bit_field_, reason); |
2666 } | 2666 } |
2667 | 2667 |
2668 bool IsAnonymousFunctionDefinition() const { | 2668 bool IsAnonymousFunctionDefinition() const { |
2669 return is_anonymous_expression(); | 2669 return is_anonymous_expression(); |
2670 } | 2670 } |
2671 | 2671 |
2672 int yield_count() { return yield_count_; } | 2672 int yield_count() { return yield_count_; } |
2673 void set_yield_count(int yield_count) { yield_count_ = yield_count; } | 2673 void set_yield_count(int yield_count) { yield_count_ = yield_count; } |
2674 | 2674 |
2675 bool requires_class_field_init() { | |
2676 return RequiresClassFieldInit::decode(bit_field_); | |
2677 } | |
2678 void set_requires_class_field_init(bool requires_class_field_init) { | |
2679 bit_field_ = | |
2680 RequiresClassFieldInit::update(bit_field_, requires_class_field_init); | |
2681 } | |
2682 bool is_class_field_initializer() { | |
2683 return IsClassFieldInitializer::decode(bit_field_); | |
2684 } | |
2685 void set_is_class_field_initializer(bool is_class_field_initializer) { | |
2686 bit_field_ = | |
2687 IsClassFieldInitializer::update(bit_field_, is_class_field_initializer); | |
2688 } | |
2689 | |
2690 int return_position() { | 2675 int return_position() { |
2691 return std::max(start_position(), end_position() - (has_braces_ ? 1 : 0)); | 2676 return std::max(start_position(), end_position() - (has_braces_ ? 1 : 0)); |
2692 } | 2677 } |
2693 | 2678 |
2694 int function_literal_id() const { return function_literal_id_; } | 2679 int function_literal_id() const { return function_literal_id_; } |
2695 void set_function_literal_id(int function_literal_id) { | 2680 void set_function_literal_id(int function_literal_id) { |
2696 function_literal_id_ = function_literal_id; | 2681 function_literal_id_ = function_literal_id; |
2697 } | 2682 } |
2698 | 2683 |
2699 private: | 2684 private: |
(...skipping 14 matching lines...) Expand all Loading... |
2714 function_length_(function_length), | 2699 function_length_(function_length), |
2715 function_token_position_(kNoSourcePosition), | 2700 function_token_position_(kNoSourcePosition), |
2716 yield_count_(0), | 2701 yield_count_(0), |
2717 has_braces_(has_braces), | 2702 has_braces_(has_braces), |
2718 raw_name_(name), | 2703 raw_name_(name), |
2719 scope_(scope), | 2704 scope_(scope), |
2720 body_(body), | 2705 body_(body), |
2721 raw_inferred_name_(ast_value_factory->empty_string()), | 2706 raw_inferred_name_(ast_value_factory->empty_string()), |
2722 ast_properties_(zone), | 2707 ast_properties_(zone), |
2723 function_literal_id_(function_literal_id) { | 2708 function_literal_id_(function_literal_id) { |
2724 bit_field_ |= | 2709 bit_field_ |= FunctionTypeBits::encode(function_type) | |
2725 FunctionTypeBits::encode(function_type) | Pretenure::encode(false) | | 2710 Pretenure::encode(false) | |
2726 HasDuplicateParameters::encode(has_duplicate_parameters == | 2711 HasDuplicateParameters::encode(has_duplicate_parameters == |
2727 kHasDuplicateParameters) | | 2712 kHasDuplicateParameters) | |
2728 IsFunction::encode(is_function) | | 2713 IsFunction::encode(is_function) | |
2729 RequiresClassFieldInit::encode(false) | | 2714 ShouldNotBeUsedOnceHintField::encode(false) | |
2730 ShouldNotBeUsedOnceHintField::encode(false) | | 2715 DontOptimizeReasonField::encode(kNoReason); |
2731 DontOptimizeReasonField::encode(kNoReason) | | |
2732 IsClassFieldInitializer::encode(false); | |
2733 if (eager_compile_hint == kShouldEagerCompile) SetShouldEagerCompile(); | 2716 if (eager_compile_hint == kShouldEagerCompile) SetShouldEagerCompile(); |
2734 } | 2717 } |
2735 | 2718 |
2736 class FunctionTypeBits | 2719 class FunctionTypeBits |
2737 : public BitField<FunctionType, Expression::kNextBitFieldIndex, 2> {}; | 2720 : public BitField<FunctionType, Expression::kNextBitFieldIndex, 2> {}; |
2738 class Pretenure : public BitField<bool, FunctionTypeBits::kNext, 1> {}; | 2721 class Pretenure : public BitField<bool, FunctionTypeBits::kNext, 1> {}; |
2739 class HasDuplicateParameters : public BitField<bool, Pretenure::kNext, 1> {}; | 2722 class HasDuplicateParameters : public BitField<bool, Pretenure::kNext, 1> {}; |
2740 class IsFunction : public BitField<bool, HasDuplicateParameters::kNext, 1> {}; | 2723 class IsFunction : public BitField<bool, HasDuplicateParameters::kNext, 1> {}; |
2741 class ShouldNotBeUsedOnceHintField | 2724 class ShouldNotBeUsedOnceHintField |
2742 : public BitField<bool, IsFunction::kNext, 1> {}; | 2725 : public BitField<bool, IsFunction::kNext, 1> {}; |
2743 class RequiresClassFieldInit | |
2744 : public BitField<bool, ShouldNotBeUsedOnceHintField::kNext, 1> {}; | |
2745 class IsClassFieldInitializer | |
2746 : public BitField<bool, RequiresClassFieldInit::kNext, 1> {}; | |
2747 class DontOptimizeReasonField | 2726 class DontOptimizeReasonField |
2748 : public BitField<BailoutReason, IsClassFieldInitializer::kNext, 8> {}; | 2727 : public BitField<BailoutReason, ShouldNotBeUsedOnceHintField::kNext, 8> { |
| 2728 }; |
2749 | 2729 |
2750 int materialized_literal_count_; | 2730 int materialized_literal_count_; |
2751 int expected_property_count_; | 2731 int expected_property_count_; |
2752 int parameter_count_; | 2732 int parameter_count_; |
2753 int function_length_; | 2733 int function_length_; |
2754 int function_token_position_; | 2734 int function_token_position_; |
2755 int yield_count_; | 2735 int yield_count_; |
2756 bool has_braces_; | 2736 bool has_braces_; |
2757 | 2737 |
2758 const AstString* raw_name_; | 2738 const AstString* raw_name_; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2796 ZoneList<Property*>* properties() const { return properties_; } | 2776 ZoneList<Property*>* properties() const { return properties_; } |
2797 int start_position() const { return position(); } | 2777 int start_position() const { return position(); } |
2798 int end_position() const { return end_position_; } | 2778 int end_position() const { return end_position_; } |
2799 bool has_name_static_property() const { | 2779 bool has_name_static_property() const { |
2800 return HasNameStaticProperty::decode(bit_field_); | 2780 return HasNameStaticProperty::decode(bit_field_); |
2801 } | 2781 } |
2802 bool has_static_computed_names() const { | 2782 bool has_static_computed_names() const { |
2803 return HasStaticComputedNames::decode(bit_field_); | 2783 return HasStaticComputedNames::decode(bit_field_); |
2804 } | 2784 } |
2805 | 2785 |
2806 VariableProxy* static_initializer_proxy() const { | |
2807 return static_initializer_proxy_; | |
2808 } | |
2809 void set_static_initializer_proxy(VariableProxy* proxy) { | |
2810 static_initializer_proxy_ = proxy; | |
2811 } | |
2812 | |
2813 // Object literals need one feedback slot for each non-trivial value, as well | 2786 // Object literals need one feedback slot for each non-trivial value, as well |
2814 // as some slots for home objects. | 2787 // as some slots for home objects. |
2815 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, | 2788 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, |
2816 FeedbackVectorSlotCache* cache); | 2789 FeedbackVectorSlotCache* cache); |
2817 | 2790 |
2818 bool NeedsProxySlot() const { | 2791 bool NeedsProxySlot() const { |
2819 return class_variable_proxy() != nullptr && | 2792 return class_variable_proxy() != nullptr && |
2820 class_variable_proxy()->var()->IsUnallocated(); | 2793 class_variable_proxy()->var()->IsUnallocated(); |
2821 } | 2794 } |
2822 | 2795 |
2823 FeedbackVectorSlot PrototypeSlot() const { return prototype_slot_; } | 2796 FeedbackVectorSlot PrototypeSlot() const { return prototype_slot_; } |
2824 FeedbackVectorSlot ProxySlot() const { return proxy_slot_; } | 2797 FeedbackVectorSlot ProxySlot() const { return proxy_slot_; } |
2825 | 2798 |
2826 private: | 2799 private: |
2827 friend class AstNodeFactory; | 2800 friend class AstNodeFactory; |
2828 | 2801 |
2829 ClassLiteral(VariableProxy* class_variable_proxy, Expression* extends, | 2802 ClassLiteral(VariableProxy* class_variable_proxy, Expression* extends, |
2830 FunctionLiteral* constructor, ZoneList<Property*>* properties, | 2803 FunctionLiteral* constructor, ZoneList<Property*>* properties, |
2831 int start_position, int end_position, | 2804 int start_position, int end_position, |
2832 bool has_name_static_property, bool has_static_computed_names) | 2805 bool has_name_static_property, bool has_static_computed_names) |
2833 : Expression(start_position, kClassLiteral), | 2806 : Expression(start_position, kClassLiteral), |
2834 end_position_(end_position), | 2807 end_position_(end_position), |
2835 class_variable_proxy_(class_variable_proxy), | 2808 class_variable_proxy_(class_variable_proxy), |
2836 extends_(extends), | 2809 extends_(extends), |
2837 constructor_(constructor), | 2810 constructor_(constructor), |
2838 properties_(properties), | 2811 properties_(properties) { |
2839 static_initializer_proxy_(nullptr) { | |
2840 bit_field_ |= HasNameStaticProperty::encode(has_name_static_property) | | 2812 bit_field_ |= HasNameStaticProperty::encode(has_name_static_property) | |
2841 HasStaticComputedNames::encode(has_static_computed_names); | 2813 HasStaticComputedNames::encode(has_static_computed_names); |
2842 } | 2814 } |
2843 | 2815 |
2844 int end_position_; | 2816 int end_position_; |
2845 FeedbackVectorSlot prototype_slot_; | 2817 FeedbackVectorSlot prototype_slot_; |
2846 FeedbackVectorSlot proxy_slot_; | 2818 FeedbackVectorSlot proxy_slot_; |
2847 VariableProxy* class_variable_proxy_; | 2819 VariableProxy* class_variable_proxy_; |
2848 Expression* extends_; | 2820 Expression* extends_; |
2849 FunctionLiteral* constructor_; | 2821 FunctionLiteral* constructor_; |
2850 ZoneList<Property*>* properties_; | 2822 ZoneList<Property*>* properties_; |
2851 VariableProxy* static_initializer_proxy_; | |
2852 | 2823 |
2853 class HasNameStaticProperty | 2824 class HasNameStaticProperty |
2854 : public BitField<bool, Expression::kNextBitFieldIndex, 1> {}; | 2825 : public BitField<bool, Expression::kNextBitFieldIndex, 1> {}; |
2855 class HasStaticComputedNames | 2826 class HasStaticComputedNames |
2856 : public BitField<bool, HasNameStaticProperty::kNext, 1> {}; | 2827 : public BitField<bool, HasNameStaticProperty::kNext, 1> {}; |
2857 }; | 2828 }; |
2858 | 2829 |
2859 | 2830 |
2860 class NativeFunctionLiteral final : public Expression { | 2831 class NativeFunctionLiteral final : public Expression { |
2861 public: | 2832 public: |
(...skipping 769 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3631 : NULL; \ | 3602 : NULL; \ |
3632 } | 3603 } |
3633 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) | 3604 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) |
3634 #undef DECLARE_NODE_FUNCTIONS | 3605 #undef DECLARE_NODE_FUNCTIONS |
3635 | 3606 |
3636 | 3607 |
3637 } // namespace internal | 3608 } // namespace internal |
3638 } // namespace v8 | 3609 } // namespace v8 |
3639 | 3610 |
3640 #endif // V8_AST_AST_H_ | 3611 #endif // V8_AST_AST_H_ |
OLD | NEW |