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

Side by Side Diff: src/ast.h

Issue 1135243004: [es6] Support super.property in eval and arrow functions (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: cleanup Created 5 years, 7 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.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 2526 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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 static int num_ids() { return parent_num_ids() + 1; }
2700 TypeFeedbackId HomeObjectFeedbackId() { return TypeFeedbackId(local_id(0)); } 2727 TypeFeedbackId HomeObjectFeedbackId() { return TypeFeedbackId(local_id(0)); }
2701 2728
2702 // Type feedback information. 2729 // Type feedback information.
2703 virtual FeedbackVectorRequirements ComputeFeedbackRequirements( 2730 virtual FeedbackVectorRequirements ComputeFeedbackRequirements(
2704 Isolate* isolate, const ICSlotCache* cache) override { 2731 Isolate* isolate, const ICSlotCache* cache) override {
2705 return FeedbackVectorRequirements(0, 1); 2732 return FeedbackVectorRequirements(0, 1);
2706 } 2733 }
2707 void SetFirstFeedbackICSlot(FeedbackVectorICSlot slot, 2734 void SetFirstFeedbackICSlot(FeedbackVectorICSlot slot,
2708 ICSlotCache* cache) override { 2735 ICSlotCache* cache) override {
2709 homeobject_feedback_slot_ = slot; 2736 home_object_feedback_slot_ = slot;
arv (Not doing code reviews) 2015/05/26 17:17:48 Initially I removed this feedback slot but it seem
arv (Not doing code reviews) 2015/05/26 18:46:30 I figured it out. TF does not support super. It ca
2710 } 2737 }
2711 Code::Kind FeedbackICSlotKind(int index) override { return Code::LOAD_IC; } 2738 Code::Kind FeedbackICSlotKind(int index) override { return Code::LOAD_IC; }
2712 2739
2713 FeedbackVectorICSlot HomeObjectFeedbackSlot() { 2740 FeedbackVectorICSlot HomeObjectFeedbackSlot() {
2714 DCHECK(!homeobject_feedback_slot_.IsInvalid()); 2741 DCHECK(!home_object_feedback_slot_.IsInvalid());
2715 return homeobject_feedback_slot_; 2742 return home_object_feedback_slot_;
2716 } 2743 }
2717 2744
2718 protected: 2745 protected:
2719 SuperReference(Zone* zone, VariableProxy* this_var, int pos) 2746 SuperReference(Zone* zone, VariableProxy* this_var,
2747 VariableProxy* home_object_var, int pos)
2720 : Expression(zone, pos), 2748 : Expression(zone, pos),
2721 this_var_(this_var), 2749 this_var_(this_var),
2722 homeobject_feedback_slot_(FeedbackVectorICSlot::Invalid()) { 2750 home_object_var_(home_object_var),
2751 home_object_feedback_slot_(FeedbackVectorICSlot::Invalid()) {
2723 DCHECK(this_var->is_this()); 2752 DCHECK(this_var->is_this());
2753 DCHECK(home_object_var->raw_name()->IsOneByteEqualTo(".home_object"));
2724 } 2754 }
2755
2725 static int parent_num_ids() { return Expression::num_ids(); } 2756 static int parent_num_ids() { return Expression::num_ids(); }
2726 2757
2727 private: 2758 private:
2728 int local_id(int n) const { return base_id() + parent_num_ids() + n; } 2759 int local_id(int n) const { return base_id() + parent_num_ids() + n; }
2729 2760
2730 VariableProxy* this_var_; 2761 VariableProxy* this_var_;
2731 FeedbackVectorICSlot homeobject_feedback_slot_; 2762 VariableProxy* home_object_var_;
2763
2764 FeedbackVectorICSlot home_object_feedback_slot_;
2732 }; 2765 };
2733 2766
2734 2767
2735 #undef DECLARE_NODE_TYPE 2768 #undef DECLARE_NODE_TYPE
2736 2769
2737 2770
2738 // ---------------------------------------------------------------------------- 2771 // ----------------------------------------------------------------------------
2739 // Regular expressions 2772 // Regular expressions
2740 2773
2741 2774
(...skipping 750 matching lines...) Expand 10 before | Expand all | Expand 10 after
3492 NativeFunctionLiteral* NewNativeFunctionLiteral(const AstRawString* name, 3525 NativeFunctionLiteral* NewNativeFunctionLiteral(const AstRawString* name,
3493 v8::Extension* extension, 3526 v8::Extension* extension,
3494 int pos) { 3527 int pos) {
3495 return new (zone_) NativeFunctionLiteral(zone_, name, extension, pos); 3528 return new (zone_) NativeFunctionLiteral(zone_, name, extension, pos);
3496 } 3529 }
3497 3530
3498 ThisFunction* NewThisFunction(int pos) { 3531 ThisFunction* NewThisFunction(int pos) {
3499 return new (zone_) ThisFunction(zone_, pos); 3532 return new (zone_) ThisFunction(zone_, pos);
3500 } 3533 }
3501 3534
3502 SuperReference* NewSuperReference(VariableProxy* this_var, int pos) { 3535 SuperReference* NewSuperReference(VariableProxy* this_var,
3503 return new (zone_) SuperReference(zone_, this_var, pos); 3536 VariableProxy* home_object_var, int pos) {
3537 return new (zone_) SuperReference(zone_, this_var, home_object_var, pos);
3504 } 3538 }
3505 3539
3506 private: 3540 private:
3507 Zone* zone_; 3541 Zone* zone_;
3508 AstValueFactory* ast_value_factory_; 3542 AstValueFactory* ast_value_factory_;
3509 }; 3543 };
3510 3544
3511 3545
3512 } } // namespace v8::internal 3546 } } // namespace v8::internal
3513 3547
3514 #endif // V8_AST_H_ 3548 #endif // V8_AST_H_
OLDNEW
« no previous file with comments | « src/arm64/full-codegen-arm64.cc ('k') | src/ast.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698