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