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