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

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

Issue 2276243002: Mark await expressions as caught or uncaught (Closed)
Patch Set: rebase 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
« src/js/promise.js ('K') | « src/objects.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 3807 matching lines...) Expand 10 before | Expand all | Expand 10 after
3818 catch_scope->DeclareLocal(ast_value_factory()->dot_catch_string(), VAR, 3818 catch_scope->DeclareLocal(ast_value_factory()->dot_catch_string(), VAR,
3819 kCreatedInitialized, NORMAL_VARIABLE); 3819 kCreatedInitialized, NORMAL_VARIABLE);
3820 Block* catch_block = factory()->NewBlock(nullptr, 1, true, kNoSourcePosition); 3820 Block* catch_block = factory()->NewBlock(nullptr, 1, true, kNoSourcePosition);
3821 3821
3822 Expression* promise_reject = BuildRejectPromise( 3822 Expression* promise_reject = BuildRejectPromise(
3823 factory()->NewVariableProxy(catch_variable), kNoSourcePosition); 3823 factory()->NewVariableProxy(catch_variable), kNoSourcePosition);
3824 ReturnStatement* return_promise_reject = 3824 ReturnStatement* return_promise_reject =
3825 factory()->NewReturnStatement(promise_reject, kNoSourcePosition); 3825 factory()->NewReturnStatement(promise_reject, kNoSourcePosition);
3826 catch_block->statements()->Add(return_promise_reject, zone()); 3826 catch_block->statements()->Add(return_promise_reject, zone());
3827 3827
3828 TryStatement* try_catch_statement = factory()->NewTryCatchStatement( 3828 TryStatement* try_catch_statement =
3829 inner_block, catch_scope, catch_variable, catch_block, kNoSourcePosition); 3829 factory()->NewTryCatchStatementForAsyncAwait(inner_block, catch_scope,
3830 catch_variable, catch_block,
3831 kNoSourcePosition);
3830 3832
3831 // There is no TryCatchFinally node, so wrap it in an outer try/finally 3833 // There is no TryCatchFinally node, so wrap it in an outer try/finally
3832 Block* outer_try_block = 3834 Block* outer_try_block =
3833 factory()->NewBlock(nullptr, 1, true, kNoSourcePosition); 3835 factory()->NewBlock(nullptr, 1, true, kNoSourcePosition);
3834 outer_try_block->statements()->Add(try_catch_statement, zone()); 3836 outer_try_block->statements()->Add(try_catch_statement, zone());
3835 3837
3836 // finally { if (.debug_is_active) %DebugPopPromise(); } 3838 // finally { if (.debug_is_active) %DebugPopPromise(); }
3837 Block* finally_block = 3839 Block* finally_block =
3838 factory()->NewBlock(nullptr, 1, true, kNoSourcePosition); 3840 factory()->NewBlock(nullptr, 1, true, kNoSourcePosition);
3839 { 3841 {
(...skipping 915 matching lines...) Expand 10 before | Expand all | Expand 10 after
4755 do_block->statements()->Add( 4757 do_block->statements()->Add(
4756 factory()->NewExpressionStatement(value_assignment, value->position()), 4758 factory()->NewExpressionStatement(value_assignment, value->position()),
4757 zone()); 4759 zone());
4758 4760
4759 ZoneList<Expression*>* async_function_await_args = 4761 ZoneList<Expression*>* async_function_await_args =
4760 new (zone()) ZoneList<Expression*>(2, zone()); 4762 new (zone()) ZoneList<Expression*>(2, zone());
4761 Expression* generator_object = 4763 Expression* generator_object =
4762 factory()->NewVariableProxy(generator_object_variable); 4764 factory()->NewVariableProxy(generator_object_variable);
4763 async_function_await_args->Add(generator_object, zone()); 4765 async_function_await_args->Add(generator_object, zone());
4764 async_function_await_args->Add(factory()->NewVariableProxy(temp_var), zone()); 4766 async_function_await_args->Add(factory()->NewVariableProxy(temp_var), zone());
4765 Expression* async_function_await = factory()->NewCallRuntime( 4767
4766 Context::ASYNC_FUNCTION_AWAIT_INDEX, async_function_await_args, nopos); 4768 // The parser emits calls to AsyncFunctionAwaitCaught, but the
4769 // AstNumberingVisitor will rewrite this to AsyncFunctionAwaitUncaught
4770 // if there is no local enclosing try/catch block.
4771 Expression* async_function_await =
4772 factory()->NewCallRuntime(Context::ASYNC_FUNCTION_AWAIT_CAUGHT_INDEX,
4773 async_function_await_args, nopos);
4767 4774
4768 // Wrap await to provide a break location between value evaluation and yield. 4775 // Wrap await to provide a break location between value evaluation and yield.
4769 Expression* await_assignment = factory()->NewAssignment( 4776 Expression* await_assignment = factory()->NewAssignment(
4770 Token::ASSIGN, factory()->NewVariableProxy(temp_var), 4777 Token::ASSIGN, factory()->NewVariableProxy(temp_var),
4771 async_function_await, nopos); 4778 async_function_await, nopos);
4772 do_block->statements()->Add( 4779 do_block->statements()->Add(
4773 factory()->NewExpressionStatement(await_assignment, await_pos), zone()); 4780 factory()->NewExpressionStatement(await_assignment, await_pos), zone());
4774 Expression* do_expr = factory()->NewDoExpression(do_block, temp_var, nopos); 4781 Expression* do_expr = factory()->NewDoExpression(do_block, temp_var, nopos);
4775 4782
4776 generator_object = factory()->NewVariableProxy(generator_object_variable); 4783 generator_object = factory()->NewVariableProxy(generator_object_variable);
(...skipping 1201 matching lines...) Expand 10 before | Expand all | Expand 10 after
5978 node->Print(Isolate::Current()); 5985 node->Print(Isolate::Current());
5979 } 5986 }
5980 #endif // DEBUG 5987 #endif // DEBUG
5981 5988
5982 #undef CHECK_OK 5989 #undef CHECK_OK
5983 #undef CHECK_OK_VOID 5990 #undef CHECK_OK_VOID
5984 #undef CHECK_FAILED 5991 #undef CHECK_FAILED
5985 5992
5986 } // namespace internal 5993 } // namespace internal
5987 } // namespace v8 5994 } // namespace v8
OLDNEW
« src/js/promise.js ('K') | « src/objects.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698