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

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 changes to ParserTarget / PreParserTarget Created 3 years, 11 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-generator.h » ('j') | src/parsing/parser.cc » ('J')
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 2955 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 IteratorType hint() const { return hint_; }
2980
2978 Expression* iterable() const { return iterable_; } 2981 Expression* iterable() const { return iterable_; }
2979 void set_iterable(Expression* iterable) { iterable_ = iterable; } 2982 void set_iterable(Expression* iterable) { iterable_ = iterable; }
2980 2983
2981 static int num_ids() { return parent_num_ids(); } 2984 static int num_ids() { return parent_num_ids(); }
2982 2985
2983 void AssignFeedbackVectorSlots(FeedbackVectorSpec* spec, 2986 void AssignFeedbackVectorSlots(FeedbackVectorSpec* spec,
2984 FeedbackVectorSlotCache* cache) { 2987 FeedbackVectorSlotCache* cache) {
2985 iterator_property_feedback_slot_ = 2988 iterator_property_feedback_slot_ =
2986 spec->AddSlot(FeedbackVectorSlotKind::LOAD_IC); 2989 spec->AddSlot(FeedbackVectorSlotKind::LOAD_IC);
2987 iterator_call_feedback_slot_ = 2990 iterator_call_feedback_slot_ =
2988 spec->AddSlot(FeedbackVectorSlotKind::CALL_IC); 2991 spec->AddSlot(FeedbackVectorSlotKind::CALL_IC);
2992
2993 if (hint() == IteratorType::kAsync) {
2994 // Can we just re-use the other slots?
2995 async_iterator_property_feedback_slot_ =
2996 spec->AddSlot(FeedbackVectorSlotKind::LOAD_IC);
2997 async_iterator_call_feedback_slot_ =
2998 spec->AddSlot(FeedbackVectorSlotKind::CALL_IC);
2999 }
2989 } 3000 }
2990 3001
2991 FeedbackVectorSlot IteratorPropertyFeedbackSlot() const { 3002 FeedbackVectorSlot IteratorPropertyFeedbackSlot() const {
2992 return iterator_property_feedback_slot_; 3003 return iterator_property_feedback_slot_;
2993 } 3004 }
2994 3005
2995 FeedbackVectorSlot IteratorCallFeedbackSlot() const { 3006 FeedbackVectorSlot IteratorCallFeedbackSlot() const {
2996 return iterator_call_feedback_slot_; 3007 return iterator_call_feedback_slot_;
2997 } 3008 }
2998 3009
3010 FeedbackVectorSlot AsyncIteratorPropertyFeedbackSlot() const {
3011 return async_iterator_property_feedback_slot_;
3012 }
3013
3014 FeedbackVectorSlot AsyncIteratorCallFeedbackSlot() const {
3015 return async_iterator_call_feedback_slot_;
3016 }
3017
2999 private: 3018 private:
3000 friend class AstNodeFactory; 3019 friend class AstNodeFactory;
3001 3020
3002 explicit GetIterator(Expression* iterable, int pos) 3021 explicit GetIterator(Expression* iterable, IteratorType hint, int pos)
3003 : Expression(pos, kGetIterator), iterable_(iterable) {} 3022 : Expression(pos, kGetIterator), hint_(hint), iterable_(iterable) {}
3004 3023
3024 IteratorType hint_;
3005 Expression* iterable_; 3025 Expression* iterable_;
3006 FeedbackVectorSlot iterator_property_feedback_slot_; 3026 FeedbackVectorSlot iterator_property_feedback_slot_;
3007 FeedbackVectorSlot iterator_call_feedback_slot_; 3027 FeedbackVectorSlot iterator_call_feedback_slot_;
3028 FeedbackVectorSlot async_iterator_property_feedback_slot_;
3029 FeedbackVectorSlot async_iterator_call_feedback_slot_;
3008 }; 3030 };
3009 3031
3010 // ---------------------------------------------------------------------------- 3032 // ----------------------------------------------------------------------------
3011 // Basic visitor 3033 // Basic visitor
3012 // Sub-class should parametrize AstVisitor with itself, e.g.: 3034 // Sub-class should parametrize AstVisitor with itself, e.g.:
3013 // class SpecificVisitor : public AstVisitor<SpecificVisitor> { ... } 3035 // class SpecificVisitor : public AstVisitor<SpecificVisitor> { ... }
3014 3036
3015 template <class Subclass> 3037 template <class Subclass>
3016 class AstVisitor BASE_EMBEDDED { 3038 class AstVisitor BASE_EMBEDDED {
3017 public: 3039 public:
(...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after
3577 VariableProxy* this_function_var, 3599 VariableProxy* this_function_var,
3578 int pos) { 3600 int pos) {
3579 return new (zone_) 3601 return new (zone_)
3580 SuperCallReference(this_var, new_target_var, this_function_var, pos); 3602 SuperCallReference(this_var, new_target_var, this_function_var, pos);
3581 } 3603 }
3582 3604
3583 EmptyParentheses* NewEmptyParentheses(int pos) { 3605 EmptyParentheses* NewEmptyParentheses(int pos) {
3584 return new (zone_) EmptyParentheses(pos); 3606 return new (zone_) EmptyParentheses(pos);
3585 } 3607 }
3586 3608
3587 GetIterator* NewGetIterator(Expression* iterable, int pos) { 3609 GetIterator* NewGetIterator(Expression* iterable, IteratorType hint,
3588 return new (zone_) GetIterator(iterable, pos); 3610 int pos) {
3611 return new (zone_) GetIterator(iterable, hint, pos);
3589 } 3612 }
3590 3613
3591 Zone* zone() const { return zone_; } 3614 Zone* zone() const { return zone_; }
3592 void set_zone(Zone* zone) { zone_ = zone; } 3615 void set_zone(Zone* zone) { zone_ = zone; }
3593 3616
3594 // Handles use of temporary zones when parsing inner function bodies. 3617 // Handles use of temporary zones when parsing inner function bodies.
3595 class BodyScope { 3618 class BodyScope {
3596 public: 3619 public:
3597 BodyScope(AstNodeFactory* factory, Zone* temp_zone, bool use_temp_zone) 3620 BodyScope(AstNodeFactory* factory, Zone* temp_zone, bool use_temp_zone)
3598 : factory_(factory), prev_zone_(factory->zone_) { 3621 : factory_(factory), prev_zone_(factory->zone_) {
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
3656 : NULL; \ 3679 : NULL; \
3657 } 3680 }
3658 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) 3681 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS)
3659 #undef DECLARE_NODE_FUNCTIONS 3682 #undef DECLARE_NODE_FUNCTIONS
3660 3683
3661 3684
3662 } // namespace internal 3685 } // namespace internal
3663 } // namespace v8 3686 } // namespace v8
3664 3687
3665 #endif // V8_AST_AST_H_ 3688 #endif // V8_AST_AST_H_
OLDNEW
« no previous file with comments | « no previous file | src/interpreter/bytecode-generator.h » ('j') | src/parsing/parser.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698