| Index: src/ast/ast.h
|
| diff --git a/src/ast/ast.h b/src/ast/ast.h
|
| index ec4b70192844c4a5d6d07ae0814e56f2744251f3..3789371a6bae8a17b2b071dfc0373783eb4f7d5b 100644
|
| --- a/src/ast/ast.h
|
| +++ b/src/ast/ast.h
|
| @@ -2538,19 +2538,25 @@ class Yield final : public Expression {
|
| void set_generator_object(Expression* e) { generator_object_ = e; }
|
| void set_expression(Expression* e) { expression_ = e; }
|
|
|
| + // AsyncFunction's first yield must suspend execution before starting, to
|
| + // prevent 'already executing' error. This avoids complexities of introducing
|
| + // an internal generator function.
|
| + bool is_async_function_start() const { return is_async_function_start_; }
|
| +
|
| protected:
|
| Yield(Zone* zone, Expression* generator_object, Expression* expression,
|
| - int pos)
|
| + bool is_async_function_start, int pos)
|
| : Expression(zone, pos),
|
| generator_object_(generator_object),
|
| - expression_(expression) {}
|
| + expression_(expression),
|
| + is_async_function_start_(is_async_function_start) {}
|
|
|
| private:
|
| Expression* generator_object_;
|
| Expression* expression_;
|
| + bool is_async_function_start_;
|
| };
|
|
|
| -
|
| class Throw final : public Expression {
|
| public:
|
| DECLARE_NODE_TYPE(Throw)
|
| @@ -3402,8 +3408,19 @@ class AstNodeFactory final BASE_EMBEDDED {
|
| Expression* expression,
|
| int pos) {
|
| if (!expression) expression = NewUndefinedLiteral(pos);
|
| - return new (local_zone_)
|
| - Yield(local_zone_, generator_object, expression, pos);
|
| + const bool is_async_function_start = false;
|
| + return new (local_zone_) Yield(local_zone_, generator_object, expression,
|
| + is_async_function_start, pos);
|
| + }
|
| +
|
| + Yield* NewAsyncFunctionStart(Expression* generator_object,
|
| + Expression* expression, int pos) {
|
| + DCHECK_NOT_NULL(expression);
|
| + // Starting an AsyncFunction emits a yield which suspends before evaluating
|
| + // operand.
|
| + const bool is_async_function_start = true;
|
| + return new (local_zone_) Yield(local_zone_, generator_object, expression,
|
| + is_async_function_start, pos);
|
| }
|
|
|
| Throw* NewThrow(Expression* exception, int pos) {
|
|
|