| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include <set> | 5 #include <set> |
| 6 | 6 |
| 7 #include "vm/kernel_to_il.h" | 7 #include "vm/kernel_to_il.h" |
| 8 | 8 |
| 9 #include "vm/compiler.h" | 9 #include "vm/compiler.h" |
| 10 #include "vm/intermediate_language.h" | 10 #include "vm/intermediate_language.h" |
| (...skipping 3780 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3791 | 3791 |
| 3792 | 3792 |
| 3793 Fragment FlowGraphBuilder::BuildImplicitClosureCreation( | 3793 Fragment FlowGraphBuilder::BuildImplicitClosureCreation( |
| 3794 const Function& target) { | 3794 const Function& target) { |
| 3795 Fragment fragment; | 3795 Fragment fragment; |
| 3796 const dart::Class& closure_class = | 3796 const dart::Class& closure_class = |
| 3797 dart::Class::ZoneHandle(Z, I->object_store()->closure_class()); | 3797 dart::Class::ZoneHandle(Z, I->object_store()->closure_class()); |
| 3798 fragment += AllocateObject(closure_class, target); | 3798 fragment += AllocateObject(closure_class, target); |
| 3799 LocalVariable* closure = MakeTemporary(); | 3799 LocalVariable* closure = MakeTemporary(); |
| 3800 | 3800 |
| 3801 // The function signature can have uninstantiated class type parameters. |
| 3802 // |
| 3803 // TODO(regis): Also handle the case of a function signature that has |
| 3804 // uninstantiated function type parameters. |
| 3805 if (!target.HasInstantiatedSignature(kCurrentClass)) { |
| 3806 fragment += LoadLocal(closure); |
| 3807 fragment += LoadInstantiatorTypeArguments(); |
| 3808 fragment += |
| 3809 StoreInstanceField(TokenPosition::kNoSource, |
| 3810 Closure::instantiator_type_arguments_offset()); |
| 3811 } |
| 3812 |
| 3801 // Allocate a context that closes over `this`. | 3813 // Allocate a context that closes over `this`. |
| 3802 fragment += AllocateContext(1); | 3814 fragment += AllocateContext(1); |
| 3803 LocalVariable* context = MakeTemporary(); | 3815 LocalVariable* context = MakeTemporary(); |
| 3804 | 3816 |
| 3805 // Store the function and the context in the closure. | 3817 // Store the function and the context in the closure. |
| 3806 fragment += LoadLocal(closure); | 3818 fragment += LoadLocal(closure); |
| 3807 fragment += Constant(target); | 3819 fragment += Constant(target); |
| 3808 fragment += | 3820 fragment += |
| 3809 StoreInstanceField(TokenPosition::kNoSource, Closure::function_offset()); | 3821 StoreInstanceField(TokenPosition::kNoSource, Closure::function_offset()); |
| 3810 | 3822 |
| (...skipping 2879 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6690 } | 6702 } |
| 6691 break; | 6703 break; |
| 6692 } | 6704 } |
| 6693 | 6705 |
| 6694 const dart::Class& closure_class = | 6706 const dart::Class& closure_class = |
| 6695 dart::Class::ZoneHandle(Z, I->object_store()->closure_class()); | 6707 dart::Class::ZoneHandle(Z, I->object_store()->closure_class()); |
| 6696 ASSERT(!closure_class.IsNull()); | 6708 ASSERT(!closure_class.IsNull()); |
| 6697 Fragment instructions = AllocateObject(closure_class, function); | 6709 Fragment instructions = AllocateObject(closure_class, function); |
| 6698 LocalVariable* closure = MakeTemporary(); | 6710 LocalVariable* closure = MakeTemporary(); |
| 6699 | 6711 |
| 6700 // TODO(27590): Generic closures need type arguments. | 6712 // The function signature can have uninstantiated class type parameters. |
| 6713 // |
| 6714 // TODO(regis): Also handle the case of a function signature that has |
| 6715 // uninstantiated function type parameters. |
| 6716 if (!function.HasInstantiatedSignature(kCurrentClass)) { |
| 6717 instructions += LoadLocal(closure); |
| 6718 instructions += LoadInstantiatorTypeArguments(); |
| 6719 instructions += |
| 6720 StoreInstanceField(TokenPosition::kNoSource, |
| 6721 Closure::instantiator_type_arguments_offset()); |
| 6722 } |
| 6701 | 6723 |
| 6702 // Store the function and the context in the closure. | 6724 // Store the function and the context in the closure. |
| 6703 instructions += LoadLocal(closure); | 6725 instructions += LoadLocal(closure); |
| 6704 instructions += Constant(function); | 6726 instructions += Constant(function); |
| 6705 instructions += | 6727 instructions += |
| 6706 StoreInstanceField(TokenPosition::kNoSource, Closure::function_offset()); | 6728 StoreInstanceField(TokenPosition::kNoSource, Closure::function_offset()); |
| 6707 | 6729 |
| 6708 instructions += LoadLocal(closure); | 6730 instructions += LoadLocal(closure); |
| 6709 instructions += LoadLocal(parsed_function_->current_context_var()); | 6731 instructions += LoadLocal(parsed_function_->current_context_var()); |
| 6710 instructions += | 6732 instructions += |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6839 thread->clear_sticky_error(); | 6861 thread->clear_sticky_error(); |
| 6840 return error.raw(); | 6862 return error.raw(); |
| 6841 } | 6863 } |
| 6842 } | 6864 } |
| 6843 | 6865 |
| 6844 | 6866 |
| 6845 } // namespace kernel | 6867 } // namespace kernel |
| 6846 } // namespace dart | 6868 } // namespace dart |
| 6847 | 6869 |
| 6848 #endif // !defined(DART_PRECOMPILED_RUNTIME) | 6870 #endif // !defined(DART_PRECOMPILED_RUNTIME) |
| OLD | NEW |