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 2558 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2569 int SourceSize() const { return end_position() - start_position(); } | 2569 int SourceSize() const { return end_position() - start_position(); } |
2570 bool is_declaration() const { return function_type() == kDeclaration; } | 2570 bool is_declaration() const { return function_type() == kDeclaration; } |
2571 bool is_named_expression() const { | 2571 bool is_named_expression() const { |
2572 return function_type() == kNamedExpression; | 2572 return function_type() == kNamedExpression; |
2573 } | 2573 } |
2574 bool is_anonymous_expression() const { | 2574 bool is_anonymous_expression() const { |
2575 return function_type() == kAnonymousExpression; | 2575 return function_type() == kAnonymousExpression; |
2576 } | 2576 } |
2577 LanguageMode language_mode() const; | 2577 LanguageMode language_mode() const; |
2578 | 2578 |
| 2579 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, |
| 2580 FeedbackVectorSlotCache* cache) { |
| 2581 // The + 1 is because we need an array with room for the literals |
| 2582 // as well as the feedback vector. |
| 2583 literal_feedback_slot_ = |
| 2584 spec->AddCreateClosureSlot(materialized_literal_count_ + 1); |
| 2585 } |
| 2586 |
| 2587 FeedbackVectorSlot LiteralFeedbackSlot() const { |
| 2588 return literal_feedback_slot_; |
| 2589 } |
| 2590 |
2579 static bool NeedsHomeObject(Expression* expr); | 2591 static bool NeedsHomeObject(Expression* expr); |
2580 | 2592 |
2581 int materialized_literal_count() { return materialized_literal_count_; } | 2593 int materialized_literal_count() { return materialized_literal_count_; } |
2582 int expected_property_count() { return expected_property_count_; } | 2594 int expected_property_count() { return expected_property_count_; } |
2583 int parameter_count() { return parameter_count_; } | 2595 int parameter_count() { return parameter_count_; } |
2584 int function_length() { return function_length_; } | 2596 int function_length() { return function_length_; } |
2585 | 2597 |
2586 bool AllowsLazyCompilation(); | 2598 bool AllowsLazyCompilation(); |
2587 | 2599 |
2588 Handle<String> debug_name() const { | 2600 Handle<String> debug_name() const { |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2736 int yield_count_; | 2748 int yield_count_; |
2737 bool has_braces_; | 2749 bool has_braces_; |
2738 | 2750 |
2739 const AstString* raw_name_; | 2751 const AstString* raw_name_; |
2740 DeclarationScope* scope_; | 2752 DeclarationScope* scope_; |
2741 ZoneList<Statement*>* body_; | 2753 ZoneList<Statement*>* body_; |
2742 const AstString* raw_inferred_name_; | 2754 const AstString* raw_inferred_name_; |
2743 Handle<String> inferred_name_; | 2755 Handle<String> inferred_name_; |
2744 AstProperties ast_properties_; | 2756 AstProperties ast_properties_; |
2745 int function_literal_id_; | 2757 int function_literal_id_; |
| 2758 FeedbackVectorSlot literal_feedback_slot_; |
2746 }; | 2759 }; |
2747 | 2760 |
2748 // Property is used for passing information | 2761 // Property is used for passing information |
2749 // about a class literal's properties from the parser to the code generator. | 2762 // about a class literal's properties from the parser to the code generator. |
2750 class ClassLiteralProperty final : public LiteralProperty { | 2763 class ClassLiteralProperty final : public LiteralProperty { |
2751 public: | 2764 public: |
2752 enum Kind : uint8_t { METHOD, GETTER, SETTER, FIELD }; | 2765 enum Kind : uint8_t { METHOD, GETTER, SETTER, FIELD }; |
2753 | 2766 |
2754 Kind kind() const { return kind_; } | 2767 Kind kind() const { return kind_; } |
2755 | 2768 |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2826 : public BitField<bool, Expression::kNextBitFieldIndex, 1> {}; | 2839 : public BitField<bool, Expression::kNextBitFieldIndex, 1> {}; |
2827 class HasStaticComputedNames | 2840 class HasStaticComputedNames |
2828 : public BitField<bool, HasNameStaticProperty::kNext, 1> {}; | 2841 : public BitField<bool, HasNameStaticProperty::kNext, 1> {}; |
2829 }; | 2842 }; |
2830 | 2843 |
2831 | 2844 |
2832 class NativeFunctionLiteral final : public Expression { | 2845 class NativeFunctionLiteral final : public Expression { |
2833 public: | 2846 public: |
2834 Handle<String> name() const { return name_->string(); } | 2847 Handle<String> name() const { return name_->string(); } |
2835 v8::Extension* extension() const { return extension_; } | 2848 v8::Extension* extension() const { return extension_; } |
| 2849 FeedbackVectorSlot LiteralFeedbackSlot() const { |
| 2850 return literal_feedback_slot_; |
| 2851 } |
| 2852 |
| 2853 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, |
| 2854 FeedbackVectorSlotCache* cache) { |
| 2855 // 0 is a magic number here. It means we are holding the literals |
| 2856 // array for a native function literal, which needs to be |
| 2857 // the empty literals array. |
| 2858 // TODO(mvstanton): The FeedbackVectorSlotCache can be adapted |
| 2859 // to always return the same slot for this case. |
| 2860 literal_feedback_slot_ = spec->AddCreateClosureSlot(0); |
| 2861 } |
2836 | 2862 |
2837 private: | 2863 private: |
2838 friend class AstNodeFactory; | 2864 friend class AstNodeFactory; |
2839 | 2865 |
2840 NativeFunctionLiteral(const AstRawString* name, v8::Extension* extension, | 2866 NativeFunctionLiteral(const AstRawString* name, v8::Extension* extension, |
2841 int pos) | 2867 int pos) |
2842 : Expression(pos, kNativeFunctionLiteral), | 2868 : Expression(pos, kNativeFunctionLiteral), |
2843 name_(name), | 2869 name_(name), |
2844 extension_(extension) {} | 2870 extension_(extension) {} |
2845 | 2871 |
2846 const AstRawString* name_; | 2872 const AstRawString* name_; |
2847 v8::Extension* extension_; | 2873 v8::Extension* extension_; |
| 2874 FeedbackVectorSlot literal_feedback_slot_; |
2848 }; | 2875 }; |
2849 | 2876 |
2850 | 2877 |
2851 class ThisFunction final : public Expression { | 2878 class ThisFunction final : public Expression { |
2852 private: | 2879 private: |
2853 friend class AstNodeFactory; | 2880 friend class AstNodeFactory; |
2854 explicit ThisFunction(int pos) : Expression(pos, kThisFunction) {} | 2881 explicit ThisFunction(int pos) : Expression(pos, kThisFunction) {} |
2855 }; | 2882 }; |
2856 | 2883 |
2857 | 2884 |
(...skipping 745 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3603 : NULL; \ | 3630 : NULL; \ |
3604 } | 3631 } |
3605 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) | 3632 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) |
3606 #undef DECLARE_NODE_FUNCTIONS | 3633 #undef DECLARE_NODE_FUNCTIONS |
3607 | 3634 |
3608 | 3635 |
3609 } // namespace internal | 3636 } // namespace internal |
3610 } // namespace v8 | 3637 } // namespace v8 |
3611 | 3638 |
3612 #endif // V8_AST_AST_H_ | 3639 #endif // V8_AST_AST_H_ |
OLD | NEW |