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

Unified Diff: src/parsing/parser.cc

Issue 2326963003: Remove multiple usages of a VariableProxy from async/await code (Closed)
Patch Set: Created 4 years, 3 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/parsing/parser.cc
diff --git a/src/parsing/parser.cc b/src/parsing/parser.cc
index 10a3983aceb0b3a35d6e87303ca7b76c93f4b2f4..c59cef7f435625b7b95e9ba2b61c4c367e49de25 100644
--- a/src/parsing/parser.cc
+++ b/src/parsing/parser.cc
@@ -4783,7 +4783,10 @@ Expression* Parser::ExpressionListToExpression(ZoneList<Expression*>* args) {
}
Expression* Parser::RewriteAwaitExpression(Expression* value, int await_pos) {
- // yield %AsyncFunctionAwait(.generator_object, <operand>)
+ // yield do {
+ // tmp = <operand>;
+ // tmp = %AsyncFunctionAwait(.generator_object, tmp);
+ // }
Variable* generator_object_variable =
function_state_->generator_object_variable();
@@ -4793,12 +4796,11 @@ Expression* Parser::RewriteAwaitExpression(Expression* value, int await_pos) {
const int nopos = kNoSourcePosition;
Variable* temp_var = NewTemporary(ast_value_factory()->empty_string());
- VariableProxy* temp_proxy = factory()->NewVariableProxy(temp_var);
Block* do_block = factory()->NewBlock(nullptr, 2, false, nopos);
// Wrap value evaluation to provide a break location.
- Expression* value_assignment =
- factory()->NewAssignment(Token::ASSIGN, temp_proxy, value, nopos);
+ Expression* value_assignment = factory()->NewAssignment(
+ Token::ASSIGN, factory()->NewVariableProxy(temp_var), value, nopos);
do_block->statements()->Add(
factory()->NewExpressionStatement(value_assignment, value->position()),
zone());
@@ -4808,12 +4810,14 @@ Expression* Parser::RewriteAwaitExpression(Expression* value, int await_pos) {
Expression* generator_object =
factory()->NewVariableProxy(generator_object_variable);
async_function_await_args->Add(generator_object, zone());
- async_function_await_args->Add(temp_proxy, zone());
+ async_function_await_args->Add(factory()->NewVariableProxy(temp_var), zone());
Expression* async_function_await = factory()->NewCallRuntime(
Context::ASYNC_FUNCTION_AWAIT_INDEX, async_function_await_args, nopos);
+
// Wrap await to provide a break location between value evaluation and yield.
Expression* await_assignment = factory()->NewAssignment(
- Token::ASSIGN, temp_proxy, async_function_await, nopos);
+ Token::ASSIGN, factory()->NewVariableProxy(temp_var),
+ async_function_await, nopos);
do_block->statements()->Add(
factory()->NewExpressionStatement(await_assignment, await_pos), zone());
Expression* do_expr = factory()->NewDoExpression(do_block, temp_var, nopos);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698