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 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
385 DCHECK(!BailoutId(base_id_).IsNone()); | 385 DCHECK(!BailoutId(base_id_).IsNone()); |
386 return base_id_; | 386 return base_id_; |
387 } | 387 } |
388 | 388 |
389 private: | 389 private: |
390 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | 390 int local_id(int n) const { return base_id() + parent_num_ids() + n; } |
391 | 391 |
392 int base_id_; | 392 int base_id_; |
393 Bounds bounds_; | 393 Bounds bounds_; |
394 class ToBooleanTypesField : public BitField16<uint16_t, 0, 9> {}; | 394 class ToBooleanTypesField : public BitField16<uint16_t, 0, 9> {}; |
| 395 |
| 396 protected: |
| 397 static const int kExpressionBitFieldNext = ToBooleanTypesField::kNext; |
395 uint16_t bit_field_; | 398 uint16_t bit_field_; |
396 // Ends with 16-bit field; deriving classes in turn begin with | 399 // Ends with 16-bit field; deriving classes in turn begin with |
397 // 16-bit fields for optimum packing efficiency. | 400 // 16-bit fields for optimum packing efficiency. |
398 }; | 401 }; |
399 | 402 |
400 | 403 |
401 class BreakableStatement : public Statement { | 404 class BreakableStatement : public Statement { |
402 public: | 405 public: |
403 enum BreakableType { | 406 enum BreakableType { |
404 TARGET_FOR_ANONYMOUS, | 407 TARGET_FOR_ANONYMOUS, |
(...skipping 2177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2582 Handle<String> name() const { return raw_name_->string(); } | 2585 Handle<String> name() const { return raw_name_->string(); } |
2583 const AstString* raw_name() const { return raw_name_; } | 2586 const AstString* raw_name() const { return raw_name_; } |
2584 void set_raw_name(const AstString* name) { raw_name_ = name; } | 2587 void set_raw_name(const AstString* name) { raw_name_ = name; } |
2585 Scope* scope() const { return scope_; } | 2588 Scope* scope() const { return scope_; } |
2586 ZoneList<Statement*>* body() const { return body_; } | 2589 ZoneList<Statement*>* body() const { return body_; } |
2587 void set_function_token_position(int pos) { function_token_position_ = pos; } | 2590 void set_function_token_position(int pos) { function_token_position_ = pos; } |
2588 int function_token_position() const { return function_token_position_; } | 2591 int function_token_position() const { return function_token_position_; } |
2589 int start_position() const; | 2592 int start_position() const; |
2590 int end_position() const; | 2593 int end_position() const; |
2591 int SourceSize() const { return end_position() - start_position(); } | 2594 int SourceSize() const { return end_position() - start_position(); } |
2592 bool is_declaration() const { return IsDeclaration::decode(bitfield_); } | 2595 bool is_declaration() const { |
| 2596 return IsDeclaration::decode(Expression::bit_field_); |
| 2597 } |
2593 bool is_named_expression() const { | 2598 bool is_named_expression() const { |
2594 return IsNamedExpression::decode(bitfield_); | 2599 return IsNamedExpression::decode(bitfield_); |
2595 } | 2600 } |
2596 bool is_anonymous_expression() const { | 2601 bool is_anonymous_expression() const { |
2597 return IsAnonymousExpression::decode(bitfield_); | 2602 return IsAnonymousExpression::decode(bitfield_); |
2598 } | 2603 } |
2599 LanguageMode language_mode() const; | 2604 LanguageMode language_mode() const; |
2600 | 2605 |
2601 static bool NeedsHomeObject(Expression* expr); | 2606 static bool NeedsHomeObject(Expression* expr); |
2602 | 2607 |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2709 body_(body), | 2714 body_(body), |
2710 raw_inferred_name_(ast_value_factory->empty_string()), | 2715 raw_inferred_name_(ast_value_factory->empty_string()), |
2711 ast_properties_(zone), | 2716 ast_properties_(zone), |
2712 dont_optimize_reason_(kNoReason), | 2717 dont_optimize_reason_(kNoReason), |
2713 materialized_literal_count_(materialized_literal_count), | 2718 materialized_literal_count_(materialized_literal_count), |
2714 expected_property_count_(expected_property_count), | 2719 expected_property_count_(expected_property_count), |
2715 parameter_count_(parameter_count), | 2720 parameter_count_(parameter_count), |
2716 function_token_position_(RelocInfo::kNoPosition), | 2721 function_token_position_(RelocInfo::kNoPosition), |
2717 yield_count_(0) { | 2722 yield_count_(0) { |
2718 bitfield_ = | 2723 bitfield_ = |
2719 IsDeclaration::encode(function_type == kDeclaration) | | |
2720 IsNamedExpression::encode(function_type == kNamedExpression) | | 2724 IsNamedExpression::encode(function_type == kNamedExpression) | |
2721 IsAnonymousExpression::encode(function_type == kAnonymousExpression) | | 2725 IsAnonymousExpression::encode(function_type == kAnonymousExpression) | |
2722 Pretenure::encode(false) | | 2726 Pretenure::encode(false) | |
2723 HasDuplicateParameters::encode(has_duplicate_parameters == | 2727 HasDuplicateParameters::encode(has_duplicate_parameters == |
2724 kHasDuplicateParameters) | | 2728 kHasDuplicateParameters) | |
2725 IsFunction::encode(is_function) | | 2729 IsFunction::encode(is_function) | |
2726 ShouldEagerCompile::encode(eager_compile_hint == kShouldEagerCompile) | | 2730 ShouldEagerCompile::encode(eager_compile_hint == kShouldEagerCompile) | |
2727 FunctionKindBits::encode(kind) | ShouldBeUsedOnceHint::encode(false); | 2731 FunctionKindBits::encode(kind) | ShouldBeUsedOnceHint::encode(false); |
2728 DCHECK(IsValidFunctionKind(kind)); | 2732 DCHECK(IsValidFunctionKind(kind)); |
2729 } | 2733 } |
2730 | 2734 |
2731 private: | 2735 private: |
2732 class IsDeclaration : public BitField16<bool, 0, 1> {}; | 2736 STATIC_ASSERT((Expression::kExpressionBitFieldNext + 1) < 16); |
2733 class IsNamedExpression : public BitField16<bool, 1, 1> {}; | 2737 class IsDeclaration |
2734 class IsAnonymousExpression : public BitField16<bool, 2, 1> {}; | 2738 : public BitField16<bool, Expression::kExpressionBitFieldNext, 1> {}; |
2735 class Pretenure : public BitField16<bool, 3, 1> {}; | 2739 class IsNamedExpression : public BitField16<bool, 0, 1> {}; |
2736 class HasDuplicateParameters : public BitField16<bool, 4, 1> {}; | 2740 class IsAnonymousExpression : public BitField16<bool, 1, 1> {}; |
2737 class IsFunction : public BitField16<bool, 5, 1> {}; | 2741 class Pretenure : public BitField16<bool, 2, 1> {}; |
2738 class ShouldEagerCompile : public BitField16<bool, 6, 1> {}; | 2742 class HasDuplicateParameters : public BitField16<bool, 3, 1> {}; |
2739 class ShouldBeUsedOnceHint : public BitField16<bool, 7, 1> {}; | 2743 class IsFunction : public BitField16<bool, 4, 1> {}; |
2740 class FunctionKindBits : public BitField16<FunctionKind, 8, 8> {}; | 2744 class ShouldEagerCompile : public BitField16<bool, 5, 1> {}; |
| 2745 class ShouldBeUsedOnceHint : public BitField16<bool, 6, 1> {}; |
| 2746 class FunctionKindBits : public BitField16<FunctionKind, 7, 9> {}; |
2741 | 2747 |
2742 // Start with 16-bit field, which should get packed together | 2748 // Start with 16-bit field, which should get packed together |
2743 // with Expression's trailing 16-bit field. | 2749 // with Expression's trailing 16-bit field. |
2744 uint16_t bitfield_; | 2750 uint16_t bitfield_; |
2745 | 2751 |
2746 const AstString* raw_name_; | 2752 const AstString* raw_name_; |
2747 Scope* scope_; | 2753 Scope* scope_; |
2748 ZoneList<Statement*>* body_; | 2754 ZoneList<Statement*>* body_; |
2749 const AstString* raw_inferred_name_; | 2755 const AstString* raw_inferred_name_; |
2750 Handle<String> inferred_name_; | 2756 Handle<String> inferred_name_; |
(...skipping 797 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3548 : NULL; \ | 3554 : NULL; \ |
3549 } | 3555 } |
3550 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) | 3556 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) |
3551 #undef DECLARE_NODE_FUNCTIONS | 3557 #undef DECLARE_NODE_FUNCTIONS |
3552 | 3558 |
3553 | 3559 |
3554 } // namespace internal | 3560 } // namespace internal |
3555 } // namespace v8 | 3561 } // namespace v8 |
3556 | 3562 |
3557 #endif // V8_AST_AST_H_ | 3563 #endif // V8_AST_AST_H_ |
OLD | NEW |