diff options
author | Michaël Zasso <targos@protonmail.com> | 2017-03-21 16:16:48 +0100 |
---|---|---|
committer | Michaël Zasso <targos@protonmail.com> | 2017-03-25 09:44:11 +0100 |
commit | 07088e6fc1342b5581d9e6f7ce084308573e3139 (patch) | |
tree | 05df5e41276c73c3f3392e1aa0bce02084866d2b /deps/v8/src/ast/ast.h | |
parent | 8394b05e20d3b661bb36cf778cd1f8c323334d7d (diff) | |
download | node-new-07088e6fc1342b5581d9e6f7ce084308573e3139.tar.gz |
deps: backport 39642fa from upstream V8
This is an almost clean cherry-pick of the original commit. The only
conflict was related to a rename of an internal class.
Original commit message:
[async-await] (simpler) fix for Return in try/finally in async functions
Alternative approach to https://codereview.chromium.org/2667983004/, which
does not depend on implicit control flow changes from
https://codereview.chromium.org/2664083002
- Remove handling for `async function` from Parser::RewriteReturn(). This functionality
is moved to BytecodeGenerator::BuildAsyncReturn(). This ensures that promise resolution
is deferred until all finally blocks are evaluated fully.
- Add a new deferred command (CMD_ASYNC_RETURN), which instructs ControlScope to
generate return code using BuildAsyncReturn rather than BuildReturn.
- Parser has a new `NewReturnStatement()` helper which determines what type of return
statement to generate based on the type of function.
BUG=v8:5896, v8:4483
R=littledan@chromium.org, neis@chromium.org, rmcilroy@chromium.org, adamk@chromium.org, gsathya@chromium.org
Review-Url: https://codereview.chromium.org/2685683002
Cr-Commit-Position: refs/heads/master@{#43104}
Fixes: https://github.com/nodejs/node/issues/11960
PR-URL: https://github.com/nodejs/node/pull/11752
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
Diffstat (limited to 'deps/v8/src/ast/ast.h')
-rw-r--r-- | deps/v8/src/ast/ast.h | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/deps/v8/src/ast/ast.h b/deps/v8/src/ast/ast.h index af561e0a3f..0cf20b0e4c 100644 --- a/deps/v8/src/ast/ast.h +++ b/deps/v8/src/ast/ast.h @@ -895,17 +895,25 @@ class BreakStatement final : public JumpStatement { class ReturnStatement final : public JumpStatement { public: + enum Type { kNormal, kAsyncReturn }; Expression* expression() const { return expression_; } void set_expression(Expression* e) { expression_ = e; } + Type type() const { return TypeField::decode(bit_field_); } + bool is_async_return() const { return type() == kAsyncReturn; } private: friend class AstNodeFactory; - ReturnStatement(Expression* expression, int pos) - : JumpStatement(pos, kReturnStatement), expression_(expression) {} + ReturnStatement(Expression* expression, Type type, int pos) + : JumpStatement(pos, kReturnStatement), expression_(expression) { + bit_field_ |= TypeField::encode(type); + } Expression* expression_; + + class TypeField + : public BitField<Type, JumpStatement::kNextBitFieldIndex, 1> {}; }; @@ -3217,7 +3225,13 @@ class AstNodeFactory final BASE_EMBEDDED { } ReturnStatement* NewReturnStatement(Expression* expression, int pos) { - return new (zone_) ReturnStatement(expression, pos); + return new (zone_) + ReturnStatement(expression, ReturnStatement::kNormal, pos); + } + + ReturnStatement* NewAsyncReturnStatement(Expression* expression, int pos) { + return new (zone_) + ReturnStatement(expression, ReturnStatement::kAsyncReturn, pos); } WithStatement* NewWithStatement(Scope* scope, |