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_H_ | 5 #ifndef V8_AST_H_ |
6 #define V8_AST_H_ | 6 #define V8_AST_H_ |
7 | 7 |
8 #include "src/v8.h" | 8 #include "src/v8.h" |
9 | 9 |
10 #include "src/assembler.h" | 10 #include "src/assembler.h" |
(...skipping 2526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2537 } | 2537 } |
2538 const ZoneFeedbackVectorSpec* feedback_vector_spec() const { | 2538 const ZoneFeedbackVectorSpec* feedback_vector_spec() const { |
2539 return ast_properties_.get_spec(); | 2539 return ast_properties_.get_spec(); |
2540 } | 2540 } |
2541 bool dont_optimize() { return dont_optimize_reason_ != kNoReason; } | 2541 bool dont_optimize() { return dont_optimize_reason_ != kNoReason; } |
2542 BailoutReason dont_optimize_reason() { return dont_optimize_reason_; } | 2542 BailoutReason dont_optimize_reason() { return dont_optimize_reason_; } |
2543 void set_dont_optimize_reason(BailoutReason reason) { | 2543 void set_dont_optimize_reason(BailoutReason reason) { |
2544 dont_optimize_reason_ = reason; | 2544 dont_optimize_reason_ = reason; |
2545 } | 2545 } |
2546 | 2546 |
| 2547 static int num_ids() { return parent_num_ids() + 1; } |
| 2548 TypeFeedbackId HomeObjectFeedbackId() { return TypeFeedbackId(local_id(0)); } |
| 2549 |
| 2550 // Type feedback information. |
| 2551 virtual FeedbackVectorRequirements ComputeFeedbackRequirements( |
| 2552 Isolate* isolate, const ICSlotCache* cache) override { |
| 2553 return FeedbackVectorRequirements(0, 1); |
| 2554 } |
| 2555 void SetFirstFeedbackICSlot(FeedbackVectorICSlot slot, |
| 2556 ICSlotCache* cache) override { |
| 2557 DCHECK(!slot.IsInvalid()); |
| 2558 home_object_feedback_slot_ = slot; |
| 2559 } |
| 2560 Code::Kind FeedbackICSlotKind(int index) override { return Code::LOAD_IC; } |
| 2561 |
| 2562 FeedbackVectorICSlot HomeObjectFeedbackSlot() { |
| 2563 DCHECK(!home_object_feedback_slot_.IsInvalid()); |
| 2564 return home_object_feedback_slot_; |
| 2565 } |
| 2566 |
2547 protected: | 2567 protected: |
2548 FunctionLiteral(Zone* zone, const AstRawString* name, | 2568 FunctionLiteral(Zone* zone, const AstRawString* name, |
2549 AstValueFactory* ast_value_factory, Scope* scope, | 2569 AstValueFactory* ast_value_factory, Scope* scope, |
2550 ZoneList<Statement*>* body, int materialized_literal_count, | 2570 ZoneList<Statement*>* body, int materialized_literal_count, |
2551 int expected_property_count, int handler_count, | 2571 int expected_property_count, int handler_count, |
2552 int parameter_count, FunctionType function_type, | 2572 int parameter_count, FunctionType function_type, |
2553 ParameterFlag has_duplicate_parameters, | 2573 ParameterFlag has_duplicate_parameters, |
2554 IsFunctionFlag is_function, | 2574 IsFunctionFlag is_function, |
2555 EagerCompileHint eager_compile_hint, FunctionKind kind, | 2575 EagerCompileHint eager_compile_hint, FunctionKind kind, |
2556 int position) | 2576 int position) |
2557 : Expression(zone, position), | 2577 : Expression(zone, position), |
2558 raw_name_(name), | 2578 raw_name_(name), |
2559 scope_(scope), | 2579 scope_(scope), |
2560 body_(body), | 2580 body_(body), |
2561 raw_inferred_name_(ast_value_factory->empty_string()), | 2581 raw_inferred_name_(ast_value_factory->empty_string()), |
2562 ast_properties_(zone), | 2582 ast_properties_(zone), |
2563 dont_optimize_reason_(kNoReason), | 2583 dont_optimize_reason_(kNoReason), |
2564 materialized_literal_count_(materialized_literal_count), | 2584 materialized_literal_count_(materialized_literal_count), |
2565 expected_property_count_(expected_property_count), | 2585 expected_property_count_(expected_property_count), |
2566 handler_count_(handler_count), | 2586 handler_count_(handler_count), |
2567 parameter_count_(parameter_count), | 2587 parameter_count_(parameter_count), |
2568 function_token_position_(RelocInfo::kNoPosition) { | 2588 function_token_position_(RelocInfo::kNoPosition), |
| 2589 home_object_feedback_slot_(FeedbackVectorICSlot::Invalid()) { |
2569 bitfield_ = IsExpression::encode(function_type != DECLARATION) | | 2590 bitfield_ = IsExpression::encode(function_type != DECLARATION) | |
2570 IsAnonymous::encode(function_type == ANONYMOUS_EXPRESSION) | | 2591 IsAnonymous::encode(function_type == ANONYMOUS_EXPRESSION) | |
2571 Pretenure::encode(false) | | 2592 Pretenure::encode(false) | |
2572 HasDuplicateParameters::encode(has_duplicate_parameters) | | 2593 HasDuplicateParameters::encode(has_duplicate_parameters) | |
2573 IsFunction::encode(is_function) | | 2594 IsFunction::encode(is_function) | |
2574 EagerCompileHintBit::encode(eager_compile_hint) | | 2595 EagerCompileHintBit::encode(eager_compile_hint) | |
2575 FunctionKindBits::encode(kind) | | 2596 FunctionKindBits::encode(kind) | |
2576 ShouldBeUsedOnceHintBit::encode(kDontKnowIfShouldBeUsedOnce); | 2597 ShouldBeUsedOnceHintBit::encode(kDontKnowIfShouldBeUsedOnce); |
2577 DCHECK(IsValidFunctionKind(kind)); | 2598 DCHECK(IsValidFunctionKind(kind)); |
2578 } | 2599 } |
2579 | 2600 |
| 2601 static int parent_num_ids() { return Expression::num_ids(); } |
| 2602 |
2580 private: | 2603 private: |
2581 const AstRawString* raw_name_; | 2604 const AstRawString* raw_name_; |
2582 Handle<String> name_; | 2605 Handle<String> name_; |
2583 Handle<SharedFunctionInfo> shared_info_; | 2606 Handle<SharedFunctionInfo> shared_info_; |
2584 Scope* scope_; | 2607 Scope* scope_; |
2585 ZoneList<Statement*>* body_; | 2608 ZoneList<Statement*>* body_; |
2586 const AstString* raw_inferred_name_; | 2609 const AstString* raw_inferred_name_; |
2587 Handle<String> inferred_name_; | 2610 Handle<String> inferred_name_; |
2588 AstProperties ast_properties_; | 2611 AstProperties ast_properties_; |
2589 BailoutReason dont_optimize_reason_; | 2612 BailoutReason dont_optimize_reason_; |
2590 | 2613 |
2591 int materialized_literal_count_; | 2614 int materialized_literal_count_; |
2592 int expected_property_count_; | 2615 int expected_property_count_; |
2593 int handler_count_; | 2616 int handler_count_; |
2594 int parameter_count_; | 2617 int parameter_count_; |
2595 int function_token_position_; | 2618 int function_token_position_; |
2596 | 2619 |
| 2620 int local_id(int n) const { return base_id() + parent_num_ids() + n; } |
| 2621 FeedbackVectorICSlot home_object_feedback_slot_; |
| 2622 |
2597 unsigned bitfield_; | 2623 unsigned bitfield_; |
2598 class IsExpression : public BitField<bool, 0, 1> {}; | 2624 class IsExpression : public BitField<bool, 0, 1> {}; |
2599 class IsAnonymous : public BitField<bool, 1, 1> {}; | 2625 class IsAnonymous : public BitField<bool, 1, 1> {}; |
2600 class Pretenure : public BitField<bool, 2, 1> {}; | 2626 class Pretenure : public BitField<bool, 2, 1> {}; |
2601 class HasDuplicateParameters : public BitField<ParameterFlag, 3, 1> {}; | 2627 class HasDuplicateParameters : public BitField<ParameterFlag, 3, 1> {}; |
2602 class IsFunction : public BitField<IsFunctionFlag, 4, 1> {}; | 2628 class IsFunction : public BitField<IsFunctionFlag, 4, 1> {}; |
2603 class EagerCompileHintBit : public BitField<EagerCompileHint, 5, 1> {}; | 2629 class EagerCompileHintBit : public BitField<EagerCompileHint, 5, 1> {}; |
2604 class FunctionKindBits : public BitField<FunctionKind, 6, 8> {}; | 2630 class FunctionKindBits : public BitField<FunctionKind, 6, 8> {}; |
2605 class ShouldBeUsedOnceHintBit : public BitField<ShouldBeUsedOnceHint, 15, 1> { | 2631 class ShouldBeUsedOnceHintBit : public BitField<ShouldBeUsedOnceHint, 15, 1> { |
2606 }; | 2632 }; |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2688 protected: | 2714 protected: |
2689 ThisFunction(Zone* zone, int pos) : Expression(zone, pos) {} | 2715 ThisFunction(Zone* zone, int pos) : Expression(zone, pos) {} |
2690 }; | 2716 }; |
2691 | 2717 |
2692 | 2718 |
2693 class SuperReference final : public Expression { | 2719 class SuperReference final : public Expression { |
2694 public: | 2720 public: |
2695 DECLARE_NODE_TYPE(SuperReference) | 2721 DECLARE_NODE_TYPE(SuperReference) |
2696 | 2722 |
2697 VariableProxy* this_var() const { return this_var_; } | 2723 VariableProxy* this_var() const { return this_var_; } |
| 2724 VariableProxy* home_object_var() const { return home_object_var_; } |
2698 | 2725 |
2699 static int num_ids() { return parent_num_ids() + 1; } | 2726 protected: |
2700 TypeFeedbackId HomeObjectFeedbackId() { return TypeFeedbackId(local_id(0)); } | 2727 SuperReference(Zone* zone, VariableProxy* this_var, |
2701 | 2728 VariableProxy* home_object_var, int pos) |
2702 // Type feedback information. | 2729 : Expression(zone, pos), |
2703 virtual FeedbackVectorRequirements ComputeFeedbackRequirements( | 2730 this_var_(this_var), |
2704 Isolate* isolate, const ICSlotCache* cache) override { | 2731 home_object_var_(home_object_var) { |
2705 return FeedbackVectorRequirements(0, 1); | 2732 DCHECK(this_var->is_this()); |
2706 } | 2733 DCHECK(home_object_var->raw_name()->IsOneByteEqualTo(".home_object")); |
2707 void SetFirstFeedbackICSlot(FeedbackVectorICSlot slot, | |
2708 ICSlotCache* cache) override { | |
2709 homeobject_feedback_slot_ = slot; | |
2710 } | |
2711 Code::Kind FeedbackICSlotKind(int index) override { return Code::LOAD_IC; } | |
2712 | |
2713 FeedbackVectorICSlot HomeObjectFeedbackSlot() { | |
2714 DCHECK(!homeobject_feedback_slot_.IsInvalid()); | |
2715 return homeobject_feedback_slot_; | |
2716 } | 2734 } |
2717 | 2735 |
2718 protected: | |
2719 SuperReference(Zone* zone, VariableProxy* this_var, int pos) | |
2720 : Expression(zone, pos), | |
2721 this_var_(this_var), | |
2722 homeobject_feedback_slot_(FeedbackVectorICSlot::Invalid()) { | |
2723 DCHECK(this_var->is_this()); | |
2724 } | |
2725 static int parent_num_ids() { return Expression::num_ids(); } | |
2726 | |
2727 private: | 2736 private: |
2728 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | |
2729 | |
2730 VariableProxy* this_var_; | 2737 VariableProxy* this_var_; |
2731 FeedbackVectorICSlot homeobject_feedback_slot_; | 2738 VariableProxy* home_object_var_; |
2732 }; | 2739 }; |
2733 | 2740 |
2734 | 2741 |
2735 #undef DECLARE_NODE_TYPE | 2742 #undef DECLARE_NODE_TYPE |
2736 | 2743 |
2737 | 2744 |
2738 // ---------------------------------------------------------------------------- | 2745 // ---------------------------------------------------------------------------- |
2739 // Regular expressions | 2746 // Regular expressions |
2740 | 2747 |
2741 | 2748 |
(...skipping 750 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3492 NativeFunctionLiteral* NewNativeFunctionLiteral(const AstRawString* name, | 3499 NativeFunctionLiteral* NewNativeFunctionLiteral(const AstRawString* name, |
3493 v8::Extension* extension, | 3500 v8::Extension* extension, |
3494 int pos) { | 3501 int pos) { |
3495 return new (zone_) NativeFunctionLiteral(zone_, name, extension, pos); | 3502 return new (zone_) NativeFunctionLiteral(zone_, name, extension, pos); |
3496 } | 3503 } |
3497 | 3504 |
3498 ThisFunction* NewThisFunction(int pos) { | 3505 ThisFunction* NewThisFunction(int pos) { |
3499 return new (zone_) ThisFunction(zone_, pos); | 3506 return new (zone_) ThisFunction(zone_, pos); |
3500 } | 3507 } |
3501 | 3508 |
3502 SuperReference* NewSuperReference(VariableProxy* this_var, int pos) { | 3509 SuperReference* NewSuperReference(VariableProxy* this_var, |
3503 return new (zone_) SuperReference(zone_, this_var, pos); | 3510 VariableProxy* home_object_var, int pos) { |
| 3511 return new (zone_) SuperReference(zone_, this_var, home_object_var, pos); |
3504 } | 3512 } |
3505 | 3513 |
3506 private: | 3514 private: |
3507 Zone* zone_; | 3515 Zone* zone_; |
3508 AstValueFactory* ast_value_factory_; | 3516 AstValueFactory* ast_value_factory_; |
3509 }; | 3517 }; |
3510 | 3518 |
3511 | 3519 |
3512 } } // namespace v8::internal | 3520 } } // namespace v8::internal |
3513 | 3521 |
3514 #endif // V8_AST_H_ | 3522 #endif // V8_AST_H_ |
OLD | NEW |