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 4852 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4863 // yield %AsyncFunctionAwait(.generator_object, <operand>) | 4863 // yield %AsyncFunctionAwait(.generator_object, <operand>) |
| 4864 Variable* generator_object_variable = | 4864 Variable* generator_object_variable = |
| 4865 function_state_->generator_object_variable(); | 4865 function_state_->generator_object_variable(); |
| 4866 | 4866 |
| 4867 // If generator_object_variable is null, | 4867 // If generator_object_variable is null, |
| 4868 if (!generator_object_variable) return value; | 4868 if (!generator_object_variable) return value; |
| 4869 | 4869 |
| 4870 const int nopos = kNoSourcePosition; | 4870 const int nopos = kNoSourcePosition; |
| 4871 | 4871 |
| 4872 Variable* temp_var = NewTemporary(ast_value_factory()->empty_string()); | 4872 Variable* temp_var = NewTemporary(ast_value_factory()->empty_string()); |
| 4873 VariableProxy* temp_proxy = factory()->NewVariableProxy(temp_var); | 4873 VariableProxy* temp_proxy = factory()->NewVariableProxy(temp_var); |
|
adamk
2016/09/08 22:07:31
Not new to your code, but It seems very wrong that
Dan Ehrenberg
2016/09/08 22:34:46
I believe we can eliminate the second and third us
| |
| 4874 Block* do_block = factory()->NewBlock(nullptr, 2, false, nopos); | 4874 Block* do_block = factory()->NewBlock(nullptr, 2, false, nopos); |
| 4875 | 4875 |
| 4876 // Wrap value evaluation to provide a break location. | 4876 // Wrap value evaluation to provide a break location. |
| 4877 Expression* value_assignment = | 4877 Expression* value_assignment = |
| 4878 factory()->NewAssignment(Token::ASSIGN, temp_proxy, value, nopos); | 4878 factory()->NewAssignment(Token::ASSIGN, temp_proxy, value, nopos); |
| 4879 do_block->statements()->Add( | 4879 do_block->statements()->Add( |
| 4880 factory()->NewExpressionStatement(value_assignment, value->position()), | 4880 factory()->NewExpressionStatement(value_assignment, value->position()), |
| 4881 zone()); | 4881 zone()); |
| 4882 | 4882 |
| 4883 ZoneList<Expression*>* async_function_await_args = | 4883 ZoneList<Expression*>* async_function_await_args = |
| 4884 new (zone()) ZoneList<Expression*>(2, zone()); | 4884 new (zone()) ZoneList<Expression*>(3, zone()); |
| 4885 Expression* generator_object = | 4885 Expression* generator_object = |
| 4886 factory()->NewVariableProxy(generator_object_variable); | 4886 factory()->NewVariableProxy(generator_object_variable); |
| 4887 async_function_await_args->Add(generator_object, zone()); | 4887 async_function_await_args->Add(generator_object, zone()); |
| 4888 async_function_await_args->Add(temp_proxy, zone()); | 4888 async_function_await_args->Add(temp_proxy, zone()); |
| 4889 async_function_await_args->Add(BuildDotPromise(), zone()); | |
| 4889 Expression* async_function_await = | 4890 Expression* async_function_await = |
| 4890 factory()->NewCallRuntime(Context::ASYNC_FUNCTION_AWAIT_CAUGHT_INDEX, | 4891 factory()->NewCallRuntime(Context::ASYNC_FUNCTION_AWAIT_CAUGHT_INDEX, |
| 4891 async_function_await_args, nopos); | 4892 async_function_await_args, nopos); |
| 4892 // Wrap await to provide a break location between value evaluation and yield. | 4893 // Wrap await to provide a break location between value evaluation and yield. |
| 4893 Expression* await_assignment = factory()->NewAssignment( | 4894 Expression* await_assignment = factory()->NewAssignment( |
| 4894 Token::ASSIGN, temp_proxy, async_function_await, nopos); | 4895 Token::ASSIGN, temp_proxy, async_function_await, nopos); |
|
adamk
2016/09/08 22:07:31
As noted in the JS file, you're just assigning und
Dan Ehrenberg
2016/09/08 22:34:46
I believe it's assigning .promise, but there's not
| |
| 4895 do_block->statements()->Add( | 4896 do_block->statements()->Add( |
| 4896 factory()->NewExpressionStatement(await_assignment, await_pos), zone()); | 4897 factory()->NewExpressionStatement(await_assignment, await_pos), zone()); |
| 4897 Expression* do_expr = factory()->NewDoExpression(do_block, temp_var, nopos); | 4898 Expression* do_expr = factory()->NewDoExpression(do_block, temp_var, nopos); |
| 4898 | 4899 |
| 4899 generator_object = factory()->NewVariableProxy(generator_object_variable); | 4900 generator_object = factory()->NewVariableProxy(generator_object_variable); |
| 4900 return factory()->NewYield(generator_object, do_expr, nopos, | 4901 return factory()->NewYield(generator_object, do_expr, nopos, |
| 4901 Yield::kOnExceptionRethrow); | 4902 Yield::kOnExceptionRethrow); |
| 4902 } | 4903 } |
| 4903 | 4904 |
| 4904 class NonPatternRewriter : public AstExpressionRewriter { | 4905 class NonPatternRewriter : public AstExpressionRewriter { |
| (...skipping 1180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6085 node->Print(Isolate::Current()); | 6086 node->Print(Isolate::Current()); |
| 6086 } | 6087 } |
| 6087 #endif // DEBUG | 6088 #endif // DEBUG |
| 6088 | 6089 |
| 6089 #undef CHECK_OK | 6090 #undef CHECK_OK |
| 6090 #undef CHECK_OK_VOID | 6091 #undef CHECK_OK_VOID |
| 6091 #undef CHECK_FAILED | 6092 #undef CHECK_FAILED |
| 6092 | 6093 |
| 6093 } // namespace internal | 6094 } // namespace internal |
| 6094 } // namespace v8 | 6095 } // namespace v8 |
| OLD | NEW |