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 2594 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2605 | 2605 |
2606 void AssignFeedbackSlots(FeedbackVectorSpec* spec, LanguageMode language_mode, | 2606 void AssignFeedbackSlots(FeedbackVectorSpec* spec, LanguageMode language_mode, |
2607 FeedbackSlotCache* cache) { | 2607 FeedbackSlotCache* cache) { |
2608 literal_feedback_slot_ = spec->AddCreateClosureSlot(); | 2608 literal_feedback_slot_ = spec->AddCreateClosureSlot(); |
2609 } | 2609 } |
2610 | 2610 |
2611 FeedbackSlot LiteralFeedbackSlot() const { return literal_feedback_slot_; } | 2611 FeedbackSlot LiteralFeedbackSlot() const { return literal_feedback_slot_; } |
2612 | 2612 |
2613 static bool NeedsHomeObject(Expression* expr); | 2613 static bool NeedsHomeObject(Expression* expr); |
2614 | 2614 |
2615 int materialized_literal_count() { return materialized_literal_count_; } | |
2616 int expected_property_count() { return expected_property_count_; } | 2615 int expected_property_count() { return expected_property_count_; } |
2617 int parameter_count() { return parameter_count_; } | 2616 int parameter_count() { return parameter_count_; } |
2618 int function_length() { return function_length_; } | 2617 int function_length() { return function_length_; } |
2619 | 2618 |
2620 bool AllowsLazyCompilation(); | 2619 bool AllowsLazyCompilation(); |
2621 | 2620 |
2622 Handle<String> debug_name() const { | 2621 Handle<String> debug_name() const { |
2623 if (raw_name_ != NULL && !raw_name_->IsEmpty()) { | 2622 if (raw_name_ != NULL && !raw_name_->IsEmpty()) { |
2624 return raw_name_->string(); | 2623 return raw_name_->string(); |
2625 } | 2624 } |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2712 int function_literal_id() const { return function_literal_id_; } | 2711 int function_literal_id() const { return function_literal_id_; } |
2713 void set_function_literal_id(int function_literal_id) { | 2712 void set_function_literal_id(int function_literal_id) { |
2714 function_literal_id_ = function_literal_id; | 2713 function_literal_id_ = function_literal_id; |
2715 } | 2714 } |
2716 | 2715 |
2717 private: | 2716 private: |
2718 friend class AstNodeFactory; | 2717 friend class AstNodeFactory; |
2719 | 2718 |
2720 FunctionLiteral(Zone* zone, const AstString* name, | 2719 FunctionLiteral(Zone* zone, const AstString* name, |
2721 AstValueFactory* ast_value_factory, DeclarationScope* scope, | 2720 AstValueFactory* ast_value_factory, DeclarationScope* scope, |
2722 ZoneList<Statement*>* body, int materialized_literal_count, | 2721 ZoneList<Statement*>* body, int expected_property_count, |
2723 int expected_property_count, int parameter_count, | 2722 int parameter_count, int function_length, |
2724 int function_length, FunctionType function_type, | 2723 FunctionType function_type, |
2725 ParameterFlag has_duplicate_parameters, | 2724 ParameterFlag has_duplicate_parameters, |
2726 EagerCompileHint eager_compile_hint, int position, | 2725 EagerCompileHint eager_compile_hint, int position, |
2727 bool has_braces, int function_literal_id) | 2726 bool has_braces, int function_literal_id) |
2728 : Expression(position, kFunctionLiteral), | 2727 : Expression(position, kFunctionLiteral), |
2729 materialized_literal_count_(materialized_literal_count), | |
2730 expected_property_count_(expected_property_count), | 2728 expected_property_count_(expected_property_count), |
2731 parameter_count_(parameter_count), | 2729 parameter_count_(parameter_count), |
2732 function_length_(function_length), | 2730 function_length_(function_length), |
2733 function_token_position_(kNoSourcePosition), | 2731 function_token_position_(kNoSourcePosition), |
2734 yield_count_(0), | 2732 yield_count_(0), |
2735 has_braces_(has_braces), | 2733 has_braces_(has_braces), |
2736 raw_name_(name), | 2734 raw_name_(name), |
2737 scope_(scope), | 2735 scope_(scope), |
2738 body_(body), | 2736 body_(body), |
2739 raw_inferred_name_(ast_value_factory->empty_string()), | 2737 raw_inferred_name_(ast_value_factory->empty_string()), |
(...skipping 11 matching lines...) Expand all Loading... |
2751 class FunctionTypeBits | 2749 class FunctionTypeBits |
2752 : public BitField<FunctionType, Expression::kNextBitFieldIndex, 2> {}; | 2750 : public BitField<FunctionType, Expression::kNextBitFieldIndex, 2> {}; |
2753 class Pretenure : public BitField<bool, FunctionTypeBits::kNext, 1> {}; | 2751 class Pretenure : public BitField<bool, FunctionTypeBits::kNext, 1> {}; |
2754 class HasDuplicateParameters : public BitField<bool, Pretenure::kNext, 1> {}; | 2752 class HasDuplicateParameters : public BitField<bool, Pretenure::kNext, 1> {}; |
2755 class ShouldNotBeUsedOnceHintField | 2753 class ShouldNotBeUsedOnceHintField |
2756 : public BitField<bool, HasDuplicateParameters::kNext, 1> {}; | 2754 : public BitField<bool, HasDuplicateParameters::kNext, 1> {}; |
2757 class DontOptimizeReasonField | 2755 class DontOptimizeReasonField |
2758 : public BitField<BailoutReason, ShouldNotBeUsedOnceHintField::kNext, 8> { | 2756 : public BitField<BailoutReason, ShouldNotBeUsedOnceHintField::kNext, 8> { |
2759 }; | 2757 }; |
2760 | 2758 |
2761 int materialized_literal_count_; | |
2762 int expected_property_count_; | 2759 int expected_property_count_; |
2763 int parameter_count_; | 2760 int parameter_count_; |
2764 int function_length_; | 2761 int function_length_; |
2765 int function_token_position_; | 2762 int function_token_position_; |
2766 int yield_count_; | 2763 int yield_count_; |
2767 bool has_braces_; | 2764 bool has_braces_; |
2768 | 2765 |
2769 const AstString* raw_name_; | 2766 const AstString* raw_name_; |
2770 DeclarationScope* scope_; | 2767 DeclarationScope* scope_; |
2771 ZoneList<Statement*>* body_; | 2768 ZoneList<Statement*>* body_; |
(...skipping 713 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3485 if (!expression) expression = NewUndefinedLiteral(pos); | 3482 if (!expression) expression = NewUndefinedLiteral(pos); |
3486 return new (zone_) Yield(generator_object, expression, pos, on_exception); | 3483 return new (zone_) Yield(generator_object, expression, pos, on_exception); |
3487 } | 3484 } |
3488 | 3485 |
3489 Throw* NewThrow(Expression* exception, int pos) { | 3486 Throw* NewThrow(Expression* exception, int pos) { |
3490 return new (zone_) Throw(exception, pos); | 3487 return new (zone_) Throw(exception, pos); |
3491 } | 3488 } |
3492 | 3489 |
3493 FunctionLiteral* NewFunctionLiteral( | 3490 FunctionLiteral* NewFunctionLiteral( |
3494 const AstRawString* name, DeclarationScope* scope, | 3491 const AstRawString* name, DeclarationScope* scope, |
3495 ZoneList<Statement*>* body, int materialized_literal_count, | 3492 ZoneList<Statement*>* body, int expected_property_count, |
3496 int expected_property_count, int parameter_count, int function_length, | 3493 int parameter_count, int function_length, |
3497 FunctionLiteral::ParameterFlag has_duplicate_parameters, | 3494 FunctionLiteral::ParameterFlag has_duplicate_parameters, |
3498 FunctionLiteral::FunctionType function_type, | 3495 FunctionLiteral::FunctionType function_type, |
3499 FunctionLiteral::EagerCompileHint eager_compile_hint, int position, | 3496 FunctionLiteral::EagerCompileHint eager_compile_hint, int position, |
3500 bool has_braces, int function_literal_id) { | 3497 bool has_braces, int function_literal_id) { |
3501 return new (zone_) FunctionLiteral( | 3498 return new (zone_) FunctionLiteral( |
3502 zone_, name, ast_value_factory_, scope, body, | 3499 zone_, name, ast_value_factory_, scope, body, expected_property_count, |
3503 materialized_literal_count, expected_property_count, parameter_count, | 3500 parameter_count, function_length, function_type, |
3504 function_length, function_type, has_duplicate_parameters, | 3501 has_duplicate_parameters, eager_compile_hint, position, has_braces, |
3505 eager_compile_hint, position, has_braces, function_literal_id); | 3502 function_literal_id); |
3506 } | 3503 } |
3507 | 3504 |
3508 // Creates a FunctionLiteral representing a top-level script, the | 3505 // Creates a FunctionLiteral representing a top-level script, the |
3509 // result of an eval (top-level or otherwise), or the result of calling | 3506 // result of an eval (top-level or otherwise), or the result of calling |
3510 // the Function constructor. | 3507 // the Function constructor. |
3511 FunctionLiteral* NewScriptOrEvalFunctionLiteral( | 3508 FunctionLiteral* NewScriptOrEvalFunctionLiteral(DeclarationScope* scope, |
3512 DeclarationScope* scope, ZoneList<Statement*>* body, | 3509 ZoneList<Statement*>* body, |
3513 int materialized_literal_count, int expected_property_count, | 3510 int expected_property_count, |
3514 int parameter_count) { | 3511 int parameter_count) { |
3515 return new (zone_) FunctionLiteral( | 3512 return new (zone_) FunctionLiteral( |
3516 zone_, ast_value_factory_->empty_string(), ast_value_factory_, scope, | 3513 zone_, ast_value_factory_->empty_string(), ast_value_factory_, scope, |
3517 body, materialized_literal_count, expected_property_count, | 3514 body, expected_property_count, parameter_count, parameter_count, |
3518 parameter_count, parameter_count, FunctionLiteral::kAnonymousExpression, | 3515 FunctionLiteral::kAnonymousExpression, |
3519 FunctionLiteral::kNoDuplicateParameters, | 3516 FunctionLiteral::kNoDuplicateParameters, |
3520 FunctionLiteral::kShouldLazyCompile, 0, true, | 3517 FunctionLiteral::kShouldLazyCompile, 0, true, |
3521 FunctionLiteral::kIdTypeTopLevel); | 3518 FunctionLiteral::kIdTypeTopLevel); |
3522 } | 3519 } |
3523 | 3520 |
3524 ClassLiteral::Property* NewClassLiteralProperty( | 3521 ClassLiteral::Property* NewClassLiteralProperty( |
3525 Expression* key, Expression* value, ClassLiteralProperty::Kind kind, | 3522 Expression* key, Expression* value, ClassLiteralProperty::Kind kind, |
3526 bool is_static, bool is_computed_name) { | 3523 bool is_static, bool is_computed_name) { |
3527 return new (zone_) | 3524 return new (zone_) |
3528 ClassLiteral::Property(key, value, kind, is_static, is_computed_name); | 3525 ClassLiteral::Property(key, value, kind, is_static, is_computed_name); |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3644 : NULL; \ | 3641 : NULL; \ |
3645 } | 3642 } |
3646 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) | 3643 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) |
3647 #undef DECLARE_NODE_FUNCTIONS | 3644 #undef DECLARE_NODE_FUNCTIONS |
3648 | 3645 |
3649 | 3646 |
3650 } // namespace internal | 3647 } // namespace internal |
3651 } // namespace v8 | 3648 } // namespace v8 |
3652 | 3649 |
3653 #endif // V8_AST_AST_H_ | 3650 #endif // V8_AST_AST_H_ |
OLD | NEW |