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/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 2943 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2954 private: | 2954 private: |
| 2955 friend class AstNodeFactory; | 2955 friend class AstNodeFactory; |
| 2956 | 2956 |
| 2957 explicit EmptyParentheses(int pos) : Expression(pos, kEmptyParentheses) {} | 2957 explicit EmptyParentheses(int pos) : Expression(pos, kEmptyParentheses) {} |
| 2958 }; | 2958 }; |
| 2959 | 2959 |
| 2960 // Represents the spec operation `GetIterator()` | 2960 // Represents the spec operation `GetIterator()` |
| 2961 // (defined at https://tc39.github.io/ecma262/#sec-getiterator). Ignition | 2961 // (defined at https://tc39.github.io/ecma262/#sec-getiterator). Ignition |
| 2962 // desugars this into a LoadIC / JSLoadNamed, CallIC, and a type-check to | 2962 // desugars this into a LoadIC / JSLoadNamed, CallIC, and a type-check to |
| 2963 // validate return value of the Symbol.iterator() call. | 2963 // validate return value of the Symbol.iterator() call. |
| 2964 enum class IteratorType { kNormal, kAsync }; | |
| 2964 class GetIterator final : public Expression { | 2965 class GetIterator final : public Expression { |
| 2965 public: | 2966 public: |
| 2967 IteratorType hint() const { return hint_; } | |
|
adamk
2017/02/14 18:47:53
Naming nit: why not "type" instead of "hint"?
Dan Ehrenberg
2017/02/14 20:56:18
This is the spec's name, see https://tc39.github.i
| |
| 2968 | |
| 2966 Expression* iterable() const { return iterable_; } | 2969 Expression* iterable() const { return iterable_; } |
| 2967 void set_iterable(Expression* iterable) { iterable_ = iterable; } | 2970 void set_iterable(Expression* iterable) { iterable_ = iterable; } |
| 2968 | 2971 |
| 2969 static int num_ids() { return parent_num_ids(); } | 2972 static int num_ids() { return parent_num_ids(); } |
| 2970 | 2973 |
| 2971 void AssignFeedbackSlots(FeedbackVectorSpec* spec, LanguageMode language_mode, | 2974 void AssignFeedbackSlots(FeedbackVectorSpec* spec, LanguageMode language_mode, |
| 2972 FeedbackSlotCache* cache) { | 2975 FeedbackSlotCache* cache) { |
| 2973 iterator_property_feedback_slot_ = spec->AddLoadICSlot(); | 2976 iterator_property_feedback_slot_ = spec->AddLoadICSlot(); |
| 2974 iterator_call_feedback_slot_ = spec->AddCallICSlot(); | 2977 iterator_call_feedback_slot_ = spec->AddCallICSlot(); |
| 2978 if (hint() == IteratorType::kAsync) { | |
| 2979 // Can we just re-use the other slots? | |
|
adamk
2017/02/14 18:47:53
Looks like the answer to this is no? My read of th
caitp
2017/02/15 19:00:18
Done
| |
| 2980 async_iterator_property_feedback_slot_ = spec->AddLoadICSlot(); | |
| 2981 async_iterator_call_feedback_slot_ = spec->AddCallICSlot(); | |
| 2982 } | |
| 2975 } | 2983 } |
| 2976 | 2984 |
| 2977 FeedbackSlot IteratorPropertyFeedbackSlot() const { | 2985 FeedbackSlot IteratorPropertyFeedbackSlot() const { |
| 2978 return iterator_property_feedback_slot_; | 2986 return iterator_property_feedback_slot_; |
| 2979 } | 2987 } |
| 2980 | 2988 |
| 2981 FeedbackSlot IteratorCallFeedbackSlot() const { | 2989 FeedbackSlot IteratorCallFeedbackSlot() const { |
| 2982 return iterator_call_feedback_slot_; | 2990 return iterator_call_feedback_slot_; |
| 2983 } | 2991 } |
| 2984 | 2992 |
| 2993 FeedbackSlot AsyncIteratorPropertyFeedbackSlot() const { | |
| 2994 return async_iterator_property_feedback_slot_; | |
| 2995 } | |
| 2996 | |
| 2997 FeedbackSlot AsyncIteratorCallFeedbackSlot() const { | |
| 2998 return async_iterator_call_feedback_slot_; | |
| 2999 } | |
| 3000 | |
| 2985 private: | 3001 private: |
| 2986 friend class AstNodeFactory; | 3002 friend class AstNodeFactory; |
| 2987 | 3003 |
| 2988 explicit GetIterator(Expression* iterable, int pos) | 3004 explicit GetIterator(Expression* iterable, IteratorType hint, int pos) |
| 2989 : Expression(pos, kGetIterator), iterable_(iterable) {} | 3005 : Expression(pos, kGetIterator), hint_(hint), iterable_(iterable) {} |
| 2990 | 3006 |
| 3007 IteratorType hint_; | |
| 2991 Expression* iterable_; | 3008 Expression* iterable_; |
| 2992 FeedbackSlot iterator_property_feedback_slot_; | 3009 FeedbackSlot iterator_property_feedback_slot_; |
| 2993 FeedbackSlot iterator_call_feedback_slot_; | 3010 FeedbackSlot iterator_call_feedback_slot_; |
| 3011 FeedbackSlot async_iterator_property_feedback_slot_; | |
| 3012 FeedbackSlot async_iterator_call_feedback_slot_; | |
| 2994 }; | 3013 }; |
| 2995 | 3014 |
| 2996 // ---------------------------------------------------------------------------- | 3015 // ---------------------------------------------------------------------------- |
| 2997 // Basic visitor | 3016 // Basic visitor |
| 2998 // Sub-class should parametrize AstVisitor with itself, e.g.: | 3017 // Sub-class should parametrize AstVisitor with itself, e.g.: |
| 2999 // class SpecificVisitor : public AstVisitor<SpecificVisitor> { ... } | 3018 // class SpecificVisitor : public AstVisitor<SpecificVisitor> { ... } |
| 3000 | 3019 |
| 3001 template <class Subclass> | 3020 template <class Subclass> |
| 3002 class AstVisitor BASE_EMBEDDED { | 3021 class AstVisitor BASE_EMBEDDED { |
| 3003 public: | 3022 public: |
| (...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3565 VariableProxy* this_function_var, | 3584 VariableProxy* this_function_var, |
| 3566 int pos) { | 3585 int pos) { |
| 3567 return new (zone_) | 3586 return new (zone_) |
| 3568 SuperCallReference(this_var, new_target_var, this_function_var, pos); | 3587 SuperCallReference(this_var, new_target_var, this_function_var, pos); |
| 3569 } | 3588 } |
| 3570 | 3589 |
| 3571 EmptyParentheses* NewEmptyParentheses(int pos) { | 3590 EmptyParentheses* NewEmptyParentheses(int pos) { |
| 3572 return new (zone_) EmptyParentheses(pos); | 3591 return new (zone_) EmptyParentheses(pos); |
| 3573 } | 3592 } |
| 3574 | 3593 |
| 3575 GetIterator* NewGetIterator(Expression* iterable, int pos) { | 3594 GetIterator* NewGetIterator(Expression* iterable, IteratorType hint, |
| 3576 return new (zone_) GetIterator(iterable, pos); | 3595 int pos) { |
| 3596 return new (zone_) GetIterator(iterable, hint, pos); | |
| 3577 } | 3597 } |
| 3578 | 3598 |
| 3579 Zone* zone() const { return zone_; } | 3599 Zone* zone() const { return zone_; } |
| 3580 void set_zone(Zone* zone) { zone_ = zone; } | 3600 void set_zone(Zone* zone) { zone_ = zone; } |
| 3581 | 3601 |
| 3582 // Handles use of temporary zones when parsing inner function bodies. | 3602 // Handles use of temporary zones when parsing inner function bodies. |
| 3583 class BodyScope { | 3603 class BodyScope { |
| 3584 public: | 3604 public: |
| 3585 BodyScope(AstNodeFactory* factory, Zone* temp_zone, bool use_temp_zone) | 3605 BodyScope(AstNodeFactory* factory, Zone* temp_zone, bool use_temp_zone) |
| 3586 : factory_(factory), prev_zone_(factory->zone_) { | 3606 : factory_(factory), prev_zone_(factory->zone_) { |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3644 : NULL; \ | 3664 : NULL; \ |
| 3645 } | 3665 } |
| 3646 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) | 3666 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) |
| 3647 #undef DECLARE_NODE_FUNCTIONS | 3667 #undef DECLARE_NODE_FUNCTIONS |
| 3648 | 3668 |
| 3649 | 3669 |
| 3650 } // namespace internal | 3670 } // namespace internal |
| 3651 } // namespace v8 | 3671 } // namespace v8 |
| 3652 | 3672 |
| 3653 #endif // V8_AST_AST_H_ | 3673 #endif // V8_AST_AST_H_ |
| OLD | NEW |