Chromium Code Reviews| 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 2581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2592 Handle<String> name() const { return raw_name_->string(); } | 2592 Handle<String> name() const { return raw_name_->string(); } |
| 2593 const AstString* raw_name() const { return raw_name_; } | 2593 const AstString* raw_name() const { return raw_name_; } |
| 2594 void set_raw_name(const AstString* name) { raw_name_ = name; } | 2594 void set_raw_name(const AstString* name) { raw_name_ = name; } |
| 2595 Scope* scope() const { return scope_; } | 2595 Scope* scope() const { return scope_; } |
| 2596 ZoneList<Statement*>* body() const { return body_; } | 2596 ZoneList<Statement*>* body() const { return body_; } |
| 2597 void set_function_token_position(int pos) { function_token_position_ = pos; } | 2597 void set_function_token_position(int pos) { function_token_position_ = pos; } |
| 2598 int function_token_position() const { return function_token_position_; } | 2598 int function_token_position() const { return function_token_position_; } |
| 2599 int start_position() const; | 2599 int start_position() const; |
| 2600 int end_position() const; | 2600 int end_position() const; |
| 2601 int SourceSize() const { return end_position() - start_position(); } | 2601 int SourceSize() const { return end_position() - start_position(); } |
| 2602 bool is_declaration() const { return IsDeclaration::decode(bitfield_); } | 2602 bool is_declaration() const { return function_type() == kDeclaration; } |
| 2603 bool is_named_expression() const { | 2603 bool is_named_expression() const { |
| 2604 return IsNamedExpression::decode(bitfield_); | 2604 return function_type() == kNamedExpression; |
| 2605 } | 2605 } |
| 2606 bool is_anonymous_expression() const { | 2606 bool is_anonymous_expression() const { |
| 2607 return IsAnonymousExpression::decode(bitfield_); | 2607 return function_type() == kAnonymousExpression; |
| 2608 } | 2608 } |
| 2609 LanguageMode language_mode() const; | 2609 LanguageMode language_mode() const; |
| 2610 | 2610 |
| 2611 static bool NeedsHomeObject(Expression* expr); | 2611 static bool NeedsHomeObject(Expression* expr); |
| 2612 | 2612 |
| 2613 int materialized_literal_count() { return materialized_literal_count_; } | 2613 int materialized_literal_count() { return materialized_literal_count_; } |
| 2614 int expected_property_count() { return expected_property_count_; } | 2614 int expected_property_count() { return expected_property_count_; } |
| 2615 int parameter_count() { return parameter_count_; } | 2615 int parameter_count() { return parameter_count_; } |
| 2616 | 2616 |
| 2617 bool AllowsLazyCompilation(); | 2617 bool AllowsLazyCompilation(); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2674 | 2674 |
| 2675 // A hint that we expect this function to be called (exactly) once, | 2675 // A hint that we expect this function to be called (exactly) once, |
| 2676 // i.e. we suspect it's an initialization function. | 2676 // i.e. we suspect it's an initialization function. |
| 2677 bool should_be_used_once_hint() const { | 2677 bool should_be_used_once_hint() const { |
| 2678 return ShouldBeUsedOnceHint::decode(bitfield_); | 2678 return ShouldBeUsedOnceHint::decode(bitfield_); |
| 2679 } | 2679 } |
| 2680 void set_should_be_used_once_hint() { | 2680 void set_should_be_used_once_hint() { |
| 2681 bitfield_ = ShouldBeUsedOnceHint::update(bitfield_, true); | 2681 bitfield_ = ShouldBeUsedOnceHint::update(bitfield_, true); |
| 2682 } | 2682 } |
| 2683 | 2683 |
| 2684 FunctionType function_type() const { | |
| 2685 return FunctionTypeBits::decode(bitfield_); | |
| 2686 } | |
| 2684 FunctionKind kind() const { return FunctionKindBits::decode(bitfield_); } | 2687 FunctionKind kind() const { return FunctionKindBits::decode(bitfield_); } |
| 2685 | 2688 |
| 2686 int ast_node_count() { return ast_properties_.node_count(); } | 2689 int ast_node_count() { return ast_properties_.node_count(); } |
| 2687 AstProperties::Flags flags() const { return ast_properties_.flags(); } | 2690 AstProperties::Flags flags() const { return ast_properties_.flags(); } |
| 2688 void set_ast_properties(AstProperties* ast_properties) { | 2691 void set_ast_properties(AstProperties* ast_properties) { |
| 2689 ast_properties_ = *ast_properties; | 2692 ast_properties_ = *ast_properties; |
| 2690 } | 2693 } |
| 2691 const FeedbackVectorSpec* feedback_vector_spec() const { | 2694 const FeedbackVectorSpec* feedback_vector_spec() const { |
| 2692 return ast_properties_.get_spec(); | 2695 return ast_properties_.get_spec(); |
| 2693 } | 2696 } |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 2719 body_(body), | 2722 body_(body), |
| 2720 raw_inferred_name_(ast_value_factory->empty_string()), | 2723 raw_inferred_name_(ast_value_factory->empty_string()), |
| 2721 ast_properties_(zone), | 2724 ast_properties_(zone), |
| 2722 dont_optimize_reason_(kNoReason), | 2725 dont_optimize_reason_(kNoReason), |
| 2723 materialized_literal_count_(materialized_literal_count), | 2726 materialized_literal_count_(materialized_literal_count), |
| 2724 expected_property_count_(expected_property_count), | 2727 expected_property_count_(expected_property_count), |
| 2725 parameter_count_(parameter_count), | 2728 parameter_count_(parameter_count), |
| 2726 function_token_position_(RelocInfo::kNoPosition), | 2729 function_token_position_(RelocInfo::kNoPosition), |
| 2727 yield_count_(0) { | 2730 yield_count_(0) { |
| 2728 bitfield_ = | 2731 bitfield_ = |
| 2729 IsDeclaration::encode(function_type == kDeclaration) | | 2732 FunctionTypeBits::encode(function_type) | Pretenure::encode(false) | |
| 2730 IsNamedExpression::encode(function_type == kNamedExpression) | | |
| 2731 IsAnonymousExpression::encode(function_type == kAnonymousExpression) | | |
| 2732 Pretenure::encode(false) | | |
| 2733 HasDuplicateParameters::encode(has_duplicate_parameters == | 2733 HasDuplicateParameters::encode(has_duplicate_parameters == |
| 2734 kHasDuplicateParameters) | | 2734 kHasDuplicateParameters) | |
| 2735 IsFunction::encode(is_function) | | 2735 IsFunction::encode(is_function) | |
| 2736 ShouldEagerCompile::encode(eager_compile_hint == kShouldEagerCompile) | | 2736 ShouldEagerCompile::encode(eager_compile_hint == kShouldEagerCompile) | |
| 2737 FunctionKindBits::encode(kind) | ShouldBeUsedOnceHint::encode(false); | 2737 FunctionKindBits::encode(kind) | ShouldBeUsedOnceHint::encode(false); |
| 2738 DCHECK(IsValidFunctionKind(kind)); | 2738 DCHECK(IsValidFunctionKind(kind)); |
| 2739 } | 2739 } |
| 2740 | 2740 |
| 2741 private: | 2741 private: |
| 2742 class IsDeclaration : public BitField16<bool, 0, 1> {}; | 2742 class FunctionTypeBits : public BitField16<FunctionType, 0, 2> {}; |
|
Dan Ehrenberg
2016/05/12 19:24:32
I like this new way that you found the extra bit!
| |
| 2743 class IsNamedExpression : public BitField16<bool, 1, 1> {}; | 2743 class Pretenure : public BitField16<bool, 2, 1> {}; |
| 2744 class IsAnonymousExpression : public BitField16<bool, 2, 1> {}; | 2744 class HasDuplicateParameters : public BitField16<bool, 3, 1> {}; |
| 2745 class Pretenure : public BitField16<bool, 3, 1> {}; | 2745 class IsFunction : public BitField16<bool, 4, 1> {}; |
| 2746 class HasDuplicateParameters : public BitField16<bool, 4, 1> {}; | 2746 class ShouldEagerCompile : public BitField16<bool, 5, 1> {}; |
| 2747 class IsFunction : public BitField16<bool, 5, 1> {}; | 2747 class ShouldBeUsedOnceHint : public BitField16<bool, 6, 1> {}; |
| 2748 class ShouldEagerCompile : public BitField16<bool, 6, 1> {}; | 2748 class FunctionKindBits : public BitField16<FunctionKind, 7, 9> {}; |
| 2749 class ShouldBeUsedOnceHint : public BitField16<bool, 7, 1> {}; | |
| 2750 class FunctionKindBits : public BitField16<FunctionKind, 8, 8> {}; | |
| 2751 | 2749 |
| 2752 // Start with 16-bit field, which should get packed together | 2750 // Start with 16-bit field, which should get packed together |
| 2753 // with Expression's trailing 16-bit field. | 2751 // with Expression's trailing 16-bit field. |
| 2754 uint16_t bitfield_; | 2752 uint16_t bitfield_; |
| 2755 | 2753 |
| 2756 const AstString* raw_name_; | 2754 const AstString* raw_name_; |
| 2757 Scope* scope_; | 2755 Scope* scope_; |
| 2758 ZoneList<Statement*>* body_; | 2756 ZoneList<Statement*>* body_; |
| 2759 const AstString* raw_inferred_name_; | 2757 const AstString* raw_inferred_name_; |
| 2760 Handle<String> inferred_name_; | 2758 Handle<String> inferred_name_; |
| (...skipping 797 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3558 : NULL; \ | 3556 : NULL; \ |
| 3559 } | 3557 } |
| 3560 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) | 3558 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) |
| 3561 #undef DECLARE_NODE_FUNCTIONS | 3559 #undef DECLARE_NODE_FUNCTIONS |
| 3562 | 3560 |
| 3563 | 3561 |
| 3564 } // namespace internal | 3562 } // namespace internal |
| 3565 } // namespace v8 | 3563 } // namespace v8 |
| 3566 | 3564 |
| 3567 #endif // V8_AST_AST_H_ | 3565 #endif // V8_AST_AST_H_ |
| OLD | NEW |