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

Side by Side Diff: src/parsing/parser.cc

Issue 2317383002: Async/await Promise dependency graph (Closed)
Patch Set: Remove irrelevant whitespace change 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 unified diff | Download patch
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 #include "src/parsing/parser.h" 5 #include "src/parsing/parser.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "src/api.h" 9 #include "src/api.h"
10 #include "src/ast/ast-expression-rewriter.h" 10 #include "src/ast/ast-expression-rewriter.h"
(...skipping 4533 matching lines...) Expand 10 before | Expand all | Expand 10 after
4544 expr = factory()->NewBinaryOperation(Token::COMMA, expr, args->at(i), 4544 expr = factory()->NewBinaryOperation(Token::COMMA, expr, args->at(i),
4545 expr->position()); 4545 expr->position());
4546 } 4546 }
4547 return expr; 4547 return expr;
4548 } 4548 }
4549 4549
4550 Expression* Parser::RewriteAwaitExpression(Expression* value, int await_pos) { 4550 Expression* Parser::RewriteAwaitExpression(Expression* value, int await_pos) {
4551 // yield do { 4551 // yield do {
4552 // promise_tmp = .promise; 4552 // promise_tmp = .promise;
4553 // tmp = <operand>; 4553 // tmp = <operand>;
4554 // %AsyncFunctionAwait(.generator_object, tmp); 4554 // %AsyncFunctionAwait(.generator_object, tmp, promise_tmp);
4555 // promise_tmp 4555 // promise_tmp
4556 // } 4556 // }
4557 // The value of the expression is returned to the caller of the async 4557 // The value of the expression is returned to the caller of the async
4558 // function for the first yield statement; for this, .promise is the 4558 // function for the first yield statement; for this, .promise is the
4559 // appropriate return value, being a Promise that will be fulfilled or 4559 // appropriate return value, being a Promise that will be fulfilled or
4560 // rejected with the appropriate value by the desugaring. Subsequent yield 4560 // rejected with the appropriate value by the desugaring. Subsequent yield
4561 // occurrences will return to the AsyncFunctionNext call within the 4561 // occurrences will return to the AsyncFunctionNext call within the
4562 // implemementation of the intermediate throwaway Promise's then handler. 4562 // implemementation of the intermediate throwaway Promise's then handler.
4563 // This handler has nothing useful to do with the value, as the Promise is 4563 // This handler has nothing useful to do with the value, as the Promise is
4564 // ignored. If we yielded the value of the throwawayPromise that 4564 // ignored. If we yielded the value of the throwawayPromise that
(...skipping 24 matching lines...) Expand all
4589 4589
4590 // Wrap value evaluation to provide a break location. 4590 // Wrap value evaluation to provide a break location.
4591 Variable* temp_var = NewTemporary(ast_value_factory()->empty_string()); 4591 Variable* temp_var = NewTemporary(ast_value_factory()->empty_string());
4592 Expression* value_assignment = factory()->NewAssignment( 4592 Expression* value_assignment = factory()->NewAssignment(
4593 Token::ASSIGN, factory()->NewVariableProxy(temp_var), value, nopos); 4593 Token::ASSIGN, factory()->NewVariableProxy(temp_var), value, nopos);
4594 do_block->statements()->Add( 4594 do_block->statements()->Add(
4595 factory()->NewExpressionStatement(value_assignment, value->position()), 4595 factory()->NewExpressionStatement(value_assignment, value->position()),
4596 zone()); 4596 zone());
4597 4597
4598 ZoneList<Expression*>* async_function_await_args = 4598 ZoneList<Expression*>* async_function_await_args =
4599 new (zone()) ZoneList<Expression*>(2, zone()); 4599 new (zone()) ZoneList<Expression*>(3, zone());
4600 Expression* generator_object = 4600 Expression* generator_object =
4601 factory()->NewVariableProxy(generator_object_variable); 4601 factory()->NewVariableProxy(generator_object_variable);
4602 async_function_await_args->Add(generator_object, zone()); 4602 async_function_await_args->Add(generator_object, zone());
4603 async_function_await_args->Add(factory()->NewVariableProxy(temp_var), zone()); 4603 async_function_await_args->Add(factory()->NewVariableProxy(temp_var), zone());
4604 async_function_await_args->Add(factory()->NewVariableProxy(promise_temp_var),
4605 zone());
4604 4606
4605 // The parser emits calls to AsyncFunctionAwaitCaught, but the 4607 // The parser emits calls to AsyncFunctionAwaitCaught, but the
4606 // AstNumberingVisitor will rewrite this to AsyncFunctionAwaitUncaught 4608 // AstNumberingVisitor will rewrite this to AsyncFunctionAwaitUncaught
4607 // if there is no local enclosing try/catch block. 4609 // if there is no local enclosing try/catch block.
4608 Expression* async_function_await = 4610 Expression* async_function_await =
4609 factory()->NewCallRuntime(Context::ASYNC_FUNCTION_AWAIT_CAUGHT_INDEX, 4611 factory()->NewCallRuntime(Context::ASYNC_FUNCTION_AWAIT_CAUGHT_INDEX,
4610 async_function_await_args, nopos); 4612 async_function_await_args, nopos);
4611 do_block->statements()->Add( 4613 do_block->statements()->Add(
4612 factory()->NewExpressionStatement(async_function_await, await_pos), 4614 factory()->NewExpressionStatement(async_function_await, await_pos),
4613 zone()); 4615 zone());
(...skipping 1207 matching lines...) Expand 10 before | Expand all | Expand 10 after
5821 node->Print(Isolate::Current()); 5823 node->Print(Isolate::Current());
5822 } 5824 }
5823 #endif // DEBUG 5825 #endif // DEBUG
5824 5826
5825 #undef CHECK_OK 5827 #undef CHECK_OK
5826 #undef CHECK_OK_VOID 5828 #undef CHECK_OK_VOID
5827 #undef CHECK_FAILED 5829 #undef CHECK_FAILED
5828 5830
5829 } // namespace internal 5831 } // namespace internal
5830 } // namespace v8 5832 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698