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

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

Powered by Google App Engine
This is Rietveld 408576698