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-value-factory.h" | 9 #include "src/ast/ast-value-factory.h" |
10 #include "src/ast/modules.h" | 10 #include "src/ast/modules.h" |
(...skipping 2575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2586 Handle<String> name() const { return raw_name_->string(); } | 2586 Handle<String> name() const { return raw_name_->string(); } |
2587 const AstString* raw_name() const { return raw_name_; } | 2587 const AstString* raw_name() const { return raw_name_; } |
2588 void set_raw_name(const AstString* name) { raw_name_ = name; } | 2588 void set_raw_name(const AstString* name) { raw_name_ = name; } |
2589 Scope* scope() const { return scope_; } | 2589 Scope* scope() const { return scope_; } |
2590 ZoneList<Statement*>* body() const { return body_; } | 2590 ZoneList<Statement*>* body() const { return body_; } |
2591 void set_function_token_position(int pos) { function_token_position_ = pos; } | 2591 void set_function_token_position(int pos) { function_token_position_ = pos; } |
2592 int function_token_position() const { return function_token_position_; } | 2592 int function_token_position() const { return function_token_position_; } |
2593 int start_position() const; | 2593 int start_position() const; |
2594 int end_position() const; | 2594 int end_position() const; |
2595 int SourceSize() const { return end_position() - start_position(); } | 2595 int SourceSize() const { return end_position() - start_position(); } |
2596 bool is_declaration() const { return IsDeclaration::decode(bitfield_); } | 2596 bool is_declaration() const { return function_type() == kDeclaration; } |
2597 bool is_named_expression() const { | 2597 bool is_named_expression() const { |
2598 return IsNamedExpression::decode(bitfield_); | 2598 return function_type() == kNamedExpression; |
2599 } | 2599 } |
2600 bool is_anonymous_expression() const { | 2600 bool is_anonymous_expression() const { |
2601 return IsAnonymousExpression::decode(bitfield_); | 2601 return function_type() == kAnonymousExpression; |
2602 } | 2602 } |
2603 LanguageMode language_mode() const; | 2603 LanguageMode language_mode() const; |
2604 | 2604 |
2605 static bool NeedsHomeObject(Expression* expr); | 2605 static bool NeedsHomeObject(Expression* expr); |
2606 | 2606 |
2607 int materialized_literal_count() { return materialized_literal_count_; } | 2607 int materialized_literal_count() { return materialized_literal_count_; } |
2608 int expected_property_count() { return expected_property_count_; } | 2608 int expected_property_count() { return expected_property_count_; } |
2609 int parameter_count() { return parameter_count_; } | 2609 int parameter_count() { return parameter_count_; } |
2610 | 2610 |
2611 bool AllowsLazyCompilation(); | 2611 bool AllowsLazyCompilation(); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2668 | 2668 |
2669 // A hint that we expect this function to be called (exactly) once, | 2669 // A hint that we expect this function to be called (exactly) once, |
2670 // i.e. we suspect it's an initialization function. | 2670 // i.e. we suspect it's an initialization function. |
2671 bool should_be_used_once_hint() const { | 2671 bool should_be_used_once_hint() const { |
2672 return ShouldBeUsedOnceHint::decode(bitfield_); | 2672 return ShouldBeUsedOnceHint::decode(bitfield_); |
2673 } | 2673 } |
2674 void set_should_be_used_once_hint() { | 2674 void set_should_be_used_once_hint() { |
2675 bitfield_ = ShouldBeUsedOnceHint::update(bitfield_, true); | 2675 bitfield_ = ShouldBeUsedOnceHint::update(bitfield_, true); |
2676 } | 2676 } |
2677 | 2677 |
| 2678 FunctionType function_type() const { |
| 2679 return FunctionTypeBits::decode(bitfield_); |
| 2680 } |
2678 FunctionKind kind() const { return FunctionKindBits::decode(bitfield_); } | 2681 FunctionKind kind() const { return FunctionKindBits::decode(bitfield_); } |
2679 | 2682 |
2680 int ast_node_count() { return ast_properties_.node_count(); } | 2683 int ast_node_count() { return ast_properties_.node_count(); } |
2681 AstProperties::Flags flags() const { return ast_properties_.flags(); } | 2684 AstProperties::Flags flags() const { return ast_properties_.flags(); } |
2682 void set_ast_properties(AstProperties* ast_properties) { | 2685 void set_ast_properties(AstProperties* ast_properties) { |
2683 ast_properties_ = *ast_properties; | 2686 ast_properties_ = *ast_properties; |
2684 } | 2687 } |
2685 const FeedbackVectorSpec* feedback_vector_spec() const { | 2688 const FeedbackVectorSpec* feedback_vector_spec() const { |
2686 return ast_properties_.get_spec(); | 2689 return ast_properties_.get_spec(); |
2687 } | 2690 } |
(...skipping 25 matching lines...) Expand all Loading... |
2713 body_(body), | 2716 body_(body), |
2714 raw_inferred_name_(ast_value_factory->empty_string()), | 2717 raw_inferred_name_(ast_value_factory->empty_string()), |
2715 ast_properties_(zone), | 2718 ast_properties_(zone), |
2716 dont_optimize_reason_(kNoReason), | 2719 dont_optimize_reason_(kNoReason), |
2717 materialized_literal_count_(materialized_literal_count), | 2720 materialized_literal_count_(materialized_literal_count), |
2718 expected_property_count_(expected_property_count), | 2721 expected_property_count_(expected_property_count), |
2719 parameter_count_(parameter_count), | 2722 parameter_count_(parameter_count), |
2720 function_token_position_(RelocInfo::kNoPosition), | 2723 function_token_position_(RelocInfo::kNoPosition), |
2721 yield_count_(0) { | 2724 yield_count_(0) { |
2722 bitfield_ = | 2725 bitfield_ = |
2723 IsDeclaration::encode(function_type == kDeclaration) | | 2726 FunctionTypeBits::encode(function_type) | Pretenure::encode(false) | |
2724 IsNamedExpression::encode(function_type == kNamedExpression) | | |
2725 IsAnonymousExpression::encode(function_type == kAnonymousExpression) | | |
2726 Pretenure::encode(false) | | |
2727 HasDuplicateParameters::encode(has_duplicate_parameters == | 2727 HasDuplicateParameters::encode(has_duplicate_parameters == |
2728 kHasDuplicateParameters) | | 2728 kHasDuplicateParameters) | |
2729 IsFunction::encode(is_function) | | 2729 IsFunction::encode(is_function) | |
2730 ShouldEagerCompile::encode(eager_compile_hint == kShouldEagerCompile) | | 2730 ShouldEagerCompile::encode(eager_compile_hint == kShouldEagerCompile) | |
2731 FunctionKindBits::encode(kind) | ShouldBeUsedOnceHint::encode(false); | 2731 FunctionKindBits::encode(kind) | ShouldBeUsedOnceHint::encode(false); |
2732 DCHECK(IsValidFunctionKind(kind)); | 2732 DCHECK(IsValidFunctionKind(kind)); |
2733 } | 2733 } |
2734 | 2734 |
2735 private: | 2735 private: |
2736 class IsDeclaration : public BitField16<bool, 0, 1> {}; | 2736 class FunctionTypeBits : public BitField16<FunctionType, 0, 2> {}; |
2737 class IsNamedExpression : public BitField16<bool, 1, 1> {}; | 2737 class Pretenure : public BitField16<bool, 2, 1> {}; |
2738 class IsAnonymousExpression : public BitField16<bool, 2, 1> {}; | 2738 class HasDuplicateParameters : public BitField16<bool, 3, 1> {}; |
2739 class Pretenure : public BitField16<bool, 3, 1> {}; | 2739 class IsFunction : public BitField16<bool, 4, 1> {}; |
2740 class HasDuplicateParameters : public BitField16<bool, 4, 1> {}; | 2740 class ShouldEagerCompile : public BitField16<bool, 5, 1> {}; |
2741 class IsFunction : public BitField16<bool, 5, 1> {}; | 2741 class ShouldBeUsedOnceHint : public BitField16<bool, 6, 1> {}; |
2742 class ShouldEagerCompile : public BitField16<bool, 6, 1> {}; | 2742 class FunctionKindBits : public BitField16<FunctionKind, 7, 9> {}; |
2743 class ShouldBeUsedOnceHint : public BitField16<bool, 7, 1> {}; | |
2744 class FunctionKindBits : public BitField16<FunctionKind, 8, 8> {}; | |
2745 | 2743 |
2746 // Start with 16-bit field, which should get packed together | 2744 // Start with 16-bit field, which should get packed together |
2747 // with Expression's trailing 16-bit field. | 2745 // with Expression's trailing 16-bit field. |
2748 uint16_t bitfield_; | 2746 uint16_t bitfield_; |
2749 | 2747 |
2750 const AstString* raw_name_; | 2748 const AstString* raw_name_; |
2751 Scope* scope_; | 2749 Scope* scope_; |
2752 ZoneList<Statement*>* body_; | 2750 ZoneList<Statement*>* body_; |
2753 const AstString* raw_inferred_name_; | 2751 const AstString* raw_inferred_name_; |
2754 Handle<String> inferred_name_; | 2752 Handle<String> inferred_name_; |
(...skipping 797 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3552 : NULL; \ | 3550 : NULL; \ |
3553 } | 3551 } |
3554 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) | 3552 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) |
3555 #undef DECLARE_NODE_FUNCTIONS | 3553 #undef DECLARE_NODE_FUNCTIONS |
3556 | 3554 |
3557 | 3555 |
3558 } // namespace internal | 3556 } // namespace internal |
3559 } // namespace v8 | 3557 } // namespace v8 |
3560 | 3558 |
3561 #endif // V8_AST_AST_H_ | 3559 #endif // V8_AST_AST_H_ |
OLD | NEW |