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 2551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2562 int SourceSize() const { return end_position() - start_position(); } | 2562 int SourceSize() const { return end_position() - start_position(); } |
2563 bool is_declaration() const { return function_type() == kDeclaration; } | 2563 bool is_declaration() const { return function_type() == kDeclaration; } |
2564 bool is_named_expression() const { | 2564 bool is_named_expression() const { |
2565 return function_type() == kNamedExpression; | 2565 return function_type() == kNamedExpression; |
2566 } | 2566 } |
2567 bool is_anonymous_expression() const { | 2567 bool is_anonymous_expression() const { |
2568 return function_type() == kAnonymousExpression; | 2568 return function_type() == kAnonymousExpression; |
2569 } | 2569 } |
2570 LanguageMode language_mode() const; | 2570 LanguageMode language_mode() const; |
2571 | 2571 |
| 2572 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, |
| 2573 FeedbackVectorSlotCache* cache) { |
| 2574 if (FLAG_strong_rooted_literals) { |
| 2575 literal_feedback_slot_ = |
| 2576 spec->AddCreateClosureSlot(materialized_literal_count_ + 1); |
| 2577 } else { |
| 2578 literal_feedback_slot_ = FeedbackVectorSlot::Invalid(); |
| 2579 } |
| 2580 } |
| 2581 |
| 2582 FeedbackVectorSlot LiteralFeedbackSlot() const { |
| 2583 return literal_feedback_slot_; |
| 2584 } |
| 2585 |
2572 static bool NeedsHomeObject(Expression* expr); | 2586 static bool NeedsHomeObject(Expression* expr); |
2573 | 2587 |
2574 int materialized_literal_count() { return materialized_literal_count_; } | 2588 int materialized_literal_count() { return materialized_literal_count_; } |
2575 int expected_property_count() { return expected_property_count_; } | 2589 int expected_property_count() { return expected_property_count_; } |
2576 int parameter_count() { return parameter_count_; } | 2590 int parameter_count() { return parameter_count_; } |
2577 int function_length() { return function_length_; } | 2591 int function_length() { return function_length_; } |
2578 | 2592 |
2579 bool AllowsLazyCompilation(); | 2593 bool AllowsLazyCompilation(); |
2580 | 2594 |
2581 Handle<String> debug_name() const { | 2595 Handle<String> debug_name() const { |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2749 int yield_count_; | 2763 int yield_count_; |
2750 bool has_braces_; | 2764 bool has_braces_; |
2751 | 2765 |
2752 const AstString* raw_name_; | 2766 const AstString* raw_name_; |
2753 DeclarationScope* scope_; | 2767 DeclarationScope* scope_; |
2754 ZoneList<Statement*>* body_; | 2768 ZoneList<Statement*>* body_; |
2755 const AstString* raw_inferred_name_; | 2769 const AstString* raw_inferred_name_; |
2756 Handle<String> inferred_name_; | 2770 Handle<String> inferred_name_; |
2757 AstProperties ast_properties_; | 2771 AstProperties ast_properties_; |
2758 int function_literal_id_; | 2772 int function_literal_id_; |
| 2773 FeedbackVectorSlot literal_feedback_slot_; |
2759 }; | 2774 }; |
2760 | 2775 |
2761 // Property is used for passing information | 2776 // Property is used for passing information |
2762 // about a class literal's properties from the parser to the code generator. | 2777 // about a class literal's properties from the parser to the code generator. |
2763 class ClassLiteralProperty final : public LiteralProperty { | 2778 class ClassLiteralProperty final : public LiteralProperty { |
2764 public: | 2779 public: |
2765 enum Kind : uint8_t { METHOD, GETTER, SETTER, FIELD }; | 2780 enum Kind : uint8_t { METHOD, GETTER, SETTER, FIELD }; |
2766 | 2781 |
2767 Kind kind() const { return kind_; } | 2782 Kind kind() const { return kind_; } |
2768 | 2783 |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2848 : public BitField<bool, Expression::kNextBitFieldIndex, 1> {}; | 2863 : public BitField<bool, Expression::kNextBitFieldIndex, 1> {}; |
2849 class HasStaticComputedNames | 2864 class HasStaticComputedNames |
2850 : public BitField<bool, HasNameStaticProperty::kNext, 1> {}; | 2865 : public BitField<bool, HasNameStaticProperty::kNext, 1> {}; |
2851 }; | 2866 }; |
2852 | 2867 |
2853 | 2868 |
2854 class NativeFunctionLiteral final : public Expression { | 2869 class NativeFunctionLiteral final : public Expression { |
2855 public: | 2870 public: |
2856 Handle<String> name() const { return name_->string(); } | 2871 Handle<String> name() const { return name_->string(); } |
2857 v8::Extension* extension() const { return extension_; } | 2872 v8::Extension* extension() const { return extension_; } |
| 2873 FeedbackVectorSlot LiteralFeedbackSlot() const { |
| 2874 return literal_feedback_slot_; |
| 2875 } |
| 2876 |
| 2877 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, |
| 2878 FeedbackVectorSlotCache* cache) { |
| 2879 // TODO(mvstanton): It's actually silly to create these slots. |
| 2880 // At the very least, can we use the FeedbackVectorSlotCache to make |
| 2881 // sure we only allocate 1 for a given function and constantly reuse it? |
| 2882 if (FLAG_strong_rooted_literals) { |
| 2883 // 0 is a magic number here. It means we are holding the literals |
| 2884 // array for a native function literal, which needs to be |
| 2885 // the empty literals array. |
| 2886 // TODO(mvstanton): better way to deal with this? |
| 2887 literal_feedback_slot_ = spec->AddCreateClosureSlot(0); |
| 2888 } else { |
| 2889 literal_feedback_slot_ = FeedbackVectorSlot::Invalid(); |
| 2890 } |
| 2891 } |
2858 | 2892 |
2859 private: | 2893 private: |
2860 friend class AstNodeFactory; | 2894 friend class AstNodeFactory; |
2861 | 2895 |
2862 NativeFunctionLiteral(const AstRawString* name, v8::Extension* extension, | 2896 NativeFunctionLiteral(const AstRawString* name, v8::Extension* extension, |
2863 int pos) | 2897 int pos) |
2864 : Expression(pos, kNativeFunctionLiteral), | 2898 : Expression(pos, kNativeFunctionLiteral), |
2865 name_(name), | 2899 name_(name), |
2866 extension_(extension) {} | 2900 extension_(extension) {} |
2867 | 2901 |
2868 const AstRawString* name_; | 2902 const AstRawString* name_; |
2869 v8::Extension* extension_; | 2903 v8::Extension* extension_; |
| 2904 FeedbackVectorSlot literal_feedback_slot_; |
2870 }; | 2905 }; |
2871 | 2906 |
2872 | 2907 |
2873 class ThisFunction final : public Expression { | 2908 class ThisFunction final : public Expression { |
2874 private: | 2909 private: |
2875 friend class AstNodeFactory; | 2910 friend class AstNodeFactory; |
2876 explicit ThisFunction(int pos) : Expression(pos, kThisFunction) {} | 2911 explicit ThisFunction(int pos) : Expression(pos, kThisFunction) {} |
2877 }; | 2912 }; |
2878 | 2913 |
2879 | 2914 |
(...skipping 754 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3634 : NULL; \ | 3669 : NULL; \ |
3635 } | 3670 } |
3636 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) | 3671 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) |
3637 #undef DECLARE_NODE_FUNCTIONS | 3672 #undef DECLARE_NODE_FUNCTIONS |
3638 | 3673 |
3639 | 3674 |
3640 } // namespace internal | 3675 } // namespace internal |
3641 } // namespace v8 | 3676 } // namespace v8 |
3642 | 3677 |
3643 #endif // V8_AST_AST_H_ | 3678 #endif // V8_AST_AST_H_ |
OLD | NEW |