OLD | NEW |
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 3344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3355 if (param_scope != nullptr) { | 3355 if (param_scope != nullptr) { |
3356 CheckConflictingVarDeclarations(param_scope, CHECK_OK); | 3356 CheckConflictingVarDeclarations(param_scope, CHECK_OK); |
3357 } | 3357 } |
3358 init_block->statements()->Add(param_block, zone()); | 3358 init_block->statements()->Add(param_block, zone()); |
3359 } | 3359 } |
3360 } | 3360 } |
3361 return init_block; | 3361 return init_block; |
3362 } | 3362 } |
3363 | 3363 |
3364 Block* Parser::BuildRejectPromiseOnException(Block* inner_block, bool* ok) { | 3364 Block* Parser::BuildRejectPromiseOnException(Block* inner_block, bool* ok) { |
3365 // var .promise = %CreatePromise(); | 3365 // .promise = %CreatePromise(); |
3366 // var .debug_is_active = %_DebugIsActive(); | 3366 // .debug_is_active = %_DebugIsActive(); |
3367 // if (.debug_is_active) %DebugPushPromise(.promise); | 3367 // if (.debug_is_active) %DebugPushPromise(.promise); |
3368 // try { | 3368 // try { |
3369 // <inner_block> | 3369 // <inner_block> |
3370 // } catch (.catch) { | 3370 // } catch (.catch) { |
3371 // %RejectPromise(.promise, .catch); | 3371 // %RejectPromise(.promise, .catch); |
3372 // return .promise; | 3372 // return .promise; |
3373 // } finally { | 3373 // } finally { |
3374 // if (.debug_is_active) %DebugPopPromise(); | 3374 // if (.debug_is_active) %DebugPopPromise(); |
3375 // } | 3375 // } |
3376 Block* result = factory()->NewBlock(nullptr, 4, true, kNoSourcePosition); | 3376 Block* result = factory()->NewBlock(nullptr, 4, true, kNoSourcePosition); |
3377 | 3377 |
3378 // var .promise = %CreatePromise(); | 3378 // .promise = %CreatePromise(); |
3379 Statement* set_promise; | 3379 Statement* set_promise; |
3380 { | 3380 { |
3381 DeclareVariable(ast_value_factory()->dot_promise_string(), VAR, | |
3382 kNoSourcePosition, CHECK_OK); | |
3383 Expression* create_promise = factory()->NewCallRuntime( | 3381 Expression* create_promise = factory()->NewCallRuntime( |
3384 Context::PROMISE_CREATE_INDEX, | 3382 Context::PROMISE_CREATE_INDEX, |
3385 new (zone()) ZoneList<Expression*>(0, zone()), kNoSourcePosition); | 3383 new (zone()) ZoneList<Expression*>(0, zone()), kNoSourcePosition); |
3386 Assignment* assign_promise = factory()->NewAssignment( | 3384 Assignment* assign_promise = factory()->NewAssignment( |
3387 Token::INIT, BuildDotPromise(), create_promise, kNoSourcePosition); | 3385 Token::INIT, factory()->NewVariableProxy(PromiseVariable()), |
| 3386 create_promise, kNoSourcePosition); |
3388 set_promise = | 3387 set_promise = |
3389 factory()->NewExpressionStatement(assign_promise, kNoSourcePosition); | 3388 factory()->NewExpressionStatement(assign_promise, kNoSourcePosition); |
3390 } | 3389 } |
3391 result->statements()->Add(set_promise, zone()); | 3390 result->statements()->Add(set_promise, zone()); |
3392 | 3391 |
3393 // var .debug_is_active = %_DebugIsActive(); | 3392 Variable* debug_is_active = |
| 3393 scope()->NewTemporary(ast_value_factory()->empty_string()); |
| 3394 // .debug_is_active = %_DebugIsActive(); |
3394 Statement* set_debug_is_active; | 3395 Statement* set_debug_is_active; |
3395 { | 3396 { |
3396 DeclareVariable(ast_value_factory()->dot_debug_is_active_string(), VAR, | 3397 Expression* call_debug_is_active = factory()->NewCallRuntime( |
3397 kNoSourcePosition, CHECK_OK); | |
3398 Expression* debug_is_active = factory()->NewCallRuntime( | |
3399 Runtime::kInlineDebugIsActive, | 3398 Runtime::kInlineDebugIsActive, |
3400 new (zone()) ZoneList<Expression*>(0, zone()), kNoSourcePosition); | 3399 new (zone()) ZoneList<Expression*>(0, zone()), kNoSourcePosition); |
3401 Assignment* assign_debug_is_active = | 3400 Assignment* assign_debug_is_active = factory()->NewAssignment( |
3402 factory()->NewAssignment(Token::INIT, BuildDotDebugIsActive(), | 3401 Token::INIT, factory()->NewVariableProxy(debug_is_active), |
3403 debug_is_active, kNoSourcePosition); | 3402 call_debug_is_active, kNoSourcePosition); |
3404 set_debug_is_active = factory()->NewExpressionStatement( | 3403 set_debug_is_active = factory()->NewExpressionStatement( |
3405 assign_debug_is_active, kNoSourcePosition); | 3404 assign_debug_is_active, kNoSourcePosition); |
3406 } | 3405 } |
3407 result->statements()->Add(set_debug_is_active, zone()); | 3406 result->statements()->Add(set_debug_is_active, zone()); |
3408 | 3407 |
3409 // if (.debug_is_active) %DebugPushPromise(.promise); | 3408 // if (.debug_is_active) %DebugPushPromise(.promise); |
3410 Statement* conditionally_debug_push_promise; | 3409 Statement* conditionally_debug_push_promise; |
3411 { | 3410 { |
3412 ZoneList<Expression*>* args = new (zone()) ZoneList<Expression*>(1, zone()); | 3411 ZoneList<Expression*>* args = new (zone()) ZoneList<Expression*>(1, zone()); |
3413 args->Add(BuildDotPromise(), zone()); | 3412 args->Add(factory()->NewVariableProxy(PromiseVariable()), zone()); |
3414 Expression* call_push_promise = factory()->NewCallRuntime( | 3413 Expression* call_push_promise = factory()->NewCallRuntime( |
3415 Runtime::kDebugPushPromise, args, kNoSourcePosition); | 3414 Runtime::kDebugPushPromise, args, kNoSourcePosition); |
3416 Statement* debug_push_promise = | 3415 Statement* debug_push_promise = |
3417 factory()->NewExpressionStatement(call_push_promise, kNoSourcePosition); | 3416 factory()->NewExpressionStatement(call_push_promise, kNoSourcePosition); |
3418 conditionally_debug_push_promise = factory()->NewIfStatement( | 3417 conditionally_debug_push_promise = factory()->NewIfStatement( |
3419 BuildDotDebugIsActive(), debug_push_promise, | 3418 factory()->NewVariableProxy(debug_is_active), debug_push_promise, |
3420 factory()->NewEmptyStatement(kNoSourcePosition), kNoSourcePosition); | 3419 factory()->NewEmptyStatement(kNoSourcePosition), kNoSourcePosition); |
3421 } | 3420 } |
3422 result->statements()->Add(conditionally_debug_push_promise, zone()); | 3421 result->statements()->Add(conditionally_debug_push_promise, zone()); |
3423 | 3422 |
3424 // catch (.catch) { return %RejectPromise(.promise, .catch), .promise } | 3423 // catch (.catch) { return %RejectPromise(.promise, .catch), .promise } |
3425 Scope* catch_scope = NewScope(CATCH_SCOPE); | 3424 Scope* catch_scope = NewScope(CATCH_SCOPE); |
3426 catch_scope->set_is_hidden(); | 3425 catch_scope->set_is_hidden(); |
3427 Variable* catch_variable = | 3426 Variable* catch_variable = |
3428 catch_scope->DeclareLocal(ast_value_factory()->dot_catch_string(), VAR, | 3427 catch_scope->DeclareLocal(ast_value_factory()->dot_catch_string(), VAR, |
3429 kCreatedInitialized, NORMAL_VARIABLE); | 3428 kCreatedInitialized, NORMAL_VARIABLE); |
(...skipping 18 matching lines...) Expand all Loading... |
3448 // finally { if (.debug_is_active) %DebugPopPromise(); } | 3447 // finally { if (.debug_is_active) %DebugPopPromise(); } |
3449 Block* finally_block = | 3448 Block* finally_block = |
3450 factory()->NewBlock(nullptr, 1, true, kNoSourcePosition); | 3449 factory()->NewBlock(nullptr, 1, true, kNoSourcePosition); |
3451 { | 3450 { |
3452 ZoneList<Expression*>* args = new (zone()) ZoneList<Expression*>(0, zone()); | 3451 ZoneList<Expression*>* args = new (zone()) ZoneList<Expression*>(0, zone()); |
3453 Expression* call_pop_promise = factory()->NewCallRuntime( | 3452 Expression* call_pop_promise = factory()->NewCallRuntime( |
3454 Runtime::kDebugPopPromise, args, kNoSourcePosition); | 3453 Runtime::kDebugPopPromise, args, kNoSourcePosition); |
3455 Statement* debug_pop_promise = | 3454 Statement* debug_pop_promise = |
3456 factory()->NewExpressionStatement(call_pop_promise, kNoSourcePosition); | 3455 factory()->NewExpressionStatement(call_pop_promise, kNoSourcePosition); |
3457 Statement* conditionally_debug_pop_promise = factory()->NewIfStatement( | 3456 Statement* conditionally_debug_pop_promise = factory()->NewIfStatement( |
3458 BuildDotDebugIsActive(), debug_pop_promise, | 3457 factory()->NewVariableProxy(debug_is_active), debug_pop_promise, |
3459 factory()->NewEmptyStatement(kNoSourcePosition), kNoSourcePosition); | 3458 factory()->NewEmptyStatement(kNoSourcePosition), kNoSourcePosition); |
3460 finally_block->statements()->Add(conditionally_debug_pop_promise, zone()); | 3459 finally_block->statements()->Add(conditionally_debug_pop_promise, zone()); |
3461 } | 3460 } |
3462 | 3461 |
3463 Statement* try_finally_statement = factory()->NewTryFinallyStatement( | 3462 Statement* try_finally_statement = factory()->NewTryFinallyStatement( |
3464 outer_try_block, finally_block, kNoSourcePosition); | 3463 outer_try_block, finally_block, kNoSourcePosition); |
3465 | 3464 |
3466 result->statements()->Add(try_finally_statement, zone()); | 3465 result->statements()->Add(try_finally_statement, zone()); |
3467 return result; | 3466 return result; |
3468 } | 3467 } |
3469 | 3468 |
3470 Expression* Parser::BuildCreateJSGeneratorObject(int pos, FunctionKind kind) { | 3469 Expression* Parser::BuildCreateJSGeneratorObject(int pos, FunctionKind kind) { |
3471 DCHECK_NOT_NULL(function_state_->generator_object_variable()); | 3470 DCHECK_NOT_NULL(function_state_->generator_object_variable()); |
3472 ZoneList<Expression*>* args = new (zone()) ZoneList<Expression*>(2, zone()); | 3471 ZoneList<Expression*>* args = new (zone()) ZoneList<Expression*>(2, zone()); |
3473 args->Add(factory()->NewThisFunction(pos), zone()); | 3472 args->Add(factory()->NewThisFunction(pos), zone()); |
3474 args->Add(IsArrowFunction(kind) ? GetLiteralUndefined(pos) | 3473 args->Add(IsArrowFunction(kind) ? GetLiteralUndefined(pos) |
3475 : ThisExpression(kNoSourcePosition), | 3474 : ThisExpression(kNoSourcePosition), |
3476 zone()); | 3475 zone()); |
3477 return factory()->NewCallRuntime(Runtime::kCreateJSGeneratorObject, args, | 3476 return factory()->NewCallRuntime(Runtime::kCreateJSGeneratorObject, args, |
3478 pos); | 3477 pos); |
3479 } | 3478 } |
3480 | 3479 |
3481 Expression* Parser::BuildResolvePromise(Expression* value, int pos) { | 3480 Expression* Parser::BuildResolvePromise(Expression* value, int pos) { |
3482 // %ResolvePromise(.promise, value), .promise | 3481 // %ResolvePromise(.promise, value), .promise |
3483 ZoneList<Expression*>* args = new (zone()) ZoneList<Expression*>(2, zone()); | 3482 ZoneList<Expression*>* args = new (zone()) ZoneList<Expression*>(2, zone()); |
3484 args->Add(BuildDotPromise(), zone()); | 3483 args->Add(factory()->NewVariableProxy(PromiseVariable()), zone()); |
3485 args->Add(value, zone()); | 3484 args->Add(value, zone()); |
3486 Expression* call_runtime = | 3485 Expression* call_runtime = |
3487 factory()->NewCallRuntime(Context::PROMISE_RESOLVE_INDEX, args, pos); | 3486 factory()->NewCallRuntime(Context::PROMISE_RESOLVE_INDEX, args, pos); |
3488 return factory()->NewBinaryOperation(Token::COMMA, call_runtime, | 3487 return factory()->NewBinaryOperation( |
3489 BuildDotPromise(), pos); | 3488 Token::COMMA, call_runtime, |
| 3489 factory()->NewVariableProxy(PromiseVariable()), pos); |
3490 } | 3490 } |
3491 | 3491 |
3492 Expression* Parser::BuildRejectPromise(Expression* value, int pos) { | 3492 Expression* Parser::BuildRejectPromise(Expression* value, int pos) { |
3493 // %RejectPromiseNoDebugEvent(.promise, value, true), .promise | 3493 // %RejectPromiseNoDebugEvent(.promise, value, true), .promise |
3494 // The NoDebugEvent variant disables the additional debug event for the | 3494 // The NoDebugEvent variant disables the additional debug event for the |
3495 // rejection since a debug event already happened for the exception that got | 3495 // rejection since a debug event already happened for the exception that got |
3496 // us here. | 3496 // us here. |
3497 ZoneList<Expression*>* args = new (zone()) ZoneList<Expression*>(2, zone()); | 3497 ZoneList<Expression*>* args = new (zone()) ZoneList<Expression*>(2, zone()); |
3498 args->Add(BuildDotPromise(), zone()); | 3498 args->Add(factory()->NewVariableProxy(PromiseVariable()), zone()); |
3499 args->Add(value, zone()); | 3499 args->Add(value, zone()); |
3500 Expression* call_runtime = factory()->NewCallRuntime( | 3500 Expression* call_runtime = factory()->NewCallRuntime( |
3501 Context::REJECT_PROMISE_NO_DEBUG_EVENT_INDEX, args, pos); | 3501 Context::REJECT_PROMISE_NO_DEBUG_EVENT_INDEX, args, pos); |
3502 return factory()->NewBinaryOperation(Token::COMMA, call_runtime, | 3502 return factory()->NewBinaryOperation( |
3503 BuildDotPromise(), pos); | 3503 Token::COMMA, call_runtime, |
| 3504 factory()->NewVariableProxy(PromiseVariable()), pos); |
3504 } | 3505 } |
3505 | 3506 |
3506 VariableProxy* Parser::BuildDotPromise() { | 3507 Variable* Parser::PromiseVariable() { |
3507 return NewUnresolved(ast_value_factory()->dot_promise_string(), VAR); | 3508 // Based on the various compilation paths, there are many different code |
3508 } | 3509 // paths which may be the first to access the Promise temporary. Whichever |
3509 | 3510 // comes first should create it and stash it in the FunctionState. |
3510 VariableProxy* Parser::BuildDotDebugIsActive() { | 3511 Variable* promise = function_state_->promise_variable(); |
3511 return NewUnresolved(ast_value_factory()->dot_debug_is_active_string(), VAR); | 3512 if (function_state_->promise_variable() == nullptr) { |
| 3513 promise = scope()->NewTemporary(ast_value_factory()->empty_string()); |
| 3514 function_state_->set_promise_variable(promise); |
| 3515 } |
| 3516 return promise; |
3512 } | 3517 } |
3513 | 3518 |
3514 ZoneList<Statement*>* Parser::ParseEagerFunctionBody( | 3519 ZoneList<Statement*>* Parser::ParseEagerFunctionBody( |
3515 const AstRawString* function_name, int pos, | 3520 const AstRawString* function_name, int pos, |
3516 const ParserFormalParameters& parameters, FunctionKind kind, | 3521 const ParserFormalParameters& parameters, FunctionKind kind, |
3517 FunctionLiteral::FunctionType function_type, bool* ok) { | 3522 FunctionLiteral::FunctionType function_type, bool* ok) { |
3518 // Everything inside an eagerly parsed function will be parsed eagerly | 3523 // Everything inside an eagerly parsed function will be parsed eagerly |
3519 // (see comment above). | 3524 // (see comment above). |
3520 ParsingModeScope parsing_mode(this, PARSE_EAGERLY); | 3525 ParsingModeScope parsing_mode(this, PARSE_EAGERLY); |
3521 ZoneList<Statement*>* result = new(zone()) ZoneList<Statement*>(8, zone()); | 3526 ZoneList<Statement*>* result = new(zone()) ZoneList<Statement*>(8, zone()); |
(...skipping 1033 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4555 Expression* expr = args->at(0); | 4560 Expression* expr = args->at(0); |
4556 for (int i = 1; i < args->length(); ++i) { | 4561 for (int i = 1; i < args->length(); ++i) { |
4557 expr = factory()->NewBinaryOperation(Token::COMMA, expr, args->at(i), | 4562 expr = factory()->NewBinaryOperation(Token::COMMA, expr, args->at(i), |
4558 expr->position()); | 4563 expr->position()); |
4559 } | 4564 } |
4560 return expr; | 4565 return expr; |
4561 } | 4566 } |
4562 | 4567 |
4563 Expression* Parser::RewriteAwaitExpression(Expression* value, int await_pos) { | 4568 Expression* Parser::RewriteAwaitExpression(Expression* value, int await_pos) { |
4564 // yield do { | 4569 // yield do { |
4565 // promise_tmp = .promise; | |
4566 // tmp = <operand>; | 4570 // tmp = <operand>; |
4567 // %AsyncFunctionAwait(.generator_object, tmp, promise_tmp); | 4571 // %AsyncFunctionAwait(.generator_object, tmp, .promise); |
4568 // promise_tmp | 4572 // .promise |
4569 // } | 4573 // } |
4570 // The value of the expression is returned to the caller of the async | 4574 // The value of the expression is returned to the caller of the async |
4571 // function for the first yield statement; for this, .promise is the | 4575 // function for the first yield statement; for this, .promise is the |
4572 // appropriate return value, being a Promise that will be fulfilled or | 4576 // appropriate return value, being a Promise that will be fulfilled or |
4573 // rejected with the appropriate value by the desugaring. Subsequent yield | 4577 // rejected with the appropriate value by the desugaring. Subsequent yield |
4574 // occurrences will return to the AsyncFunctionNext call within the | 4578 // occurrences will return to the AsyncFunctionNext call within the |
4575 // implemementation of the intermediate throwaway Promise's then handler. | 4579 // implemementation of the intermediate throwaway Promise's then handler. |
4576 // This handler has nothing useful to do with the value, as the Promise is | 4580 // This handler has nothing useful to do with the value, as the Promise is |
4577 // ignored. If we yielded the value of the throwawayPromise that | 4581 // ignored. If we yielded the value of the throwawayPromise that |
4578 // AsyncFunctionAwait creates as an intermediate, it would create a memory | 4582 // AsyncFunctionAwait creates as an intermediate, it would create a memory |
4579 // leak; we must return .promise instead; | 4583 // leak; we must return .promise instead; |
4580 // The operand needs to be evaluated on a separate statement in order to get | 4584 // The operand needs to be evaluated on a separate statement in order to get |
4581 // a break location, and the .promise needs to be read earlier so that it | 4585 // a break location, and the .promise needs to be read earlier so that it |
4582 // doesn't insert a false location. | 4586 // doesn't insert a false location. |
4583 // TODO(littledan): investigate why this ordering is needed in more detail. | 4587 // TODO(littledan): investigate why this ordering is needed in more detail. |
4584 Variable* generator_object_variable = | 4588 Variable* generator_object_variable = |
4585 function_state_->generator_object_variable(); | 4589 function_state_->generator_object_variable(); |
4586 | 4590 |
4587 // If generator_object_variable is null, | 4591 // If generator_object_variable is null, |
4588 // TODO(littledan): Is this necessary? | 4592 // TODO(littledan): Is this necessary? |
4589 if (!generator_object_variable) return value; | 4593 if (!generator_object_variable) return value; |
4590 | 4594 |
4591 const int nopos = kNoSourcePosition; | 4595 const int nopos = kNoSourcePosition; |
4592 | 4596 |
4593 Block* do_block = factory()->NewBlock(nullptr, 3, false, nopos); | 4597 Block* do_block = factory()->NewBlock(nullptr, 2, false, nopos); |
4594 | 4598 |
4595 Variable* promise_temp_var = | 4599 Variable* promise = PromiseVariable(); |
4596 NewTemporary(ast_value_factory()->empty_string()); | |
4597 Expression* promise_assignment = factory()->NewAssignment( | |
4598 Token::ASSIGN, factory()->NewVariableProxy(promise_temp_var), | |
4599 BuildDotPromise(), nopos); | |
4600 do_block->statements()->Add( | |
4601 factory()->NewExpressionStatement(promise_assignment, nopos), zone()); | |
4602 | 4600 |
4603 // Wrap value evaluation to provide a break location. | 4601 // Wrap value evaluation to provide a break location. |
4604 Variable* temp_var = NewTemporary(ast_value_factory()->empty_string()); | 4602 Variable* temp_var = NewTemporary(ast_value_factory()->empty_string()); |
4605 Expression* value_assignment = factory()->NewAssignment( | 4603 Expression* value_assignment = factory()->NewAssignment( |
4606 Token::ASSIGN, factory()->NewVariableProxy(temp_var), value, nopos); | 4604 Token::ASSIGN, factory()->NewVariableProxy(temp_var), value, nopos); |
4607 do_block->statements()->Add( | 4605 do_block->statements()->Add( |
4608 factory()->NewExpressionStatement(value_assignment, value->position()), | 4606 factory()->NewExpressionStatement(value_assignment, value->position()), |
4609 zone()); | 4607 zone()); |
4610 | 4608 |
4611 ZoneList<Expression*>* async_function_await_args = | 4609 ZoneList<Expression*>* async_function_await_args = |
4612 new (zone()) ZoneList<Expression*>(3, zone()); | 4610 new (zone()) ZoneList<Expression*>(3, zone()); |
4613 Expression* generator_object = | 4611 Expression* generator_object = |
4614 factory()->NewVariableProxy(generator_object_variable); | 4612 factory()->NewVariableProxy(generator_object_variable); |
4615 async_function_await_args->Add(generator_object, zone()); | 4613 async_function_await_args->Add(generator_object, zone()); |
4616 async_function_await_args->Add(factory()->NewVariableProxy(temp_var), zone()); | 4614 async_function_await_args->Add(factory()->NewVariableProxy(temp_var), zone()); |
4617 async_function_await_args->Add(factory()->NewVariableProxy(promise_temp_var), | 4615 async_function_await_args->Add(factory()->NewVariableProxy(promise), zone()); |
4618 zone()); | |
4619 | 4616 |
4620 // The parser emits calls to AsyncFunctionAwaitCaught, but the | 4617 // The parser emits calls to AsyncFunctionAwaitCaught, but the |
4621 // AstNumberingVisitor will rewrite this to AsyncFunctionAwaitUncaught | 4618 // AstNumberingVisitor will rewrite this to AsyncFunctionAwaitUncaught |
4622 // if there is no local enclosing try/catch block. | 4619 // if there is no local enclosing try/catch block. |
4623 Expression* async_function_await = | 4620 Expression* async_function_await = |
4624 factory()->NewCallRuntime(Context::ASYNC_FUNCTION_AWAIT_CAUGHT_INDEX, | 4621 factory()->NewCallRuntime(Context::ASYNC_FUNCTION_AWAIT_CAUGHT_INDEX, |
4625 async_function_await_args, nopos); | 4622 async_function_await_args, nopos); |
4626 do_block->statements()->Add( | 4623 do_block->statements()->Add( |
4627 factory()->NewExpressionStatement(async_function_await, await_pos), | 4624 factory()->NewExpressionStatement(async_function_await, await_pos), |
4628 zone()); | 4625 zone()); |
4629 | 4626 |
4630 // Wrap await to provide a break location between value evaluation and yield. | 4627 // Wrap await to provide a break location between value evaluation and yield. |
4631 Expression* do_expr = | 4628 Expression* do_expr = factory()->NewDoExpression(do_block, promise, nopos); |
4632 factory()->NewDoExpression(do_block, promise_temp_var, nopos); | |
4633 | 4629 |
4634 generator_object = factory()->NewVariableProxy(generator_object_variable); | 4630 generator_object = factory()->NewVariableProxy(generator_object_variable); |
4635 return factory()->NewYield(generator_object, do_expr, nopos, | 4631 return factory()->NewYield(generator_object, do_expr, nopos, |
4636 Yield::kOnExceptionRethrow); | 4632 Yield::kOnExceptionRethrow); |
4637 } | 4633 } |
4638 | 4634 |
4639 class NonPatternRewriter : public AstExpressionRewriter { | 4635 class NonPatternRewriter : public AstExpressionRewriter { |
4640 public: | 4636 public: |
4641 NonPatternRewriter(uintptr_t stack_limit, Parser* parser) | 4637 NonPatternRewriter(uintptr_t stack_limit, Parser* parser) |
4642 : AstExpressionRewriter(stack_limit), parser_(parser) {} | 4638 : AstExpressionRewriter(stack_limit), parser_(parser) {} |
(...skipping 1186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5829 | 5825 |
5830 return final_loop; | 5826 return final_loop; |
5831 } | 5827 } |
5832 | 5828 |
5833 #undef CHECK_OK | 5829 #undef CHECK_OK |
5834 #undef CHECK_OK_VOID | 5830 #undef CHECK_OK_VOID |
5835 #undef CHECK_FAILED | 5831 #undef CHECK_FAILED |
5836 | 5832 |
5837 } // namespace internal | 5833 } // namespace internal |
5838 } // namespace v8 | 5834 } // namespace v8 |
OLD | NEW |