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

Unified Diff: src/ast/ast.h

Issue 1895603002: [esnext] prototype runtime implementation for async functions (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@AsyncFunction
Patch Set: Partially fix `throw` completions (resumption works, but no resumption doesn't) Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/bailout-reason.h » ('j') | src/builtins.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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) {
« no previous file with comments | « no previous file | src/bailout-reason.h » ('j') | src/builtins.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698