Chromium Code Reviews| 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 2949 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 class GetIterator final : public Expression { | 2968 class GetIterator final : public Expression { |
| 2969 public: | 2969 public: |
| 2970 enum Hint { kNormal, kAsync }; | |
|
neis
2017/01/20 14:38:15
Can you instead use the IteratorType enum that you
| |
| 2971 | |
| 2972 Hint hint() const { return hint_; } | |
| 2973 | |
| 2970 Expression* iterable() const { return iterable_; } | 2974 Expression* iterable() const { return iterable_; } |
| 2971 void set_iterable(Expression* iterable) { iterable_ = iterable; } | 2975 void set_iterable(Expression* iterable) { iterable_ = iterable; } |
| 2972 | 2976 |
| 2973 static int num_ids() { return parent_num_ids(); } | 2977 static int num_ids() { return parent_num_ids(); } |
| 2974 | 2978 |
| 2975 void AssignFeedbackVectorSlots(FeedbackVectorSpec* spec, | 2979 void AssignFeedbackVectorSlots(FeedbackVectorSpec* spec, |
| 2976 FeedbackVectorSlotCache* cache) { | 2980 FeedbackVectorSlotCache* cache) { |
| 2977 iterator_property_feedback_slot_ = | 2981 iterator_property_feedback_slot_ = |
| 2978 spec->AddSlot(FeedbackVectorSlotKind::LOAD_IC); | 2982 spec->AddSlot(FeedbackVectorSlotKind::LOAD_IC); |
| 2979 iterator_call_feedback_slot_ = | 2983 iterator_call_feedback_slot_ = |
| 2980 spec->AddSlot(FeedbackVectorSlotKind::CALL_IC); | 2984 spec->AddSlot(FeedbackVectorSlotKind::CALL_IC); |
| 2985 | |
| 2986 if (hint() == kAsync) { | |
| 2987 // Can we just re-use the other slots? | |
| 2988 async_iterator_property_feedback_slot_ = | |
| 2989 spec->AddSlot(FeedbackVectorSlotKind::LOAD_IC); | |
| 2990 async_iterator_call_feedback_slot_ = | |
| 2991 spec->AddSlot(FeedbackVectorSlotKind::CALL_IC); | |
| 2992 } | |
| 2981 } | 2993 } |
| 2982 | 2994 |
| 2983 FeedbackVectorSlot IteratorPropertyFeedbackSlot() const { | 2995 FeedbackVectorSlot IteratorPropertyFeedbackSlot() const { |
| 2984 return iterator_property_feedback_slot_; | 2996 return iterator_property_feedback_slot_; |
| 2985 } | 2997 } |
| 2986 | 2998 |
| 2987 FeedbackVectorSlot IteratorCallFeedbackSlot() const { | 2999 FeedbackVectorSlot IteratorCallFeedbackSlot() const { |
| 2988 return iterator_call_feedback_slot_; | 3000 return iterator_call_feedback_slot_; |
| 2989 } | 3001 } |
| 2990 | 3002 |
| 3003 FeedbackVectorSlot AsyncIteratorPropertyFeedbackSlot() const { | |
| 3004 return async_iterator_property_feedback_slot_; | |
| 3005 } | |
| 3006 | |
| 3007 FeedbackVectorSlot AsyncIteratorCallFeedbackSlot() const { | |
| 3008 return async_iterator_call_feedback_slot_; | |
| 3009 } | |
| 3010 | |
| 2991 private: | 3011 private: |
| 2992 friend class AstNodeFactory; | 3012 friend class AstNodeFactory; |
| 2993 | 3013 |
| 2994 explicit GetIterator(Expression* iterable, int pos) | 3014 explicit GetIterator(Expression* iterable, Hint hint, int pos) |
| 2995 : Expression(pos, kGetIterator), iterable_(iterable) {} | 3015 : Expression(pos, kGetIterator), hint_(hint), iterable_(iterable) {} |
| 2996 | 3016 |
| 3017 Hint hint_; | |
| 2997 Expression* iterable_; | 3018 Expression* iterable_; |
| 2998 FeedbackVectorSlot iterator_property_feedback_slot_; | 3019 FeedbackVectorSlot iterator_property_feedback_slot_; |
| 2999 FeedbackVectorSlot iterator_call_feedback_slot_; | 3020 FeedbackVectorSlot iterator_call_feedback_slot_; |
| 3021 FeedbackVectorSlot async_iterator_property_feedback_slot_; | |
| 3022 FeedbackVectorSlot async_iterator_call_feedback_slot_; | |
| 3000 }; | 3023 }; |
| 3001 | 3024 |
| 3002 // ---------------------------------------------------------------------------- | 3025 // ---------------------------------------------------------------------------- |
| 3003 // Basic visitor | 3026 // Basic visitor |
| 3004 // Sub-class should parametrize AstVisitor with itself, e.g.: | 3027 // Sub-class should parametrize AstVisitor with itself, e.g.: |
| 3005 // class SpecificVisitor : public AstVisitor<SpecificVisitor> { ... } | 3028 // class SpecificVisitor : public AstVisitor<SpecificVisitor> { ... } |
| 3006 | 3029 |
| 3007 template <class Subclass> | 3030 template <class Subclass> |
| 3008 class AstVisitor BASE_EMBEDDED { | 3031 class AstVisitor BASE_EMBEDDED { |
| 3009 public: | 3032 public: |
| (...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3569 VariableProxy* this_function_var, | 3592 VariableProxy* this_function_var, |
| 3570 int pos) { | 3593 int pos) { |
| 3571 return new (zone_) | 3594 return new (zone_) |
| 3572 SuperCallReference(this_var, new_target_var, this_function_var, pos); | 3595 SuperCallReference(this_var, new_target_var, this_function_var, pos); |
| 3573 } | 3596 } |
| 3574 | 3597 |
| 3575 EmptyParentheses* NewEmptyParentheses(int pos) { | 3598 EmptyParentheses* NewEmptyParentheses(int pos) { |
| 3576 return new (zone_) EmptyParentheses(pos); | 3599 return new (zone_) EmptyParentheses(pos); |
| 3577 } | 3600 } |
| 3578 | 3601 |
| 3579 GetIterator* NewGetIterator(Expression* iterable, int pos) { | 3602 GetIterator* NewGetIterator(Expression* iterable, GetIterator::Hint hint, |
| 3580 return new (zone_) GetIterator(iterable, pos); | 3603 int pos) { |
| 3604 return new (zone_) GetIterator(iterable, hint, pos); | |
| 3581 } | 3605 } |
| 3582 | 3606 |
| 3583 Zone* zone() const { return zone_; } | 3607 Zone* zone() const { return zone_; } |
| 3584 void set_zone(Zone* zone) { zone_ = zone; } | 3608 void set_zone(Zone* zone) { zone_ = zone; } |
| 3585 | 3609 |
| 3586 // Handles use of temporary zones when parsing inner function bodies. | 3610 // Handles use of temporary zones when parsing inner function bodies. |
| 3587 class BodyScope { | 3611 class BodyScope { |
| 3588 public: | 3612 public: |
| 3589 BodyScope(AstNodeFactory* factory, Zone* temp_zone, bool use_temp_zone) | 3613 BodyScope(AstNodeFactory* factory, Zone* temp_zone, bool use_temp_zone) |
| 3590 : factory_(factory), prev_zone_(factory->zone_) { | 3614 : factory_(factory), prev_zone_(factory->zone_) { |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3648 : NULL; \ | 3672 : NULL; \ |
| 3649 } | 3673 } |
| 3650 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) | 3674 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) |
| 3651 #undef DECLARE_NODE_FUNCTIONS | 3675 #undef DECLARE_NODE_FUNCTIONS |
| 3652 | 3676 |
| 3653 | 3677 |
| 3654 } // namespace internal | 3678 } // namespace internal |
| 3655 } // namespace v8 | 3679 } // namespace v8 |
| 3656 | 3680 |
| 3657 #endif // V8_AST_AST_H_ | 3681 #endif // V8_AST_AST_H_ |
| OLD | NEW |