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 2953 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2964 private: | 2964 private: |
2965 friend class AstNodeFactory; | 2965 friend class AstNodeFactory; |
2966 | 2966 |
2967 explicit EmptyParentheses(int pos) : Expression(pos, kEmptyParentheses) {} | 2967 explicit EmptyParentheses(int pos) : Expression(pos, kEmptyParentheses) {} |
2968 }; | 2968 }; |
2969 | 2969 |
2970 // Represents the spec operation `GetIterator()` | 2970 // Represents the spec operation `GetIterator()` |
2971 // (defined at https://tc39.github.io/ecma262/#sec-getiterator). Ignition | 2971 // (defined at https://tc39.github.io/ecma262/#sec-getiterator). Ignition |
2972 // desugars this into a LoadIC / JSLoadNamed, CallIC, and a type-check to | 2972 // desugars this into a LoadIC / JSLoadNamed, CallIC, and a type-check to |
2973 // validate return value of the Symbol.iterator() call. | 2973 // validate return value of the Symbol.iterator() call. |
| 2974 enum class IteratorType { kNormal, kAsync }; |
2974 class GetIterator final : public Expression { | 2975 class GetIterator final : public Expression { |
2975 public: | 2976 public: |
| 2977 using Hint = IteratorType; |
| 2978 |
| 2979 Hint hint() const { return hint_; } |
| 2980 |
2976 Expression* iterable() const { return iterable_; } | 2981 Expression* iterable() const { return iterable_; } |
2977 void set_iterable(Expression* iterable) { iterable_ = iterable; } | 2982 void set_iterable(Expression* iterable) { iterable_ = iterable; } |
2978 | 2983 |
2979 static int num_ids() { return parent_num_ids(); } | 2984 static int num_ids() { return parent_num_ids(); } |
2980 | 2985 |
2981 void AssignFeedbackVectorSlots(FeedbackVectorSpec* spec, | 2986 void AssignFeedbackVectorSlots(FeedbackVectorSpec* spec, |
2982 FeedbackVectorSlotCache* cache) { | 2987 FeedbackVectorSlotCache* cache) { |
2983 iterator_property_feedback_slot_ = | 2988 iterator_property_feedback_slot_ = |
2984 spec->AddSlot(FeedbackVectorSlotKind::LOAD_IC); | 2989 spec->AddSlot(FeedbackVectorSlotKind::LOAD_IC); |
2985 iterator_call_feedback_slot_ = | 2990 iterator_call_feedback_slot_ = |
2986 spec->AddSlot(FeedbackVectorSlotKind::CALL_IC); | 2991 spec->AddSlot(FeedbackVectorSlotKind::CALL_IC); |
| 2992 |
| 2993 if (hint() == Hint::kAsync) { |
| 2994 // Can we just re-use the other slots? |
| 2995 async_iterator_property_feedback_slot_ = |
| 2996 spec->AddSlot(FeedbackVectorSlotKind::LOAD_IC); |
| 2997 async_iterator_call_feedback_slot_ = |
| 2998 spec->AddSlot(FeedbackVectorSlotKind::CALL_IC); |
| 2999 } |
2987 } | 3000 } |
2988 | 3001 |
2989 FeedbackVectorSlot IteratorPropertyFeedbackSlot() const { | 3002 FeedbackVectorSlot IteratorPropertyFeedbackSlot() const { |
2990 return iterator_property_feedback_slot_; | 3003 return iterator_property_feedback_slot_; |
2991 } | 3004 } |
2992 | 3005 |
2993 FeedbackVectorSlot IteratorCallFeedbackSlot() const { | 3006 FeedbackVectorSlot IteratorCallFeedbackSlot() const { |
2994 return iterator_call_feedback_slot_; | 3007 return iterator_call_feedback_slot_; |
2995 } | 3008 } |
2996 | 3009 |
| 3010 FeedbackVectorSlot AsyncIteratorPropertyFeedbackSlot() const { |
| 3011 return async_iterator_property_feedback_slot_; |
| 3012 } |
| 3013 |
| 3014 FeedbackVectorSlot AsyncIteratorCallFeedbackSlot() const { |
| 3015 return async_iterator_call_feedback_slot_; |
| 3016 } |
| 3017 |
2997 private: | 3018 private: |
2998 friend class AstNodeFactory; | 3019 friend class AstNodeFactory; |
2999 | 3020 |
3000 explicit GetIterator(Expression* iterable, int pos) | 3021 explicit GetIterator(Expression* iterable, Hint hint, int pos) |
3001 : Expression(pos, kGetIterator), iterable_(iterable) {} | 3022 : Expression(pos, kGetIterator), hint_(hint), iterable_(iterable) {} |
3002 | 3023 |
| 3024 Hint hint_; |
3003 Expression* iterable_; | 3025 Expression* iterable_; |
3004 FeedbackVectorSlot iterator_property_feedback_slot_; | 3026 FeedbackVectorSlot iterator_property_feedback_slot_; |
3005 FeedbackVectorSlot iterator_call_feedback_slot_; | 3027 FeedbackVectorSlot iterator_call_feedback_slot_; |
| 3028 FeedbackVectorSlot async_iterator_property_feedback_slot_; |
| 3029 FeedbackVectorSlot async_iterator_call_feedback_slot_; |
3006 }; | 3030 }; |
3007 | 3031 |
3008 // ---------------------------------------------------------------------------- | 3032 // ---------------------------------------------------------------------------- |
3009 // Basic visitor | 3033 // Basic visitor |
3010 // Sub-class should parametrize AstVisitor with itself, e.g.: | 3034 // Sub-class should parametrize AstVisitor with itself, e.g.: |
3011 // class SpecificVisitor : public AstVisitor<SpecificVisitor> { ... } | 3035 // class SpecificVisitor : public AstVisitor<SpecificVisitor> { ... } |
3012 | 3036 |
3013 template <class Subclass> | 3037 template <class Subclass> |
3014 class AstVisitor BASE_EMBEDDED { | 3038 class AstVisitor BASE_EMBEDDED { |
3015 public: | 3039 public: |
(...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3576 VariableProxy* this_function_var, | 3600 VariableProxy* this_function_var, |
3577 int pos) { | 3601 int pos) { |
3578 return new (zone_) | 3602 return new (zone_) |
3579 SuperCallReference(this_var, new_target_var, this_function_var, pos); | 3603 SuperCallReference(this_var, new_target_var, this_function_var, pos); |
3580 } | 3604 } |
3581 | 3605 |
3582 EmptyParentheses* NewEmptyParentheses(int pos) { | 3606 EmptyParentheses* NewEmptyParentheses(int pos) { |
3583 return new (zone_) EmptyParentheses(pos); | 3607 return new (zone_) EmptyParentheses(pos); |
3584 } | 3608 } |
3585 | 3609 |
3586 GetIterator* NewGetIterator(Expression* iterable, int pos) { | 3610 GetIterator* NewGetIterator(Expression* iterable, GetIterator::Hint hint, |
3587 return new (zone_) GetIterator(iterable, pos); | 3611 int pos) { |
| 3612 return new (zone_) GetIterator(iterable, hint, pos); |
3588 } | 3613 } |
3589 | 3614 |
3590 Zone* zone() const { return zone_; } | 3615 Zone* zone() const { return zone_; } |
3591 void set_zone(Zone* zone) { zone_ = zone; } | 3616 void set_zone(Zone* zone) { zone_ = zone; } |
3592 | 3617 |
3593 // Handles use of temporary zones when parsing inner function bodies. | 3618 // Handles use of temporary zones when parsing inner function bodies. |
3594 class BodyScope { | 3619 class BodyScope { |
3595 public: | 3620 public: |
3596 BodyScope(AstNodeFactory* factory, Zone* temp_zone, bool use_temp_zone) | 3621 BodyScope(AstNodeFactory* factory, Zone* temp_zone, bool use_temp_zone) |
3597 : factory_(factory), prev_zone_(factory->zone_) { | 3622 : factory_(factory), prev_zone_(factory->zone_) { |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3655 : NULL; \ | 3680 : NULL; \ |
3656 } | 3681 } |
3657 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) | 3682 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) |
3658 #undef DECLARE_NODE_FUNCTIONS | 3683 #undef DECLARE_NODE_FUNCTIONS |
3659 | 3684 |
3660 | 3685 |
3661 } // namespace internal | 3686 } // namespace internal |
3662 } // namespace v8 | 3687 } // namespace v8 |
3663 | 3688 |
3664 #endif // V8_AST_AST_H_ | 3689 #endif // V8_AST_AST_H_ |
OLD | NEW |