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