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

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

Issue 2276243002: Mark await expressions as caught or uncaught (Closed)
Patch Set: Fix broken test 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 3856 matching lines...) Expand 10 before | Expand all | Expand 10 after
3867 catch_scope->DeclareLocal(ast_value_factory()->dot_catch_string(), VAR, 3867 catch_scope->DeclareLocal(ast_value_factory()->dot_catch_string(), VAR,
3868 kCreatedInitialized, Variable::NORMAL); 3868 kCreatedInitialized, Variable::NORMAL);
3869 Block* catch_block = factory()->NewBlock(nullptr, 1, true, kNoSourcePosition); 3869 Block* catch_block = factory()->NewBlock(nullptr, 1, true, kNoSourcePosition);
3870 3870
3871 Expression* promise_reject = BuildRejectPromise( 3871 Expression* promise_reject = BuildRejectPromise(
3872 factory()->NewVariableProxy(catch_variable), kNoSourcePosition); 3872 factory()->NewVariableProxy(catch_variable), kNoSourcePosition);
3873 ReturnStatement* return_promise_reject = 3873 ReturnStatement* return_promise_reject =
3874 factory()->NewReturnStatement(promise_reject, kNoSourcePosition); 3874 factory()->NewReturnStatement(promise_reject, kNoSourcePosition);
3875 catch_block->statements()->Add(return_promise_reject, zone()); 3875 catch_block->statements()->Add(return_promise_reject, zone());
3876 3876
3877 TryStatement* try_catch_statement = factory()->NewTryCatchStatement( 3877 TryStatement* try_catch_statement =
3878 inner_block, catch_scope, catch_variable, catch_block, kNoSourcePosition); 3878 factory()->NewTryCatchStatementForAsyncAwait(inner_block, catch_scope,
3879 catch_variable, catch_block,
3880 kNoSourcePosition);
3879 3881
3880 // There is no TryCatchFinally node, so wrap it in an outer try/finally 3882 // There is no TryCatchFinally node, so wrap it in an outer try/finally
3881 Block* outer_try_block = 3883 Block* outer_try_block =
3882 factory()->NewBlock(nullptr, 1, true, kNoSourcePosition); 3884 factory()->NewBlock(nullptr, 1, true, kNoSourcePosition);
3883 outer_try_block->statements()->Add(try_catch_statement, zone()); 3885 outer_try_block->statements()->Add(try_catch_statement, zone());
3884 3886
3885 // finally { if (.debug_is_active) %DebugPopPromise(); } 3887 // finally { if (.debug_is_active) %DebugPopPromise(); }
3886 Block* finally_block = 3888 Block* finally_block =
3887 factory()->NewBlock(nullptr, 1, true, kNoSourcePosition); 3889 factory()->NewBlock(nullptr, 1, true, kNoSourcePosition);
3888 { 3890 {
(...skipping 913 matching lines...) Expand 10 before | Expand all | Expand 10 after
4802 do_block->statements()->Add( 4804 do_block->statements()->Add(
4803 factory()->NewExpressionStatement(value_assignment, value->position()), 4805 factory()->NewExpressionStatement(value_assignment, value->position()),
4804 zone()); 4806 zone());
4805 4807
4806 ZoneList<Expression*>* async_function_await_args = 4808 ZoneList<Expression*>* async_function_await_args =
4807 new (zone()) ZoneList<Expression*>(2, zone()); 4809 new (zone()) ZoneList<Expression*>(2, zone());
4808 Expression* generator_object = 4810 Expression* generator_object =
4809 factory()->NewVariableProxy(generator_object_variable); 4811 factory()->NewVariableProxy(generator_object_variable);
4810 async_function_await_args->Add(generator_object, zone()); 4812 async_function_await_args->Add(generator_object, zone());
4811 async_function_await_args->Add(temp_proxy, zone()); 4813 async_function_await_args->Add(temp_proxy, zone());
4812 Expression* async_function_await = factory()->NewCallRuntime( 4814 // The parser emits calls to AsyncFunctionAwaitCaught, but the
4813 Context::ASYNC_FUNCTION_AWAIT_INDEX, async_function_await_args, nopos); 4815 // AstNumberingVisitor will rewrite this to AsyncFunctionAwaitUncaught
4816 // if there is no local enclosing try/catch block.
4817 Expression* async_function_await =
4818 factory()->NewCallRuntime(Context::ASYNC_FUNCTION_AWAIT_CAUGHT_INDEX,
4819 async_function_await_args, nopos);
4814 // Wrap await to provide a break location between value evaluation and yield. 4820 // Wrap await to provide a break location between value evaluation and yield.
4815 Expression* await_assignment = factory()->NewAssignment( 4821 Expression* await_assignment = factory()->NewAssignment(
4816 Token::ASSIGN, temp_proxy, async_function_await, nopos); 4822 Token::ASSIGN, temp_proxy, async_function_await, nopos);
4817 do_block->statements()->Add( 4823 do_block->statements()->Add(
4818 factory()->NewExpressionStatement(await_assignment, await_pos), zone()); 4824 factory()->NewExpressionStatement(await_assignment, await_pos), zone());
4819 Expression* do_expr = factory()->NewDoExpression(do_block, temp_var, nopos); 4825 Expression* do_expr = factory()->NewDoExpression(do_block, temp_var, nopos);
4820 4826
4821 generator_object = factory()->NewVariableProxy(generator_object_variable); 4827 generator_object = factory()->NewVariableProxy(generator_object_variable);
4822 return factory()->NewYield(generator_object, do_expr, nopos, 4828 return factory()->NewYield(generator_object, do_expr, nopos,
4823 Yield::kOnExceptionRethrow); 4829 Yield::kOnExceptionRethrow);
(...skipping 1200 matching lines...) Expand 10 before | Expand all | Expand 10 after
6024 node->Print(Isolate::Current()); 6030 node->Print(Isolate::Current());
6025 } 6031 }
6026 #endif // DEBUG 6032 #endif // DEBUG
6027 6033
6028 #undef CHECK_OK 6034 #undef CHECK_OK
6029 #undef CHECK_OK_VOID 6035 #undef CHECK_OK_VOID
6030 #undef CHECK_FAILED 6036 #undef CHECK_FAILED
6031 6037
6032 } // namespace internal 6038 } // namespace internal
6033 } // namespace v8 6039 } // 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