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/assembler.h" | 8 #include "src/assembler.h" |
9 #include "src/ast/ast-types.h" | 9 #include "src/ast/ast-types.h" |
10 #include "src/ast/ast-value-factory.h" | 10 #include "src/ast/ast-value-factory.h" |
(...skipping 2549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2560 int SourceSize() const { return end_position() - start_position(); } | 2560 int SourceSize() const { return end_position() - start_position(); } |
2561 bool is_declaration() const { return function_type() == kDeclaration; } | 2561 bool is_declaration() const { return function_type() == kDeclaration; } |
2562 bool is_named_expression() const { | 2562 bool is_named_expression() const { |
2563 return function_type() == kNamedExpression; | 2563 return function_type() == kNamedExpression; |
2564 } | 2564 } |
2565 bool is_anonymous_expression() const { | 2565 bool is_anonymous_expression() const { |
2566 return function_type() == kAnonymousExpression; | 2566 return function_type() == kAnonymousExpression; |
2567 } | 2567 } |
2568 LanguageMode language_mode() const; | 2568 LanguageMode language_mode() const; |
2569 | 2569 |
| 2570 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, |
| 2571 FeedbackVectorSlotCache* cache) { |
| 2572 // The + 1 is because we need an array with room for the literals |
| 2573 // as well as the feedback vector. |
| 2574 literal_feedback_slot_ = |
| 2575 spec->AddCreateClosureSlot(materialized_literal_count_ + 1); |
| 2576 } |
| 2577 |
| 2578 FeedbackVectorSlot LiteralFeedbackSlot() const { |
| 2579 return literal_feedback_slot_; |
| 2580 } |
| 2581 |
2570 static bool NeedsHomeObject(Expression* expr); | 2582 static bool NeedsHomeObject(Expression* expr); |
2571 | 2583 |
2572 int materialized_literal_count() { return materialized_literal_count_; } | 2584 int materialized_literal_count() { return materialized_literal_count_; } |
2573 int expected_property_count() { return expected_property_count_; } | 2585 int expected_property_count() { return expected_property_count_; } |
2574 int parameter_count() { return parameter_count_; } | 2586 int parameter_count() { return parameter_count_; } |
2575 int function_length() { return function_length_; } | 2587 int function_length() { return function_length_; } |
2576 | 2588 |
2577 bool AllowsLazyCompilation(); | 2589 bool AllowsLazyCompilation(); |
2578 | 2590 |
2579 Handle<String> debug_name() const { | 2591 Handle<String> debug_name() const { |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2727 int yield_count_; | 2739 int yield_count_; |
2728 bool has_braces_; | 2740 bool has_braces_; |
2729 | 2741 |
2730 const AstString* raw_name_; | 2742 const AstString* raw_name_; |
2731 DeclarationScope* scope_; | 2743 DeclarationScope* scope_; |
2732 ZoneList<Statement*>* body_; | 2744 ZoneList<Statement*>* body_; |
2733 const AstString* raw_inferred_name_; | 2745 const AstString* raw_inferred_name_; |
2734 Handle<String> inferred_name_; | 2746 Handle<String> inferred_name_; |
2735 AstProperties ast_properties_; | 2747 AstProperties ast_properties_; |
2736 int function_literal_id_; | 2748 int function_literal_id_; |
| 2749 FeedbackVectorSlot literal_feedback_slot_; |
2737 }; | 2750 }; |
2738 | 2751 |
2739 // Property is used for passing information | 2752 // Property is used for passing information |
2740 // about a class literal's properties from the parser to the code generator. | 2753 // about a class literal's properties from the parser to the code generator. |
2741 class ClassLiteralProperty final : public LiteralProperty { | 2754 class ClassLiteralProperty final : public LiteralProperty { |
2742 public: | 2755 public: |
2743 enum Kind : uint8_t { METHOD, GETTER, SETTER, FIELD }; | 2756 enum Kind : uint8_t { METHOD, GETTER, SETTER, FIELD }; |
2744 | 2757 |
2745 Kind kind() const { return kind_; } | 2758 Kind kind() const { return kind_; } |
2746 | 2759 |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2817 : public BitField<bool, Expression::kNextBitFieldIndex, 1> {}; | 2830 : public BitField<bool, Expression::kNextBitFieldIndex, 1> {}; |
2818 class HasStaticComputedNames | 2831 class HasStaticComputedNames |
2819 : public BitField<bool, HasNameStaticProperty::kNext, 1> {}; | 2832 : public BitField<bool, HasNameStaticProperty::kNext, 1> {}; |
2820 }; | 2833 }; |
2821 | 2834 |
2822 | 2835 |
2823 class NativeFunctionLiteral final : public Expression { | 2836 class NativeFunctionLiteral final : public Expression { |
2824 public: | 2837 public: |
2825 Handle<String> name() const { return name_->string(); } | 2838 Handle<String> name() const { return name_->string(); } |
2826 v8::Extension* extension() const { return extension_; } | 2839 v8::Extension* extension() const { return extension_; } |
| 2840 FeedbackVectorSlot LiteralFeedbackSlot() const { |
| 2841 return literal_feedback_slot_; |
| 2842 } |
| 2843 |
| 2844 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, |
| 2845 FeedbackVectorSlotCache* cache) { |
| 2846 // 0 is a magic number here. It means we are holding the literals |
| 2847 // array for a native function literal, which needs to be |
| 2848 // the empty literals array. |
| 2849 // TODO(mvstanton): The FeedbackVectorSlotCache can be adapted |
| 2850 // to always return the same slot for this case. |
| 2851 literal_feedback_slot_ = spec->AddCreateClosureSlot(0); |
| 2852 } |
2827 | 2853 |
2828 private: | 2854 private: |
2829 friend class AstNodeFactory; | 2855 friend class AstNodeFactory; |
2830 | 2856 |
2831 NativeFunctionLiteral(const AstRawString* name, v8::Extension* extension, | 2857 NativeFunctionLiteral(const AstRawString* name, v8::Extension* extension, |
2832 int pos) | 2858 int pos) |
2833 : Expression(pos, kNativeFunctionLiteral), | 2859 : Expression(pos, kNativeFunctionLiteral), |
2834 name_(name), | 2860 name_(name), |
2835 extension_(extension) {} | 2861 extension_(extension) {} |
2836 | 2862 |
2837 const AstRawString* name_; | 2863 const AstRawString* name_; |
2838 v8::Extension* extension_; | 2864 v8::Extension* extension_; |
| 2865 FeedbackVectorSlot literal_feedback_slot_; |
2839 }; | 2866 }; |
2840 | 2867 |
2841 | 2868 |
2842 class ThisFunction final : public Expression { | 2869 class ThisFunction final : public Expression { |
2843 private: | 2870 private: |
2844 friend class AstNodeFactory; | 2871 friend class AstNodeFactory; |
2845 explicit ThisFunction(int pos) : Expression(pos, kThisFunction) {} | 2872 explicit ThisFunction(int pos) : Expression(pos, kThisFunction) {} |
2846 }; | 2873 }; |
2847 | 2874 |
2848 | 2875 |
(...skipping 745 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3594 : NULL; \ | 3621 : NULL; \ |
3595 } | 3622 } |
3596 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) | 3623 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) |
3597 #undef DECLARE_NODE_FUNCTIONS | 3624 #undef DECLARE_NODE_FUNCTIONS |
3598 | 3625 |
3599 | 3626 |
3600 } // namespace internal | 3627 } // namespace internal |
3601 } // namespace v8 | 3628 } // namespace v8 |
3602 | 3629 |
3603 #endif // V8_AST_AST_H_ | 3630 #endif // V8_AST_AST_H_ |
OLD | NEW |