| 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 2630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2641 return HasDuplicateParameters::decode(bit_field_); | 2641 return HasDuplicateParameters::decode(bit_field_); |
| 2642 } | 2642 } |
| 2643 | 2643 |
| 2644 bool is_function() const { return IsFunction::decode(bit_field_); } | 2644 bool is_function() const { return IsFunction::decode(bit_field_); } |
| 2645 | 2645 |
| 2646 // This is used as a heuristic on when to eagerly compile a function | 2646 // This is used as a heuristic on when to eagerly compile a function |
| 2647 // literal. We consider the following constructs as hints that the | 2647 // literal. We consider the following constructs as hints that the |
| 2648 // function will be called immediately: | 2648 // function will be called immediately: |
| 2649 // - (function() { ... })(); | 2649 // - (function() { ... })(); |
| 2650 // - var x = function() { ... }(); | 2650 // - var x = function() { ... }(); |
| 2651 bool should_eager_compile() const { | 2651 bool ShouldEagerCompile() const; |
| 2652 return ShouldEagerCompile::decode(bit_field_); | 2652 void SetShouldEagerCompile(); |
| 2653 } | |
| 2654 void set_should_eager_compile() { | |
| 2655 bit_field_ = ShouldEagerCompile::update(bit_field_, true); | |
| 2656 } | |
| 2657 | 2653 |
| 2658 // A hint that we expect this function to be called (exactly) once, | 2654 // A hint that we expect this function to be called (exactly) once, |
| 2659 // i.e. we suspect it's an initialization function. | 2655 // i.e. we suspect it's an initialization function. |
| 2660 bool should_be_used_once_hint() const { | 2656 bool should_be_used_once_hint() const { |
| 2661 return ShouldNotBeUsedOnceHintField::decode(bit_field_); | 2657 return ShouldNotBeUsedOnceHintField::decode(bit_field_); |
| 2662 } | 2658 } |
| 2663 void set_should_be_used_once_hint() { | 2659 void set_should_be_used_once_hint() { |
| 2664 bit_field_ = ShouldNotBeUsedOnceHintField::update(bit_field_, true); | 2660 bit_field_ = ShouldNotBeUsedOnceHintField::update(bit_field_, true); |
| 2665 } | 2661 } |
| 2666 | 2662 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2727 raw_name_(name), | 2723 raw_name_(name), |
| 2728 scope_(scope), | 2724 scope_(scope), |
| 2729 body_(body), | 2725 body_(body), |
| 2730 raw_inferred_name_(ast_value_factory->empty_string()), | 2726 raw_inferred_name_(ast_value_factory->empty_string()), |
| 2731 ast_properties_(zone) { | 2727 ast_properties_(zone) { |
| 2732 bit_field_ |= | 2728 bit_field_ |= |
| 2733 FunctionTypeBits::encode(function_type) | Pretenure::encode(false) | | 2729 FunctionTypeBits::encode(function_type) | Pretenure::encode(false) | |
| 2734 HasDuplicateParameters::encode(has_duplicate_parameters == | 2730 HasDuplicateParameters::encode(has_duplicate_parameters == |
| 2735 kHasDuplicateParameters) | | 2731 kHasDuplicateParameters) | |
| 2736 IsFunction::encode(is_function) | | 2732 IsFunction::encode(is_function) | |
| 2737 ShouldEagerCompile::encode(eager_compile_hint == kShouldEagerCompile) | | |
| 2738 RequiresClassFieldInit::encode(false) | | 2733 RequiresClassFieldInit::encode(false) | |
| 2739 ShouldNotBeUsedOnceHintField::encode(false) | | 2734 ShouldNotBeUsedOnceHintField::encode(false) | |
| 2740 DontOptimizeReasonField::encode(kNoReason) | | 2735 DontOptimizeReasonField::encode(kNoReason) | |
| 2741 IsClassFieldInitializer::encode(false); | 2736 IsClassFieldInitializer::encode(false); |
| 2737 if (eager_compile_hint == kShouldEagerCompile) SetShouldEagerCompile(); |
| 2742 } | 2738 } |
| 2743 | 2739 |
| 2744 class FunctionTypeBits | 2740 class FunctionTypeBits |
| 2745 : public BitField<FunctionType, Expression::kNextBitFieldIndex, 2> {}; | 2741 : public BitField<FunctionType, Expression::kNextBitFieldIndex, 2> {}; |
| 2746 class Pretenure : public BitField<bool, FunctionTypeBits::kNext, 1> {}; | 2742 class Pretenure : public BitField<bool, FunctionTypeBits::kNext, 1> {}; |
| 2747 class HasDuplicateParameters : public BitField<bool, Pretenure::kNext, 1> {}; | 2743 class HasDuplicateParameters : public BitField<bool, Pretenure::kNext, 1> {}; |
| 2748 class IsFunction : public BitField<bool, HasDuplicateParameters::kNext, 1> {}; | 2744 class IsFunction : public BitField<bool, HasDuplicateParameters::kNext, 1> {}; |
| 2749 class ShouldEagerCompile : public BitField<bool, IsFunction::kNext, 1> {}; | |
| 2750 class ShouldNotBeUsedOnceHintField | 2745 class ShouldNotBeUsedOnceHintField |
| 2751 : public BitField<bool, ShouldEagerCompile::kNext, 1> {}; | 2746 : public BitField<bool, IsFunction::kNext, 1> {}; |
| 2752 class RequiresClassFieldInit | 2747 class RequiresClassFieldInit |
| 2753 : public BitField<bool, ShouldNotBeUsedOnceHintField::kNext, 1> {}; | 2748 : public BitField<bool, ShouldNotBeUsedOnceHintField::kNext, 1> {}; |
| 2754 class IsClassFieldInitializer | 2749 class IsClassFieldInitializer |
| 2755 : public BitField<bool, RequiresClassFieldInit::kNext, 1> {}; | 2750 : public BitField<bool, RequiresClassFieldInit::kNext, 1> {}; |
| 2756 class DontOptimizeReasonField | 2751 class DontOptimizeReasonField |
| 2757 : public BitField<BailoutReason, IsClassFieldInitializer::kNext, 8> {}; | 2752 : public BitField<BailoutReason, IsClassFieldInitializer::kNext, 8> {}; |
| 2758 | 2753 |
| 2759 int materialized_literal_count_; | 2754 int materialized_literal_count_; |
| 2760 int expected_property_count_; | 2755 int expected_property_count_; |
| 2761 int parameter_count_; | 2756 int parameter_count_; |
| (...skipping 838 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3600 : NULL; \ | 3595 : NULL; \ |
| 3601 } | 3596 } |
| 3602 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) | 3597 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) |
| 3603 #undef DECLARE_NODE_FUNCTIONS | 3598 #undef DECLARE_NODE_FUNCTIONS |
| 3604 | 3599 |
| 3605 | 3600 |
| 3606 } // namespace internal | 3601 } // namespace internal |
| 3607 } // namespace v8 | 3602 } // namespace v8 |
| 3608 | 3603 |
| 3609 #endif // V8_AST_AST_H_ | 3604 #endif // V8_AST_AST_H_ |
| OLD | NEW |