Chromium Code Reviews| 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 4362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4373 for (int i = 1; i < args->length(); ++i) { | 4373 for (int i = 1; i < args->length(); ++i) { |
| 4374 expr = factory()->NewBinaryOperation(Token::COMMA, expr, args->at(i), | 4374 expr = factory()->NewBinaryOperation(Token::COMMA, expr, args->at(i), |
| 4375 expr->position()); | 4375 expr->position()); |
| 4376 } | 4376 } |
| 4377 return expr; | 4377 return expr; |
| 4378 } | 4378 } |
| 4379 | 4379 |
| 4380 Expression* Parser::RewriteAwaitExpression(Expression* value, int await_pos) { | 4380 Expression* Parser::RewriteAwaitExpression(Expression* value, int await_pos) { |
| 4381 // yield do { | 4381 // yield do { |
| 4382 // tmp = <operand>; | 4382 // tmp = <operand>; |
| 4383 // tmp = %AsyncFunctionAwait(.generator_object, tmp); | 4383 // tmp2 = .promise; |
| 4384 // tmp = %AsyncFunctionAwait(.generator_object, tmp, tmp2); | |
| 4384 // } | 4385 // } |
| 4385 Variable* generator_object_variable = | 4386 Variable* generator_object_variable = |
| 4386 function_state_->generator_object_variable(); | 4387 function_state_->generator_object_variable(); |
| 4387 | 4388 |
| 4388 // If generator_object_variable is null, | 4389 // If generator_object_variable is null, |
| 4389 if (!generator_object_variable) return value; | 4390 if (!generator_object_variable) return value; |
| 4390 | 4391 |
| 4391 const int nopos = kNoSourcePosition; | 4392 const int nopos = kNoSourcePosition; |
| 4392 | 4393 |
| 4393 Variable* temp_var = NewTemporary(ast_value_factory()->empty_string()); | 4394 Variable* temp_var = NewTemporary(ast_value_factory()->empty_string()); |
| 4394 Block* do_block = factory()->NewBlock(nullptr, 2, false, nopos); | 4395 Block* do_block = factory()->NewBlock(nullptr, 2, false, nopos); |
| 4395 | 4396 |
| 4396 // Wrap value evaluation to provide a break location. | 4397 // Wrap value evaluation to provide a break location. |
| 4397 Expression* value_assignment = factory()->NewAssignment( | 4398 Expression* value_assignment = factory()->NewAssignment( |
| 4398 Token::ASSIGN, factory()->NewVariableProxy(temp_var), value, nopos); | 4399 Token::ASSIGN, factory()->NewVariableProxy(temp_var), value, nopos); |
| 4399 do_block->statements()->Add( | 4400 do_block->statements()->Add( |
| 4400 factory()->NewExpressionStatement(value_assignment, value->position()), | 4401 factory()->NewExpressionStatement(value_assignment, value->position()), |
| 4401 zone()); | 4402 zone()); |
| 4402 | 4403 |
| 4404 Variable* promise_temp_var = | |
| 4405 NewTemporary(ast_value_factory()->empty_string()); | |
| 4406 Expression* promise_assignment = factory()->NewAssignment( | |
| 4407 Token::ASSIGN, factory()->NewVariableProxy(promise_temp_var), | |
| 4408 BuildDotPromise(), nopos); | |
| 4409 do_block->statements()->Add( | |
| 4410 factory()->NewExpressionStatement(promise_assignment, value->position()), | |
| 4411 zone()); | |
|
Dan Ehrenberg
2016/09/14 01:09:14
This parser change should address the Blink failur
Dan Ehrenberg
2016/09/14 01:32:38
Sorry, issues still remaining; will work on more t
| |
| 4412 | |
| 4403 ZoneList<Expression*>* async_function_await_args = | 4413 ZoneList<Expression*>* async_function_await_args = |
| 4404 new (zone()) ZoneList<Expression*>(2, zone()); | 4414 new (zone()) ZoneList<Expression*>(3, zone()); |
| 4405 Expression* generator_object = | 4415 Expression* generator_object = |
| 4406 factory()->NewVariableProxy(generator_object_variable); | 4416 factory()->NewVariableProxy(generator_object_variable); |
| 4407 async_function_await_args->Add(generator_object, zone()); | 4417 async_function_await_args->Add(generator_object, zone()); |
| 4408 async_function_await_args->Add(factory()->NewVariableProxy(temp_var), zone()); | 4418 async_function_await_args->Add(factory()->NewVariableProxy(temp_var), zone()); |
| 4419 async_function_await_args->Add(factory()->NewVariableProxy(promise_temp_var), | |
| 4420 zone()); | |
| 4409 | 4421 |
| 4410 // The parser emits calls to AsyncFunctionAwaitCaught, but the | 4422 // The parser emits calls to AsyncFunctionAwaitCaught, but the |
| 4411 // AstNumberingVisitor will rewrite this to AsyncFunctionAwaitUncaught | 4423 // AstNumberingVisitor will rewrite this to AsyncFunctionAwaitUncaught |
| 4412 // if there is no local enclosing try/catch block. | 4424 // if there is no local enclosing try/catch block. |
| 4413 Expression* async_function_await = | 4425 Expression* async_function_await = |
| 4414 factory()->NewCallRuntime(Context::ASYNC_FUNCTION_AWAIT_CAUGHT_INDEX, | 4426 factory()->NewCallRuntime(Context::ASYNC_FUNCTION_AWAIT_CAUGHT_INDEX, |
| 4415 async_function_await_args, nopos); | 4427 async_function_await_args, nopos); |
| 4416 | 4428 |
| 4417 // Wrap await to provide a break location between value evaluation and yield. | 4429 // Wrap await to provide a break location between value evaluation and yield. |
| 4418 Expression* await_assignment = factory()->NewAssignment( | 4430 Expression* await_assignment = factory()->NewAssignment( |
| (...skipping 1208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5627 node->Print(Isolate::Current()); | 5639 node->Print(Isolate::Current()); |
| 5628 } | 5640 } |
| 5629 #endif // DEBUG | 5641 #endif // DEBUG |
| 5630 | 5642 |
| 5631 #undef CHECK_OK | 5643 #undef CHECK_OK |
| 5632 #undef CHECK_OK_VOID | 5644 #undef CHECK_OK_VOID |
| 5633 #undef CHECK_FAILED | 5645 #undef CHECK_FAILED |
| 5634 | 5646 |
| 5635 } // namespace internal | 5647 } // namespace internal |
| 5636 } // namespace v8 | 5648 } // namespace v8 |
| OLD | NEW |