| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 "vm/code_generator.h" | 5 #include "vm/code_generator.h" |
| 6 | 6 |
| 7 #include "vm/code_index_table.h" | 7 #include "vm/code_index_table.h" |
| 8 #include "vm/code_patcher.h" | 8 #include "vm/code_patcher.h" |
| 9 #include "vm/compiler.h" | 9 #include "vm/compiler.h" |
| 10 #include "vm/dart_entry.h" | 10 #include "vm/dart_entry.h" |
| (...skipping 797 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 808 } | 808 } |
| 809 | 809 |
| 810 | 810 |
| 811 // Only unoptimized code has invocation counter threshold checking. | 811 // Only unoptimized code has invocation counter threshold checking. |
| 812 // Once the invocation counter threshold is reached any entry into the | 812 // Once the invocation counter threshold is reached any entry into the |
| 813 // unoptimized code is redirected to this function. | 813 // unoptimized code is redirected to this function. |
| 814 DEFINE_RUNTIME_ENTRY(OptimizeInvokedFunction, 1) { | 814 DEFINE_RUNTIME_ENTRY(OptimizeInvokedFunction, 1) { |
| 815 ASSERT(arguments.Count() == | 815 ASSERT(arguments.Count() == |
| 816 kOptimizeInvokedFunctionRuntimeEntry.argument_count()); | 816 kOptimizeInvokedFunctionRuntimeEntry.argument_count()); |
| 817 const Function& function = Function::CheckedHandle(arguments.At(0)); | 817 const Function& function = Function::CheckedHandle(arguments.At(0)); |
| 818 ASSERT(function.is_optimizable()); | 818 if (function.is_optimizable()) { |
| 819 ASSERT(!Code::Handle(function.code()).is_optimized()); | 819 ASSERT(!Code::Handle(function.code()).is_optimized()); |
| 820 const Code& unoptimized_code = Code::Handle(function.code()); | 820 const Code& unoptimized_code = Code::Handle(function.code()); |
| 821 // Compilation patches the entry of unoptimized code. | 821 // Compilation patches the entry of unoptimized code. |
| 822 Compiler::CompileOptimizedFunction(function); | 822 Compiler::CompileOptimizedFunction(function); |
| 823 const Code& optimized_code = Code::Handle(function.code()); | 823 const Code& optimized_code = Code::Handle(function.code()); |
| 824 ASSERT(!optimized_code.IsNull()); | 824 ASSERT(!optimized_code.IsNull()); |
| 825 ASSERT(!unoptimized_code.IsNull()); | 825 ASSERT(!unoptimized_code.IsNull()); |
| 826 DisableOldCode(function, unoptimized_code, optimized_code); | 826 DisableOldCode(function, unoptimized_code, optimized_code); |
| 827 } else { |
| 828 // TODO(5442338): Abort as this should not happen. |
| 829 function.set_invocation_counter(0); |
| 830 } |
| 827 } | 831 } |
| 828 | 832 |
| 829 | 833 |
| 830 // The caller must be a static call in a Dart frame, or an entry frame. | 834 // The caller must be a static call in a Dart frame, or an entry frame. |
| 831 // Patch static call to point to 'new_entry_point'. | 835 // Patch static call to point to 'new_entry_point'. |
| 832 DEFINE_RUNTIME_ENTRY(FixCallersTarget, 1) { | 836 DEFINE_RUNTIME_ENTRY(FixCallersTarget, 1) { |
| 833 ASSERT(arguments.Count() == kFixCallersTargetRuntimeEntry.argument_count()); | 837 ASSERT(arguments.Count() == kFixCallersTargetRuntimeEntry.argument_count()); |
| 834 const Function& function = Function::CheckedHandle(arguments.At(0)); | 838 const Function& function = Function::CheckedHandle(arguments.At(0)); |
| 835 ASSERT(!function.IsNull()); | 839 ASSERT(!function.IsNull()); |
| 836 ASSERT(function.HasCode()); | 840 ASSERT(function.HasCode()); |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 988 } | 992 } |
| 989 } | 993 } |
| 990 } | 994 } |
| 991 // The cache is null terminated, therefore the loop above should never | 995 // The cache is null terminated, therefore the loop above should never |
| 992 // terminate by itself. | 996 // terminate by itself. |
| 993 UNREACHABLE(); | 997 UNREACHABLE(); |
| 994 return Code::null(); | 998 return Code::null(); |
| 995 } | 999 } |
| 996 | 1000 |
| 997 } // namespace dart | 1001 } // namespace dart |
| OLD | NEW |