Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(60)

Side by Side Diff: src/ast/ast.h

Issue 2637403008: [async-iteration] add support for for-await-of loops in Async Functions (Closed)
Patch Set: remove that comment Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/interpreter/bytecode-array-builder.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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_; }
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 async_iterator_property_feedback_slot_ = spec->AddLoadICSlot();
2980 async_iterator_call_feedback_slot_ = spec->AddCallICSlot();
2981 }
2975 } 2982 }
2976 2983
2977 FeedbackSlot IteratorPropertyFeedbackSlot() const { 2984 FeedbackSlot IteratorPropertyFeedbackSlot() const {
2978 return iterator_property_feedback_slot_; 2985 return iterator_property_feedback_slot_;
2979 } 2986 }
2980 2987
2981 FeedbackSlot IteratorCallFeedbackSlot() const { 2988 FeedbackSlot IteratorCallFeedbackSlot() const {
2982 return iterator_call_feedback_slot_; 2989 return iterator_call_feedback_slot_;
2983 } 2990 }
2984 2991
2992 FeedbackSlot AsyncIteratorPropertyFeedbackSlot() const {
2993 return async_iterator_property_feedback_slot_;
2994 }
2995
2996 FeedbackSlot AsyncIteratorCallFeedbackSlot() const {
2997 return async_iterator_call_feedback_slot_;
2998 }
2999
2985 private: 3000 private:
2986 friend class AstNodeFactory; 3001 friend class AstNodeFactory;
2987 3002
2988 explicit GetIterator(Expression* iterable, int pos) 3003 explicit GetIterator(Expression* iterable, IteratorType hint, int pos)
2989 : Expression(pos, kGetIterator), iterable_(iterable) {} 3004 : Expression(pos, kGetIterator), hint_(hint), iterable_(iterable) {}
2990 3005
3006 IteratorType hint_;
2991 Expression* iterable_; 3007 Expression* iterable_;
2992 FeedbackSlot iterator_property_feedback_slot_; 3008 FeedbackSlot iterator_property_feedback_slot_;
2993 FeedbackSlot iterator_call_feedback_slot_; 3009 FeedbackSlot iterator_call_feedback_slot_;
3010 FeedbackSlot async_iterator_property_feedback_slot_;
3011 FeedbackSlot async_iterator_call_feedback_slot_;
2994 }; 3012 };
2995 3013
2996 // ---------------------------------------------------------------------------- 3014 // ----------------------------------------------------------------------------
2997 // Basic visitor 3015 // Basic visitor
2998 // Sub-class should parametrize AstVisitor with itself, e.g.: 3016 // Sub-class should parametrize AstVisitor with itself, e.g.:
2999 // class SpecificVisitor : public AstVisitor<SpecificVisitor> { ... } 3017 // class SpecificVisitor : public AstVisitor<SpecificVisitor> { ... }
3000 3018
3001 template <class Subclass> 3019 template <class Subclass>
3002 class AstVisitor BASE_EMBEDDED { 3020 class AstVisitor BASE_EMBEDDED {
3003 public: 3021 public:
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
3199 return new (zone_) ForInStatement(labels, pos); 3217 return new (zone_) ForInStatement(labels, pos);
3200 } 3218 }
3201 case ForEachStatement::ITERATE: { 3219 case ForEachStatement::ITERATE: {
3202 return new (zone_) ForOfStatement(labels, pos); 3220 return new (zone_) ForOfStatement(labels, pos);
3203 } 3221 }
3204 } 3222 }
3205 UNREACHABLE(); 3223 UNREACHABLE();
3206 return NULL; 3224 return NULL;
3207 } 3225 }
3208 3226
3227 ForOfStatement* NewForOfStatement(ZoneList<const AstRawString*>* labels,
3228 int pos) {
3229 return new (zone_) ForOfStatement(labels, pos);
3230 }
3231
3209 ExpressionStatement* NewExpressionStatement(Expression* expression, int pos) { 3232 ExpressionStatement* NewExpressionStatement(Expression* expression, int pos) {
3210 return new (zone_) ExpressionStatement(expression, pos); 3233 return new (zone_) ExpressionStatement(expression, pos);
3211 } 3234 }
3212 3235
3213 ContinueStatement* NewContinueStatement(IterationStatement* target, int pos) { 3236 ContinueStatement* NewContinueStatement(IterationStatement* target, int pos) {
3214 return new (zone_) ContinueStatement(target, pos); 3237 return new (zone_) ContinueStatement(target, pos);
3215 } 3238 }
3216 3239
3217 BreakStatement* NewBreakStatement(BreakableStatement* target, int pos) { 3240 BreakStatement* NewBreakStatement(BreakableStatement* target, int pos) {
3218 return new (zone_) BreakStatement(target, pos); 3241 return new (zone_) BreakStatement(target, pos);
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
3565 VariableProxy* this_function_var, 3588 VariableProxy* this_function_var,
3566 int pos) { 3589 int pos) {
3567 return new (zone_) 3590 return new (zone_)
3568 SuperCallReference(this_var, new_target_var, this_function_var, pos); 3591 SuperCallReference(this_var, new_target_var, this_function_var, pos);
3569 } 3592 }
3570 3593
3571 EmptyParentheses* NewEmptyParentheses(int pos) { 3594 EmptyParentheses* NewEmptyParentheses(int pos) {
3572 return new (zone_) EmptyParentheses(pos); 3595 return new (zone_) EmptyParentheses(pos);
3573 } 3596 }
3574 3597
3575 GetIterator* NewGetIterator(Expression* iterable, int pos) { 3598 GetIterator* NewGetIterator(Expression* iterable, IteratorType hint,
3576 return new (zone_) GetIterator(iterable, pos); 3599 int pos) {
3600 return new (zone_) GetIterator(iterable, hint, pos);
3577 } 3601 }
3578 3602
3579 Zone* zone() const { return zone_; } 3603 Zone* zone() const { return zone_; }
3580 void set_zone(Zone* zone) { zone_ = zone; } 3604 void set_zone(Zone* zone) { zone_ = zone; }
3581 3605
3582 // Handles use of temporary zones when parsing inner function bodies. 3606 // Handles use of temporary zones when parsing inner function bodies.
3583 class BodyScope { 3607 class BodyScope {
3584 public: 3608 public:
3585 BodyScope(AstNodeFactory* factory, Zone* temp_zone, bool use_temp_zone) 3609 BodyScope(AstNodeFactory* factory, Zone* temp_zone, bool use_temp_zone)
3586 : factory_(factory), prev_zone_(factory->zone_) { 3610 : factory_(factory), prev_zone_(factory->zone_) {
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
3644 : NULL; \ 3668 : NULL; \
3645 } 3669 }
3646 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) 3670 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS)
3647 #undef DECLARE_NODE_FUNCTIONS 3671 #undef DECLARE_NODE_FUNCTIONS
3648 3672
3649 3673
3650 } // namespace internal 3674 } // namespace internal
3651 } // namespace v8 3675 } // namespace v8
3652 3676
3653 #endif // V8_AST_AST_H_ 3677 #endif // V8_AST_AST_H_
OLDNEW
« no previous file with comments | « no previous file | src/interpreter/bytecode-array-builder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698