Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(612)

Side by Side Diff: src/ast.h

Issue 1154103005: Refactor lexical home object binding (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: git rebase Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/arm64/full-codegen-arm64.cc ('k') | src/ast-numbering.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 2600 matching lines...) Expand 10 before | Expand all | Expand 10 after
2611 } 2611 }
2612 const ZoneFeedbackVectorSpec* feedback_vector_spec() const { 2612 const ZoneFeedbackVectorSpec* feedback_vector_spec() const {
2613 return ast_properties_.get_spec(); 2613 return ast_properties_.get_spec();
2614 } 2614 }
2615 bool dont_optimize() { return dont_optimize_reason_ != kNoReason; } 2615 bool dont_optimize() { return dont_optimize_reason_ != kNoReason; }
2616 BailoutReason dont_optimize_reason() { return dont_optimize_reason_; } 2616 BailoutReason dont_optimize_reason() { return dont_optimize_reason_; }
2617 void set_dont_optimize_reason(BailoutReason reason) { 2617 void set_dont_optimize_reason(BailoutReason reason) {
2618 dont_optimize_reason_ = reason; 2618 dont_optimize_reason_ = reason;
2619 } 2619 }
2620 2620
2621 static int num_ids() { return parent_num_ids() + 1; }
2622 TypeFeedbackId HomeObjectFeedbackId() { return TypeFeedbackId(local_id(0)); }
2623
2624 // Type feedback information.
2625 virtual FeedbackVectorRequirements ComputeFeedbackRequirements(
2626 Isolate* isolate, const ICSlotCache* cache) override {
2627 return FeedbackVectorRequirements(0, 1);
2628 }
2629 void SetFirstFeedbackICSlot(FeedbackVectorICSlot slot,
2630 ICSlotCache* cache) override {
2631 DCHECK(!slot.IsInvalid());
2632 home_object_feedback_slot_ = slot;
2633 }
2634 Code::Kind FeedbackICSlotKind(int index) override { return Code::LOAD_IC; }
2635
2636 FeedbackVectorICSlot HomeObjectFeedbackSlot() {
2637 DCHECK(!home_object_feedback_slot_.IsInvalid());
2638 return home_object_feedback_slot_;
2639 }
2640
2641 protected: 2621 protected:
2642 FunctionLiteral(Zone* zone, const AstRawString* name, 2622 FunctionLiteral(Zone* zone, const AstRawString* name,
2643 AstValueFactory* ast_value_factory, Scope* scope, 2623 AstValueFactory* ast_value_factory, Scope* scope,
2644 ZoneList<Statement*>* body, int materialized_literal_count, 2624 ZoneList<Statement*>* body, int materialized_literal_count,
2645 int expected_property_count, int handler_count, 2625 int expected_property_count, int handler_count,
2646 int parameter_count, FunctionType function_type, 2626 int parameter_count, FunctionType function_type,
2647 ParameterFlag has_duplicate_parameters, 2627 ParameterFlag has_duplicate_parameters,
2648 IsFunctionFlag is_function, 2628 IsFunctionFlag is_function,
2649 EagerCompileHint eager_compile_hint, FunctionKind kind, 2629 EagerCompileHint eager_compile_hint, FunctionKind kind,
2650 int position) 2630 int position)
2651 : Expression(zone, position), 2631 : Expression(zone, position),
2652 raw_name_(name), 2632 raw_name_(name),
2653 scope_(scope), 2633 scope_(scope),
2654 body_(body), 2634 body_(body),
2655 raw_inferred_name_(ast_value_factory->empty_string()), 2635 raw_inferred_name_(ast_value_factory->empty_string()),
2656 ast_properties_(zone), 2636 ast_properties_(zone),
2657 dont_optimize_reason_(kNoReason), 2637 dont_optimize_reason_(kNoReason),
2658 materialized_literal_count_(materialized_literal_count), 2638 materialized_literal_count_(materialized_literal_count),
2659 expected_property_count_(expected_property_count), 2639 expected_property_count_(expected_property_count),
2660 handler_count_(handler_count), 2640 handler_count_(handler_count),
2661 parameter_count_(parameter_count), 2641 parameter_count_(parameter_count),
2662 function_token_position_(RelocInfo::kNoPosition), 2642 function_token_position_(RelocInfo::kNoPosition) {
2663 home_object_feedback_slot_(FeedbackVectorICSlot::Invalid()) {
2664 bitfield_ = IsExpression::encode(function_type != DECLARATION) | 2643 bitfield_ = IsExpression::encode(function_type != DECLARATION) |
2665 IsAnonymous::encode(function_type == ANONYMOUS_EXPRESSION) | 2644 IsAnonymous::encode(function_type == ANONYMOUS_EXPRESSION) |
2666 Pretenure::encode(false) | 2645 Pretenure::encode(false) |
2667 HasDuplicateParameters::encode(has_duplicate_parameters) | 2646 HasDuplicateParameters::encode(has_duplicate_parameters) |
2668 IsFunction::encode(is_function) | 2647 IsFunction::encode(is_function) |
2669 EagerCompileHintBit::encode(eager_compile_hint) | 2648 EagerCompileHintBit::encode(eager_compile_hint) |
2670 FunctionKindBits::encode(kind) | 2649 FunctionKindBits::encode(kind) |
2671 ShouldBeUsedOnceHintBit::encode(kDontKnowIfShouldBeUsedOnce); 2650 ShouldBeUsedOnceHintBit::encode(kDontKnowIfShouldBeUsedOnce);
2672 DCHECK(IsValidFunctionKind(kind)); 2651 DCHECK(IsValidFunctionKind(kind));
2673 } 2652 }
2674 2653
2675 static int parent_num_ids() { return Expression::num_ids(); }
2676
2677 private: 2654 private:
2678 const AstRawString* raw_name_; 2655 const AstRawString* raw_name_;
2679 Handle<String> name_; 2656 Handle<String> name_;
2680 Handle<SharedFunctionInfo> shared_info_; 2657 Handle<SharedFunctionInfo> shared_info_;
2681 Scope* scope_; 2658 Scope* scope_;
2682 ZoneList<Statement*>* body_; 2659 ZoneList<Statement*>* body_;
2683 const AstString* raw_inferred_name_; 2660 const AstString* raw_inferred_name_;
2684 Handle<String> inferred_name_; 2661 Handle<String> inferred_name_;
2685 AstProperties ast_properties_; 2662 AstProperties ast_properties_;
2686 BailoutReason dont_optimize_reason_; 2663 BailoutReason dont_optimize_reason_;
2687 2664
2688 int materialized_literal_count_; 2665 int materialized_literal_count_;
2689 int expected_property_count_; 2666 int expected_property_count_;
2690 int handler_count_; 2667 int handler_count_;
2691 int parameter_count_; 2668 int parameter_count_;
2692 int function_token_position_; 2669 int function_token_position_;
2693 2670
2694 int local_id(int n) const { return base_id() + parent_num_ids() + n; }
2695 FeedbackVectorICSlot home_object_feedback_slot_;
2696
2697 unsigned bitfield_; 2671 unsigned bitfield_;
2698 class IsExpression : public BitField<bool, 0, 1> {}; 2672 class IsExpression : public BitField<bool, 0, 1> {};
2699 class IsAnonymous : public BitField<bool, 1, 1> {}; 2673 class IsAnonymous : public BitField<bool, 1, 1> {};
2700 class Pretenure : public BitField<bool, 2, 1> {}; 2674 class Pretenure : public BitField<bool, 2, 1> {};
2701 class HasDuplicateParameters : public BitField<ParameterFlag, 3, 1> {}; 2675 class HasDuplicateParameters : public BitField<ParameterFlag, 3, 1> {};
2702 class IsFunction : public BitField<IsFunctionFlag, 4, 1> {}; 2676 class IsFunction : public BitField<IsFunctionFlag, 4, 1> {};
2703 class EagerCompileHintBit : public BitField<EagerCompileHint, 5, 1> {}; 2677 class EagerCompileHintBit : public BitField<EagerCompileHint, 5, 1> {};
2704 class FunctionKindBits : public BitField<FunctionKind, 6, 8> {}; 2678 class FunctionKindBits : public BitField<FunctionKind, 6, 8> {};
2705 class ShouldBeUsedOnceHintBit : public BitField<ShouldBeUsedOnceHint, 15, 1> { 2679 class ShouldBeUsedOnceHintBit : public BitField<ShouldBeUsedOnceHint, 15, 1> {
2706 }; 2680 };
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
2788 protected: 2762 protected:
2789 ThisFunction(Zone* zone, int pos) : Expression(zone, pos) {} 2763 ThisFunction(Zone* zone, int pos) : Expression(zone, pos) {}
2790 }; 2764 };
2791 2765
2792 2766
2793 class SuperPropertyReference final : public Expression { 2767 class SuperPropertyReference final : public Expression {
2794 public: 2768 public:
2795 DECLARE_NODE_TYPE(SuperPropertyReference) 2769 DECLARE_NODE_TYPE(SuperPropertyReference)
2796 2770
2797 VariableProxy* this_var() const { return this_var_; } 2771 VariableProxy* this_var() const { return this_var_; }
2798 VariableProxy* home_object_var() const { return home_object_var_; } 2772 Expression* home_object() const { return home_object_; }
2799 2773
2800 protected: 2774 protected:
2801 SuperPropertyReference(Zone* zone, VariableProxy* this_var, 2775 SuperPropertyReference(Zone* zone, VariableProxy* this_var,
2802 VariableProxy* home_object_var, int pos) 2776 Expression* home_object, int pos)
2803 : Expression(zone, pos), 2777 : Expression(zone, pos), this_var_(this_var), home_object_(home_object) {
2804 this_var_(this_var),
2805 home_object_var_(home_object_var) {
2806 DCHECK(this_var->is_this()); 2778 DCHECK(this_var->is_this());
2807 DCHECK(home_object_var->raw_name()->IsOneByteEqualTo(".home_object")); 2779 DCHECK(home_object->IsProperty());
2808 } 2780 }
2809 2781
2810 private: 2782 private:
2811 VariableProxy* this_var_; 2783 VariableProxy* this_var_;
2812 VariableProxy* home_object_var_; 2784 Expression* home_object_;
2813 }; 2785 };
2814 2786
2815 2787
2816 class SuperCallReference final : public Expression { 2788 class SuperCallReference final : public Expression {
2817 public: 2789 public:
2818 DECLARE_NODE_TYPE(SuperCallReference) 2790 DECLARE_NODE_TYPE(SuperCallReference)
2819 2791
2820 VariableProxy* this_var() const { return this_var_; } 2792 VariableProxy* this_var() const { return this_var_; }
2821 VariableProxy* new_target_var() const { return new_target_var_; } 2793 VariableProxy* new_target_var() const { return new_target_var_; }
2822 VariableProxy* this_function_var() const { return this_function_var_; } 2794 VariableProxy* this_function_var() const { return this_function_var_; }
(...skipping 778 matching lines...) Expand 10 before | Expand all | Expand 10 after
3601 NativeFunctionLiteral* NewNativeFunctionLiteral(const AstRawString* name, 3573 NativeFunctionLiteral* NewNativeFunctionLiteral(const AstRawString* name,
3602 v8::Extension* extension, 3574 v8::Extension* extension,
3603 int pos) { 3575 int pos) {
3604 return new (zone_) NativeFunctionLiteral(zone_, name, extension, pos); 3576 return new (zone_) NativeFunctionLiteral(zone_, name, extension, pos);
3605 } 3577 }
3606 3578
3607 ThisFunction* NewThisFunction(int pos) { 3579 ThisFunction* NewThisFunction(int pos) {
3608 return new (zone_) ThisFunction(zone_, pos); 3580 return new (zone_) ThisFunction(zone_, pos);
3609 } 3581 }
3610 3582
3611 SuperPropertyReference* NewSuperPropertyReference( 3583 SuperPropertyReference* NewSuperPropertyReference(VariableProxy* this_var,
3612 VariableProxy* this_var, VariableProxy* home_object_var, int pos) { 3584 Expression* home_object,
3585 int pos) {
3613 return new (zone_) 3586 return new (zone_)
3614 SuperPropertyReference(zone_, this_var, home_object_var, pos); 3587 SuperPropertyReference(zone_, this_var, home_object, pos);
3615 } 3588 }
3616 3589
3617 SuperCallReference* NewSuperCallReference(VariableProxy* this_var, 3590 SuperCallReference* NewSuperCallReference(VariableProxy* this_var,
3618 VariableProxy* new_target_var, 3591 VariableProxy* new_target_var,
3619 VariableProxy* this_function_var, 3592 VariableProxy* this_function_var,
3620 int pos) { 3593 int pos) {
3621 return new (zone_) SuperCallReference(zone_, this_var, new_target_var, 3594 return new (zone_) SuperCallReference(zone_, this_var, new_target_var,
3622 this_function_var, pos); 3595 this_function_var, pos);
3623 } 3596 }
3624 3597
3625 private: 3598 private:
3626 Zone* zone_; 3599 Zone* zone_;
3627 AstValueFactory* ast_value_factory_; 3600 AstValueFactory* ast_value_factory_;
3628 }; 3601 };
3629 3602
3630 3603
3631 } } // namespace v8::internal 3604 } } // namespace v8::internal
3632 3605
3633 #endif // V8_AST_H_ 3606 #endif // V8_AST_H_
OLDNEW
« no previous file with comments | « src/arm64/full-codegen-arm64.cc ('k') | src/ast-numbering.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698