Mathieu Chartier | e5f13e5 | 2015-02-24 09:37:21 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2014 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #include "jit.h" |
| 18 | |
| 19 | #include <dlfcn.h> |
| 20 | |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 21 | #include "art_method-inl.h" |
Andreas Gampe | 542451c | 2016-07-26 09:02:02 -0700 | [diff] [blame] | 22 | #include "base/enums.h" |
Andreas Gampe | 5794381 | 2017-12-06 21:39:13 -0800 | [diff] [blame] | 23 | #include "base/logging.h" // For VLOG. |
Andreas Gampe | 0897e1c | 2017-05-16 08:36:56 -0700 | [diff] [blame] | 24 | #include "base/memory_tool.h" |
Andreas Gampe | dcc528d | 2017-12-07 13:37:10 -0800 | [diff] [blame] | 25 | #include "base/runtime_debug.h" |
David Sehr | c431b9d | 2018-03-02 12:01:51 -0800 | [diff] [blame] | 26 | #include "base/utils.h" |
Vladimir Marko | c7aa87e | 2018-05-24 15:19:52 +0100 | [diff] [blame] | 27 | #include "class_root.h" |
Andreas Gampe | 2a5c468 | 2015-08-14 08:22:54 -0700 | [diff] [blame] | 28 | #include "debugger.h" |
Mathieu Chartier | e5f13e5 | 2015-02-24 09:37:21 -0800 | [diff] [blame] | 29 | #include "entrypoints/runtime_asm_entrypoints.h" |
| 30 | #include "interpreter/interpreter.h" |
| 31 | #include "jit_code_cache.h" |
Vladimir Marko | a3ad0cd | 2018-05-04 10:06:38 +0100 | [diff] [blame] | 32 | #include "jni/java_vm_ext.h" |
Orion Hodson | 52f5a1f | 2018-05-02 11:05:44 +0100 | [diff] [blame] | 33 | #include "mirror/method_handle_impl.h" |
| 34 | #include "mirror/var_handle.h" |
Calin Juravle | 31f2c15 | 2015-10-23 17:56:15 +0100 | [diff] [blame] | 35 | #include "oat_file_manager.h" |
Nicolas Geoffray | b331feb | 2016-02-05 16:51:53 +0000 | [diff] [blame] | 36 | #include "oat_quick_method_header.h" |
David Sehr | 82d046e | 2018-04-23 08:14:19 -0700 | [diff] [blame] | 37 | #include "profile/profile_compilation_info.h" |
Calin Juravle | 4d77b6a | 2015-12-01 18:38:09 +0000 | [diff] [blame] | 38 | #include "profile_saver.h" |
Mathieu Chartier | e5f13e5 | 2015-02-24 09:37:21 -0800 | [diff] [blame] | 39 | #include "runtime.h" |
| 40 | #include "runtime_options.h" |
Andreas Gampe | 513061a | 2017-06-01 09:17:34 -0700 | [diff] [blame] | 41 | #include "stack.h" |
Nicolas Geoffray | b331feb | 2016-02-05 16:51:53 +0000 | [diff] [blame] | 42 | #include "stack_map.h" |
Andreas Gampe | 513061a | 2017-06-01 09:17:34 -0700 | [diff] [blame] | 43 | #include "thread-inl.h" |
Nicolas Geoffray | 274fe4a | 2016-04-12 16:33:24 +0100 | [diff] [blame] | 44 | #include "thread_list.h" |
Mathieu Chartier | e5f13e5 | 2015-02-24 09:37:21 -0800 | [diff] [blame] | 45 | |
| 46 | namespace art { |
| 47 | namespace jit { |
| 48 | |
Nicolas Geoffray | d186dd8 | 2016-02-16 10:03:44 +0000 | [diff] [blame] | 49 | static constexpr bool kEnableOnStackReplacement = true; |
Nicolas Geoffray | e866213 | 2016-02-15 10:00:42 +0000 | [diff] [blame] | 50 | |
Andreas Gampe | 7897cec | 2017-07-19 16:28:59 -0700 | [diff] [blame] | 51 | // Different compilation threshold constants. These can be overridden on the command line. |
| 52 | static constexpr size_t kJitDefaultCompileThreshold = 10000; // Non-debug default. |
| 53 | static constexpr size_t kJitStressDefaultCompileThreshold = 100; // Fast-debug build. |
| 54 | static constexpr size_t kJitSlowStressDefaultCompileThreshold = 2; // Slow-debug build. |
| 55 | |
Mathieu Chartier | 72918ea | 2016-03-24 11:07:06 -0700 | [diff] [blame] | 56 | // JIT compiler |
Igor Murashkin | 2ffb703 | 2017-11-08 13:35:21 -0800 | [diff] [blame] | 57 | void* Jit::jit_library_handle_ = nullptr; |
Mathieu Chartier | 72918ea | 2016-03-24 11:07:06 -0700 | [diff] [blame] | 58 | void* Jit::jit_compiler_handle_ = nullptr; |
| 59 | void* (*Jit::jit_load_)(bool*) = nullptr; |
| 60 | void (*Jit::jit_unload_)(void*) = nullptr; |
| 61 | bool (*Jit::jit_compile_method_)(void*, ArtMethod*, Thread*, bool) = nullptr; |
| 62 | void (*Jit::jit_types_loaded_)(void*, mirror::Class**, size_t count) = nullptr; |
Mathieu Chartier | 72918ea | 2016-03-24 11:07:06 -0700 | [diff] [blame] | 63 | |
Andreas Gampe | 7897cec | 2017-07-19 16:28:59 -0700 | [diff] [blame] | 64 | struct StressModeHelper { |
| 65 | DECLARE_RUNTIME_DEBUG_FLAG(kSlowMode); |
| 66 | }; |
| 67 | DEFINE_RUNTIME_DEBUG_FLAG(StressModeHelper, kSlowMode); |
| 68 | |
Mathieu Chartier | e5f13e5 | 2015-02-24 09:37:21 -0800 | [diff] [blame] | 69 | JitOptions* JitOptions::CreateFromRuntimeArguments(const RuntimeArgumentMap& options) { |
Mathieu Chartier | e5f13e5 | 2015-02-24 09:37:21 -0800 | [diff] [blame] | 70 | auto* jit_options = new JitOptions; |
Calin Juravle | ffc8707 | 2016-04-20 14:22:09 +0100 | [diff] [blame] | 71 | jit_options->use_jit_compilation_ = options.GetOrDefault(RuntimeArgumentMap::UseJitCompilation); |
Nicolas Geoffray | 83f080a | 2016-03-08 16:50:21 +0000 | [diff] [blame] | 72 | |
Nicolas Geoffray | 0a3be16 | 2015-11-18 11:15:22 +0000 | [diff] [blame] | 73 | jit_options->code_cache_initial_capacity_ = |
| 74 | options.GetOrDefault(RuntimeArgumentMap::JITCodeCacheInitialCapacity); |
| 75 | jit_options->code_cache_max_capacity_ = |
| 76 | options.GetOrDefault(RuntimeArgumentMap::JITCodeCacheMaxCapacity); |
Mathieu Chartier | a4885cb | 2015-03-09 15:38:54 -0700 | [diff] [blame] | 77 | jit_options->dump_info_on_shutdown_ = |
| 78 | options.Exists(RuntimeArgumentMap::DumpJITInfoOnShutdown); |
Calin Juravle | 138dbff | 2016-06-28 19:36:58 +0100 | [diff] [blame] | 79 | jit_options->profile_saver_options_ = |
| 80 | options.GetOrDefault(RuntimeArgumentMap::ProfileSaverOpts); |
Nicolas Geoffray | 47b9580 | 2018-05-16 15:42:17 +0100 | [diff] [blame] | 81 | jit_options->thread_pool_pthread_priority_ = |
| 82 | options.GetOrDefault(RuntimeArgumentMap::JITPoolThreadPthreadPriority); |
Nicolas Geoffray | 83f080a | 2016-03-08 16:50:21 +0000 | [diff] [blame] | 83 | |
Andreas Gampe | 7897cec | 2017-07-19 16:28:59 -0700 | [diff] [blame] | 84 | if (options.Exists(RuntimeArgumentMap::JITCompileThreshold)) { |
| 85 | jit_options->compile_threshold_ = *options.Get(RuntimeArgumentMap::JITCompileThreshold); |
| 86 | } else { |
| 87 | jit_options->compile_threshold_ = |
| 88 | kIsDebugBuild |
| 89 | ? (StressModeHelper::kSlowMode |
| 90 | ? kJitSlowStressDefaultCompileThreshold |
| 91 | : kJitStressDefaultCompileThreshold) |
| 92 | : kJitDefaultCompileThreshold; |
| 93 | } |
Nicolas Geoffray | 83f080a | 2016-03-08 16:50:21 +0000 | [diff] [blame] | 94 | if (jit_options->compile_threshold_ > std::numeric_limits<uint16_t>::max()) { |
| 95 | LOG(FATAL) << "Method compilation threshold is above its internal limit."; |
| 96 | } |
| 97 | |
| 98 | if (options.Exists(RuntimeArgumentMap::JITWarmupThreshold)) { |
| 99 | jit_options->warmup_threshold_ = *options.Get(RuntimeArgumentMap::JITWarmupThreshold); |
| 100 | if (jit_options->warmup_threshold_ > std::numeric_limits<uint16_t>::max()) { |
| 101 | LOG(FATAL) << "Method warmup threshold is above its internal limit."; |
| 102 | } |
| 103 | } else { |
| 104 | jit_options->warmup_threshold_ = jit_options->compile_threshold_ / 2; |
| 105 | } |
| 106 | |
| 107 | if (options.Exists(RuntimeArgumentMap::JITOsrThreshold)) { |
| 108 | jit_options->osr_threshold_ = *options.Get(RuntimeArgumentMap::JITOsrThreshold); |
| 109 | if (jit_options->osr_threshold_ > std::numeric_limits<uint16_t>::max()) { |
| 110 | LOG(FATAL) << "Method on stack replacement threshold is above its internal limit."; |
| 111 | } |
| 112 | } else { |
| 113 | jit_options->osr_threshold_ = jit_options->compile_threshold_ * 2; |
| 114 | if (jit_options->osr_threshold_ > std::numeric_limits<uint16_t>::max()) { |
| 115 | jit_options->osr_threshold_ = std::numeric_limits<uint16_t>::max(); |
| 116 | } |
| 117 | } |
| 118 | |
Calin Juravle | b2771b4 | 2016-04-07 17:09:25 +0100 | [diff] [blame] | 119 | if (options.Exists(RuntimeArgumentMap::JITPriorityThreadWeight)) { |
| 120 | jit_options->priority_thread_weight_ = |
| 121 | *options.Get(RuntimeArgumentMap::JITPriorityThreadWeight); |
| 122 | if (jit_options->priority_thread_weight_ > jit_options->warmup_threshold_) { |
| 123 | LOG(FATAL) << "Priority thread weight is above the warmup threshold."; |
| 124 | } else if (jit_options->priority_thread_weight_ == 0) { |
| 125 | LOG(FATAL) << "Priority thread weight cannot be 0."; |
| 126 | } |
| 127 | } else { |
Nicolas Geoffray | 71cd50f | 2016-04-14 15:00:33 +0100 | [diff] [blame] | 128 | jit_options->priority_thread_weight_ = std::max( |
| 129 | jit_options->warmup_threshold_ / Jit::kDefaultPriorityThreadWeightRatio, |
| 130 | static_cast<size_t>(1)); |
Calin Juravle | b2771b4 | 2016-04-07 17:09:25 +0100 | [diff] [blame] | 131 | } |
| 132 | |
Calin Juravle | 155ff3d | 2016-04-27 14:14:58 +0100 | [diff] [blame] | 133 | if (options.Exists(RuntimeArgumentMap::JITInvokeTransitionWeight)) { |
Nicolas Geoffray | 7c9f3ba | 2016-05-06 16:52:36 +0100 | [diff] [blame] | 134 | jit_options->invoke_transition_weight_ = |
| 135 | *options.Get(RuntimeArgumentMap::JITInvokeTransitionWeight); |
Calin Juravle | 155ff3d | 2016-04-27 14:14:58 +0100 | [diff] [blame] | 136 | if (jit_options->invoke_transition_weight_ > jit_options->warmup_threshold_) { |
| 137 | LOG(FATAL) << "Invoke transition weight is above the warmup threshold."; |
| 138 | } else if (jit_options->invoke_transition_weight_ == 0) { |
Nicolas Geoffray | 7c9f3ba | 2016-05-06 16:52:36 +0100 | [diff] [blame] | 139 | LOG(FATAL) << "Invoke transition weight cannot be 0."; |
Calin Juravle | 155ff3d | 2016-04-27 14:14:58 +0100 | [diff] [blame] | 140 | } |
Calin Juravle | 155ff3d | 2016-04-27 14:14:58 +0100 | [diff] [blame] | 141 | } else { |
| 142 | jit_options->invoke_transition_weight_ = std::max( |
| 143 | jit_options->warmup_threshold_ / Jit::kDefaultInvokeTransitionWeightRatio, |
Mathieu Chartier | 6beced4 | 2016-11-15 15:51:31 -0800 | [diff] [blame] | 144 | static_cast<size_t>(1)); |
Calin Juravle | 155ff3d | 2016-04-27 14:14:58 +0100 | [diff] [blame] | 145 | } |
| 146 | |
Mathieu Chartier | e5f13e5 | 2015-02-24 09:37:21 -0800 | [diff] [blame] | 147 | return jit_options; |
| 148 | } |
| 149 | |
Vladimir Marko | a710d91 | 2017-09-12 14:56:07 +0100 | [diff] [blame] | 150 | bool Jit::ShouldUsePriorityThreadWeight(Thread* self) { |
| 151 | return self->IsJitSensitiveThread() && Runtime::Current()->InJankPerceptibleProcessState(); |
Calin Juravle | b2771b4 | 2016-04-07 17:09:25 +0100 | [diff] [blame] | 152 | } |
| 153 | |
Mathieu Chartier | a4885cb | 2015-03-09 15:38:54 -0700 | [diff] [blame] | 154 | void Jit::DumpInfo(std::ostream& os) { |
Nicolas Geoffray | bcd94c8 | 2016-03-03 13:23:33 +0000 | [diff] [blame] | 155 | code_cache_->Dump(os); |
Mathieu Chartier | a4885cb | 2015-03-09 15:38:54 -0700 | [diff] [blame] | 156 | cumulative_timings_.Dump(os); |
Nicolas Geoffray | a4f8154 | 2016-03-08 16:57:48 +0000 | [diff] [blame] | 157 | MutexLock mu(Thread::Current(), lock_); |
| 158 | memory_use_.PrintMemoryUse(os); |
Mathieu Chartier | a4885cb | 2015-03-09 15:38:54 -0700 | [diff] [blame] | 159 | } |
| 160 | |
Calin Juravle | b8e6999 | 2016-03-09 15:37:48 +0000 | [diff] [blame] | 161 | void Jit::DumpForSigQuit(std::ostream& os) { |
| 162 | DumpInfo(os); |
| 163 | ProfileSaver::DumpInstanceInfo(os); |
| 164 | } |
| 165 | |
Mathieu Chartier | a4885cb | 2015-03-09 15:38:54 -0700 | [diff] [blame] | 166 | void Jit::AddTimingLogger(const TimingLogger& logger) { |
| 167 | cumulative_timings_.AddLogger(logger); |
| 168 | } |
| 169 | |
Orion Hodson | ad28f5e | 2018-10-17 09:08:17 +0100 | [diff] [blame] | 170 | Jit::Jit(JitCodeCache* code_cache, JitOptions* options) |
| 171 | : code_cache_(code_cache), |
| 172 | options_(options), |
| 173 | cumulative_timings_("JIT timings"), |
| 174 | memory_use_("Memory used for compilation", 16), |
| 175 | lock_("JIT memory use lock") {} |
Mathieu Chartier | e5f13e5 | 2015-02-24 09:37:21 -0800 | [diff] [blame] | 176 | |
Orion Hodson | ad28f5e | 2018-10-17 09:08:17 +0100 | [diff] [blame] | 177 | Jit* Jit::Create(JitCodeCache* code_cache, JitOptions* options) { |
Nicolas Geoffray | a7edd0d | 2018-11-07 03:18:16 +0000 | [diff] [blame^] | 178 | if (jit_load_ == nullptr) { |
| 179 | LOG(WARNING) << "Not creating JIT: library not loaded"; |
Mathieu Chartier | e5f13e5 | 2015-02-24 09:37:21 -0800 | [diff] [blame] | 180 | return nullptr; |
| 181 | } |
Nicolas Geoffray | a7edd0d | 2018-11-07 03:18:16 +0000 | [diff] [blame^] | 182 | bool will_generate_debug_symbols = false; |
| 183 | jit_compiler_handle_ = (jit_load_)(&will_generate_debug_symbols); |
| 184 | if (jit_compiler_handle_ == nullptr) { |
| 185 | LOG(WARNING) << "Not creating JIT: failed to allocate a compiler"; |
| 186 | return nullptr; |
| 187 | } |
| 188 | std::unique_ptr<Jit> jit(new Jit(code_cache, options)); |
| 189 | jit->generate_debug_info_ = will_generate_debug_symbols; |
| 190 | |
| 191 | // With 'perf', we want a 1-1 mapping between an address and a method. |
| 192 | // We aren't able to keep method pointers live during the instrumentation method entry trampoline |
| 193 | // so we will just disable jit-gc if we are doing that. |
| 194 | code_cache->SetGarbageCollectCode(!jit->generate_debug_info_ && |
| 195 | !Runtime::Current()->GetInstrumentation()->AreExitStubsInstalled()); |
Orion Hodson | ad28f5e | 2018-10-17 09:08:17 +0100 | [diff] [blame] | 196 | |
Nicolas Geoffray | bcd94c8 | 2016-03-03 13:23:33 +0000 | [diff] [blame] | 197 | VLOG(jit) << "JIT created with initial_capacity=" |
Nicolas Geoffray | 0a3be16 | 2015-11-18 11:15:22 +0000 | [diff] [blame] | 198 | << PrettySize(options->GetCodeCacheInitialCapacity()) |
| 199 | << ", max_capacity=" << PrettySize(options->GetCodeCacheMaxCapacity()) |
Calin Juravle | 4d77b6a | 2015-12-01 18:38:09 +0000 | [diff] [blame] | 200 | << ", compile_threshold=" << options->GetCompileThreshold() |
Calin Juravle | 138dbff | 2016-06-28 19:36:58 +0100 | [diff] [blame] | 201 | << ", profile_saver_options=" << options->GetProfileSaverOptions(); |
Nicolas Geoffray | 274fe4a | 2016-04-12 16:33:24 +0100 | [diff] [blame] | 202 | |
Nicolas Geoffray | 274fe4a | 2016-04-12 16:33:24 +0100 | [diff] [blame] | 203 | jit->CreateThreadPool(); |
| 204 | |
| 205 | // Notify native debugger about the classes already loaded before the creation of the jit. |
| 206 | jit->DumpTypeInfoForLoadedTypes(Runtime::Current()->GetClassLinker()); |
Mathieu Chartier | e5f13e5 | 2015-02-24 09:37:21 -0800 | [diff] [blame] | 207 | return jit.release(); |
| 208 | } |
| 209 | |
Nicolas Geoffray | a7edd0d | 2018-11-07 03:18:16 +0000 | [diff] [blame^] | 210 | bool Jit::LoadCompilerLibrary(std::string* error_msg) { |
Mathieu Chartier | e5f13e5 | 2015-02-24 09:37:21 -0800 | [diff] [blame] | 211 | jit_library_handle_ = dlopen( |
| 212 | kIsDebugBuild ? "libartd-compiler.so" : "libart-compiler.so", RTLD_NOW); |
| 213 | if (jit_library_handle_ == nullptr) { |
| 214 | std::ostringstream oss; |
| 215 | oss << "JIT could not load libart-compiler.so: " << dlerror(); |
| 216 | *error_msg = oss.str(); |
| 217 | return false; |
| 218 | } |
Nicolas Geoffray | 5b82d33 | 2016-02-18 14:22:32 +0000 | [diff] [blame] | 219 | jit_load_ = reinterpret_cast<void* (*)(bool*)>(dlsym(jit_library_handle_, "jit_load")); |
Mathieu Chartier | e5f13e5 | 2015-02-24 09:37:21 -0800 | [diff] [blame] | 220 | if (jit_load_ == nullptr) { |
| 221 | dlclose(jit_library_handle_); |
| 222 | *error_msg = "JIT couldn't find jit_load entry point"; |
| 223 | return false; |
| 224 | } |
| 225 | jit_unload_ = reinterpret_cast<void (*)(void*)>( |
| 226 | dlsym(jit_library_handle_, "jit_unload")); |
| 227 | if (jit_unload_ == nullptr) { |
| 228 | dlclose(jit_library_handle_); |
| 229 | *error_msg = "JIT couldn't find jit_unload entry point"; |
| 230 | return false; |
| 231 | } |
Nicolas Geoffray | b331feb | 2016-02-05 16:51:53 +0000 | [diff] [blame] | 232 | jit_compile_method_ = reinterpret_cast<bool (*)(void*, ArtMethod*, Thread*, bool)>( |
Mathieu Chartier | e5f13e5 | 2015-02-24 09:37:21 -0800 | [diff] [blame] | 233 | dlsym(jit_library_handle_, "jit_compile_method")); |
| 234 | if (jit_compile_method_ == nullptr) { |
| 235 | dlclose(jit_library_handle_); |
| 236 | *error_msg = "JIT couldn't find jit_compile_method entry point"; |
| 237 | return false; |
| 238 | } |
Tamas Berghammer | fffbee4 | 2016-01-15 13:09:34 +0000 | [diff] [blame] | 239 | jit_types_loaded_ = reinterpret_cast<void (*)(void*, mirror::Class**, size_t)>( |
| 240 | dlsym(jit_library_handle_, "jit_types_loaded")); |
| 241 | if (jit_types_loaded_ == nullptr) { |
Tamas Berghammer | 160e6df | 2016-01-05 14:29:02 +0000 | [diff] [blame] | 242 | dlclose(jit_library_handle_); |
Tamas Berghammer | fffbee4 | 2016-01-15 13:09:34 +0000 | [diff] [blame] | 243 | *error_msg = "JIT couldn't find jit_types_loaded entry point"; |
Tamas Berghammer | 160e6df | 2016-01-05 14:29:02 +0000 | [diff] [blame] | 244 | return false; |
| 245 | } |
Mathieu Chartier | c1bc415 | 2016-03-24 17:22:52 -0700 | [diff] [blame] | 246 | return true; |
| 247 | } |
| 248 | |
Nicolas Geoffray | b331feb | 2016-02-05 16:51:53 +0000 | [diff] [blame] | 249 | bool Jit::CompileMethod(ArtMethod* method, Thread* self, bool osr) { |
Calin Juravle | ffc8707 | 2016-04-20 14:22:09 +0100 | [diff] [blame] | 250 | DCHECK(Runtime::Current()->UseJitCompilation()); |
Mathieu Chartier | e5f13e5 | 2015-02-24 09:37:21 -0800 | [diff] [blame] | 251 | DCHECK(!method->IsRuntimeMethod()); |
Nicolas Geoffray | d9994f0 | 2016-02-11 17:35:55 +0000 | [diff] [blame] | 252 | |
Alex Light | 0fa1786 | 2017-10-24 13:43:05 -0700 | [diff] [blame] | 253 | RuntimeCallbacks* cb = Runtime::Current()->GetRuntimeCallbacks(); |
Nicolas Geoffray | 73be1e8 | 2015-09-17 15:22:56 +0100 | [diff] [blame] | 254 | // Don't compile the method if it has breakpoints. |
Alex Light | 0fa1786 | 2017-10-24 13:43:05 -0700 | [diff] [blame] | 255 | if (cb->IsMethodBeingInspected(method) && !cb->IsMethodSafeToJit(method)) { |
| 256 | VLOG(jit) << "JIT not compiling " << method->PrettyMethod() |
| 257 | << " due to not being safe to jit according to runtime-callbacks. For example, there" |
| 258 | << " could be breakpoints in this method."; |
Mathieu Chartier | d856545 | 2015-03-26 09:41:50 -0700 | [diff] [blame] | 259 | return false; |
| 260 | } |
Nicolas Geoffray | 73be1e8 | 2015-09-17 15:22:56 +0100 | [diff] [blame] | 261 | |
| 262 | // Don't compile the method if we are supposed to be deoptimized. |
| 263 | instrumentation::Instrumentation* instrumentation = Runtime::Current()->GetInstrumentation(); |
| 264 | if (instrumentation->AreAllMethodsDeoptimized() || instrumentation->IsDeoptimized(method)) { |
David Sehr | 709b070 | 2016-10-13 09:12:37 -0700 | [diff] [blame] | 265 | VLOG(jit) << "JIT not compiling " << method->PrettyMethod() << " due to deoptimization"; |
Nicolas Geoffray | 73be1e8 | 2015-09-17 15:22:56 +0100 | [diff] [blame] | 266 | return false; |
| 267 | } |
| 268 | |
Nicolas Geoffray | d9994f0 | 2016-02-11 17:35:55 +0000 | [diff] [blame] | 269 | // If we get a request to compile a proxy method, we pass the actual Java method |
| 270 | // of that proxy method, as the compiler does not expect a proxy method. |
Andreas Gampe | 542451c | 2016-07-26 09:02:02 -0700 | [diff] [blame] | 271 | ArtMethod* method_to_compile = method->GetInterfaceMethodIfProxy(kRuntimePointerSize); |
Nicolas Geoffray | d9994f0 | 2016-02-11 17:35:55 +0000 | [diff] [blame] | 272 | if (!code_cache_->NotifyCompilationOf(method_to_compile, self, osr)) { |
Nicolas Geoffray | 73be1e8 | 2015-09-17 15:22:56 +0100 | [diff] [blame] | 273 | return false; |
| 274 | } |
Nicolas Geoffray | 71cd50f | 2016-04-14 15:00:33 +0100 | [diff] [blame] | 275 | |
| 276 | VLOG(jit) << "Compiling method " |
David Sehr | 709b070 | 2016-10-13 09:12:37 -0700 | [diff] [blame] | 277 | << ArtMethod::PrettyMethod(method_to_compile) |
Nicolas Geoffray | 71cd50f | 2016-04-14 15:00:33 +0100 | [diff] [blame] | 278 | << " osr=" << std::boolalpha << osr; |
Nicolas Geoffray | d9994f0 | 2016-02-11 17:35:55 +0000 | [diff] [blame] | 279 | bool success = jit_compile_method_(jit_compiler_handle_, method_to_compile, self, osr); |
buzbee | 454b3b6 | 2016-04-07 14:42:47 -0700 | [diff] [blame] | 280 | code_cache_->DoneCompiling(method_to_compile, self, osr); |
Nicolas Geoffray | 71cd50f | 2016-04-14 15:00:33 +0100 | [diff] [blame] | 281 | if (!success) { |
| 282 | VLOG(jit) << "Failed to compile method " |
David Sehr | 709b070 | 2016-10-13 09:12:37 -0700 | [diff] [blame] | 283 | << ArtMethod::PrettyMethod(method_to_compile) |
Nicolas Geoffray | 71cd50f | 2016-04-14 15:00:33 +0100 | [diff] [blame] | 284 | << " osr=" << std::boolalpha << osr; |
| 285 | } |
Andreas Gampe | 320ba91 | 2016-11-18 17:39:45 -0800 | [diff] [blame] | 286 | if (kIsDebugBuild) { |
| 287 | if (self->IsExceptionPending()) { |
| 288 | mirror::Throwable* exception = self->GetException(); |
| 289 | LOG(FATAL) << "No pending exception expected after compiling " |
| 290 | << ArtMethod::PrettyMethod(method) |
| 291 | << ": " |
| 292 | << exception->Dump(); |
| 293 | } |
| 294 | } |
Nicolas Geoffray | 73be1e8 | 2015-09-17 15:22:56 +0100 | [diff] [blame] | 295 | return success; |
Mathieu Chartier | e5f13e5 | 2015-02-24 09:37:21 -0800 | [diff] [blame] | 296 | } |
| 297 | |
| 298 | void Jit::CreateThreadPool() { |
Nicolas Geoffray | 274fe4a | 2016-04-12 16:33:24 +0100 | [diff] [blame] | 299 | // There is a DCHECK in the 'AddSamples' method to ensure the tread pool |
| 300 | // is not null when we instrument. |
Andreas Gampe | 4471e4f | 2017-01-30 16:40:49 +0000 | [diff] [blame] | 301 | |
| 302 | // We need peers as we may report the JIT thread, e.g., in the debugger. |
| 303 | constexpr bool kJitPoolNeedsPeers = true; |
| 304 | thread_pool_.reset(new ThreadPool("Jit thread pool", 1, kJitPoolNeedsPeers)); |
| 305 | |
Nicolas Geoffray | 47b9580 | 2018-05-16 15:42:17 +0100 | [diff] [blame] | 306 | thread_pool_->SetPthreadPriority(options_->GetThreadPoolPthreadPriority()); |
Nicolas Geoffray | 021c5f2 | 2016-12-16 11:22:05 +0000 | [diff] [blame] | 307 | Start(); |
Mathieu Chartier | e5f13e5 | 2015-02-24 09:37:21 -0800 | [diff] [blame] | 308 | } |
| 309 | |
| 310 | void Jit::DeleteThreadPool() { |
Nicolas Geoffray | 274fe4a | 2016-04-12 16:33:24 +0100 | [diff] [blame] | 311 | Thread* self = Thread::Current(); |
| 312 | DCHECK(Runtime::Current()->IsShuttingDown(self)); |
| 313 | if (thread_pool_ != nullptr) { |
Andreas Gampe | 0897e1c | 2017-05-16 08:36:56 -0700 | [diff] [blame] | 314 | std::unique_ptr<ThreadPool> pool; |
Nicolas Geoffray | 274fe4a | 2016-04-12 16:33:24 +0100 | [diff] [blame] | 315 | { |
| 316 | ScopedSuspendAll ssa(__FUNCTION__); |
| 317 | // Clear thread_pool_ field while the threads are suspended. |
| 318 | // A mutator in the 'AddSamples' method will check against it. |
Andreas Gampe | 0897e1c | 2017-05-16 08:36:56 -0700 | [diff] [blame] | 319 | pool = std::move(thread_pool_); |
Nicolas Geoffray | 274fe4a | 2016-04-12 16:33:24 +0100 | [diff] [blame] | 320 | } |
Andreas Gampe | 0897e1c | 2017-05-16 08:36:56 -0700 | [diff] [blame] | 321 | |
| 322 | // When running sanitized, let all tasks finish to not leak. Otherwise just clear the queue. |
Roland Levillain | 05e34f4 | 2018-05-24 13:19:05 +0000 | [diff] [blame] | 323 | if (!kRunningOnMemoryTool) { |
Andreas Gampe | 0897e1c | 2017-05-16 08:36:56 -0700 | [diff] [blame] | 324 | pool->StopWorkers(self); |
| 325 | pool->RemoveAllTasks(self); |
| 326 | } |
Nicolas Geoffray | 274fe4a | 2016-04-12 16:33:24 +0100 | [diff] [blame] | 327 | // We could just suspend all threads, but we know those threads |
| 328 | // will finish in a short period, so it's not worth adding a suspend logic |
| 329 | // here. Besides, this is only done for shutdown. |
Andreas Gampe | 0897e1c | 2017-05-16 08:36:56 -0700 | [diff] [blame] | 330 | pool->Wait(self, false, false); |
Mathieu Chartier | e5f13e5 | 2015-02-24 09:37:21 -0800 | [diff] [blame] | 331 | } |
| 332 | } |
| 333 | |
Calin Juravle | 4d77b6a | 2015-12-01 18:38:09 +0000 | [diff] [blame] | 334 | void Jit::StartProfileSaver(const std::string& filename, |
Calin Juravle | 77651c4 | 2017-03-03 18:04:02 -0800 | [diff] [blame] | 335 | const std::vector<std::string>& code_paths) { |
Nicolas Geoffray | 47b9580 | 2018-05-16 15:42:17 +0100 | [diff] [blame] | 336 | if (options_->GetSaveProfilingInfo()) { |
Orion Hodson | ad28f5e | 2018-10-17 09:08:17 +0100 | [diff] [blame] | 337 | ProfileSaver::Start(options_->GetProfileSaverOptions(), filename, code_cache_, code_paths); |
Calin Juravle | 31f2c15 | 2015-10-23 17:56:15 +0100 | [diff] [blame] | 338 | } |
Calin Juravle | 4d77b6a | 2015-12-01 18:38:09 +0000 | [diff] [blame] | 339 | } |
| 340 | |
| 341 | void Jit::StopProfileSaver() { |
Nicolas Geoffray | 47b9580 | 2018-05-16 15:42:17 +0100 | [diff] [blame] | 342 | if (options_->GetSaveProfilingInfo() && ProfileSaver::IsStarted()) { |
| 343 | ProfileSaver::Stop(options_->DumpJitInfoOnShutdown()); |
Calin Juravle | 31f2c15 | 2015-10-23 17:56:15 +0100 | [diff] [blame] | 344 | } |
| 345 | } |
| 346 | |
Siva Chandra | 05d2415 | 2016-01-05 17:43:17 -0800 | [diff] [blame] | 347 | bool Jit::JitAtFirstUse() { |
Nicolas Geoffray | 274fe4a | 2016-04-12 16:33:24 +0100 | [diff] [blame] | 348 | return HotMethodThreshold() == 0; |
Siva Chandra | 05d2415 | 2016-01-05 17:43:17 -0800 | [diff] [blame] | 349 | } |
| 350 | |
Nicolas Geoffray | 3512244 | 2016-03-02 12:05:30 +0000 | [diff] [blame] | 351 | bool Jit::CanInvokeCompiledCode(ArtMethod* method) { |
| 352 | return code_cache_->ContainsPc(method->GetEntryPointFromQuickCompiledCode()); |
| 353 | } |
| 354 | |
Mathieu Chartier | e5f13e5 | 2015-02-24 09:37:21 -0800 | [diff] [blame] | 355 | Jit::~Jit() { |
Nicolas Geoffray | 47b9580 | 2018-05-16 15:42:17 +0100 | [diff] [blame] | 356 | DCHECK(!options_->GetSaveProfilingInfo() || !ProfileSaver::IsStarted()); |
| 357 | if (options_->DumpJitInfoOnShutdown()) { |
Andreas Gampe | 3fec9ac | 2016-09-13 10:47:28 -0700 | [diff] [blame] | 358 | DumpInfo(LOG_STREAM(INFO)); |
Nicolas Geoffray | 4e92c3c | 2017-05-08 09:34:26 +0100 | [diff] [blame] | 359 | Runtime::Current()->DumpDeoptimizations(LOG_STREAM(INFO)); |
Mathieu Chartier | a4885cb | 2015-03-09 15:38:54 -0700 | [diff] [blame] | 360 | } |
Mathieu Chartier | e5f13e5 | 2015-02-24 09:37:21 -0800 | [diff] [blame] | 361 | DeleteThreadPool(); |
| 362 | if (jit_compiler_handle_ != nullptr) { |
| 363 | jit_unload_(jit_compiler_handle_); |
Mathieu Chartier | 72918ea | 2016-03-24 11:07:06 -0700 | [diff] [blame] | 364 | jit_compiler_handle_ = nullptr; |
Mathieu Chartier | e5f13e5 | 2015-02-24 09:37:21 -0800 | [diff] [blame] | 365 | } |
| 366 | if (jit_library_handle_ != nullptr) { |
| 367 | dlclose(jit_library_handle_); |
Mathieu Chartier | 72918ea | 2016-03-24 11:07:06 -0700 | [diff] [blame] | 368 | jit_library_handle_ = nullptr; |
Mathieu Chartier | e5f13e5 | 2015-02-24 09:37:21 -0800 | [diff] [blame] | 369 | } |
| 370 | } |
| 371 | |
Tamas Berghammer | 160e6df | 2016-01-05 14:29:02 +0000 | [diff] [blame] | 372 | void Jit::NewTypeLoadedIfUsingJit(mirror::Class* type) { |
Calin Juravle | ffc8707 | 2016-04-20 14:22:09 +0100 | [diff] [blame] | 373 | if (!Runtime::Current()->UseJitCompilation()) { |
| 374 | // No need to notify if we only use the JIT to save profiles. |
| 375 | return; |
| 376 | } |
Tamas Berghammer | 160e6df | 2016-01-05 14:29:02 +0000 | [diff] [blame] | 377 | jit::Jit* jit = Runtime::Current()->GetJit(); |
Nicolas Geoffray | a7edd0d | 2018-11-07 03:18:16 +0000 | [diff] [blame^] | 378 | if (jit->generate_debug_info_) { |
Tamas Berghammer | fffbee4 | 2016-01-15 13:09:34 +0000 | [diff] [blame] | 379 | DCHECK(jit->jit_types_loaded_ != nullptr); |
| 380 | jit->jit_types_loaded_(jit->jit_compiler_handle_, &type, 1); |
| 381 | } |
| 382 | } |
| 383 | |
| 384 | void Jit::DumpTypeInfoForLoadedTypes(ClassLinker* linker) { |
| 385 | struct CollectClasses : public ClassVisitor { |
Roland Levillain | bbc6e7e | 2018-08-24 16:58:47 +0100 | [diff] [blame] | 386 | bool operator()(ObjPtr<mirror::Class> klass) override REQUIRES_SHARED(Locks::mutator_lock_) { |
Mathieu Chartier | 28357fa | 2016-10-18 16:27:40 -0700 | [diff] [blame] | 387 | classes_.push_back(klass.Ptr()); |
Tamas Berghammer | fffbee4 | 2016-01-15 13:09:34 +0000 | [diff] [blame] | 388 | return true; |
| 389 | } |
Mathieu Chartier | 9b1c9b7 | 2016-02-02 10:09:58 -0800 | [diff] [blame] | 390 | std::vector<mirror::Class*> classes_; |
Tamas Berghammer | fffbee4 | 2016-01-15 13:09:34 +0000 | [diff] [blame] | 391 | }; |
| 392 | |
| 393 | if (generate_debug_info_) { |
| 394 | ScopedObjectAccess so(Thread::Current()); |
| 395 | |
| 396 | CollectClasses visitor; |
| 397 | linker->VisitClasses(&visitor); |
| 398 | jit_types_loaded_(jit_compiler_handle_, visitor.classes_.data(), visitor.classes_.size()); |
Tamas Berghammer | 160e6df | 2016-01-05 14:29:02 +0000 | [diff] [blame] | 399 | } |
| 400 | } |
| 401 | |
Nicolas Geoffray | b331feb | 2016-02-05 16:51:53 +0000 | [diff] [blame] | 402 | extern "C" void art_quick_osr_stub(void** stack, |
Evgenii Stepanov | 6d90fde | 2018-09-04 17:50:38 -0700 | [diff] [blame] | 403 | size_t stack_size_in_bytes, |
Nicolas Geoffray | b331feb | 2016-02-05 16:51:53 +0000 | [diff] [blame] | 404 | const uint8_t* native_pc, |
| 405 | JValue* result, |
| 406 | const char* shorty, |
| 407 | Thread* self); |
| 408 | |
| 409 | bool Jit::MaybeDoOnStackReplacement(Thread* thread, |
| 410 | ArtMethod* method, |
| 411 | uint32_t dex_pc, |
| 412 | int32_t dex_pc_offset, |
| 413 | JValue* result) { |
Nicolas Geoffray | e866213 | 2016-02-15 10:00:42 +0000 | [diff] [blame] | 414 | if (!kEnableOnStackReplacement) { |
| 415 | return false; |
| 416 | } |
| 417 | |
Nicolas Geoffray | b331feb | 2016-02-05 16:51:53 +0000 | [diff] [blame] | 418 | Jit* jit = Runtime::Current()->GetJit(); |
| 419 | if (jit == nullptr) { |
| 420 | return false; |
| 421 | } |
| 422 | |
Nicolas Geoffray | b88d59e | 2016-02-17 11:31:49 +0000 | [diff] [blame] | 423 | if (UNLIKELY(__builtin_frame_address(0) < thread->GetStackEnd())) { |
| 424 | // Don't attempt to do an OSR if we are close to the stack limit. Since |
| 425 | // the interpreter frames are still on stack, OSR has the potential |
| 426 | // to stack overflow even for a simple loop. |
| 427 | // b/27094810. |
| 428 | return false; |
| 429 | } |
| 430 | |
Nicolas Geoffray | d9bc433 | 2016-02-05 23:32:25 +0000 | [diff] [blame] | 431 | // Get the actual Java method if this method is from a proxy class. The compiler |
| 432 | // and the JIT code cache do not expect methods from proxy classes. |
Andreas Gampe | 542451c | 2016-07-26 09:02:02 -0700 | [diff] [blame] | 433 | method = method->GetInterfaceMethodIfProxy(kRuntimePointerSize); |
Nicolas Geoffray | d9bc433 | 2016-02-05 23:32:25 +0000 | [diff] [blame] | 434 | |
Nicolas Geoffray | b331feb | 2016-02-05 16:51:53 +0000 | [diff] [blame] | 435 | // Cheap check if the method has been compiled already. That's an indicator that we should |
| 436 | // osr into it. |
| 437 | if (!jit->GetCodeCache()->ContainsPc(method->GetEntryPointFromQuickCompiledCode())) { |
| 438 | return false; |
| 439 | } |
| 440 | |
Nicolas Geoffray | c0b2796 | 2016-02-16 12:06:05 +0000 | [diff] [blame] | 441 | // Fetch some data before looking up for an OSR method. We don't want thread |
| 442 | // suspension once we hold an OSR method, as the JIT code cache could delete the OSR |
| 443 | // method while we are being suspended. |
David Sehr | 0225f8e | 2018-01-31 08:52:24 +0000 | [diff] [blame] | 444 | CodeItemDataAccessor accessor(method->DexInstructionData()); |
Mathieu Chartier | 808c7a5 | 2017-12-15 11:19:33 -0800 | [diff] [blame] | 445 | const size_t number_of_vregs = accessor.RegistersSize(); |
Nicolas Geoffray | d186dd8 | 2016-02-16 10:03:44 +0000 | [diff] [blame] | 446 | const char* shorty = method->GetShorty(); |
David Sehr | 709b070 | 2016-10-13 09:12:37 -0700 | [diff] [blame] | 447 | std::string method_name(VLOG_IS_ON(jit) ? method->PrettyMethod() : ""); |
Nicolas Geoffray | d186dd8 | 2016-02-16 10:03:44 +0000 | [diff] [blame] | 448 | void** memory = nullptr; |
| 449 | size_t frame_size = 0; |
| 450 | ShadowFrame* shadow_frame = nullptr; |
| 451 | const uint8_t* native_pc = nullptr; |
Nicolas Geoffray | b331feb | 2016-02-05 16:51:53 +0000 | [diff] [blame] | 452 | |
Nicolas Geoffray | d186dd8 | 2016-02-16 10:03:44 +0000 | [diff] [blame] | 453 | { |
Mathieu Chartier | 268764d | 2016-09-13 12:09:38 -0700 | [diff] [blame] | 454 | ScopedAssertNoThreadSuspension sts("Holding OSR method"); |
Nicolas Geoffray | d186dd8 | 2016-02-16 10:03:44 +0000 | [diff] [blame] | 455 | const OatQuickMethodHeader* osr_method = jit->GetCodeCache()->LookupOsrMethodHeader(method); |
| 456 | if (osr_method == nullptr) { |
| 457 | // No osr method yet, just return to the interpreter. |
| 458 | return false; |
Nicolas Geoffray | b331feb | 2016-02-05 16:51:53 +0000 | [diff] [blame] | 459 | } |
Nicolas Geoffray | d186dd8 | 2016-02-16 10:03:44 +0000 | [diff] [blame] | 460 | |
David Srbecky | 052f8ca | 2018-04-26 15:42:54 +0100 | [diff] [blame] | 461 | CodeInfo code_info(osr_method); |
Nicolas Geoffray | d186dd8 | 2016-02-16 10:03:44 +0000 | [diff] [blame] | 462 | |
| 463 | // Find stack map starting at the target dex_pc. |
David Srbecky | 052f8ca | 2018-04-26 15:42:54 +0100 | [diff] [blame] | 464 | StackMap stack_map = code_info.GetOsrStackMapForDexPc(dex_pc + dex_pc_offset); |
Nicolas Geoffray | d186dd8 | 2016-02-16 10:03:44 +0000 | [diff] [blame] | 465 | if (!stack_map.IsValid()) { |
| 466 | // There is no OSR stack map for this dex pc offset. Just return to the interpreter in the |
| 467 | // hope that the next branch has one. |
| 468 | return false; |
| 469 | } |
| 470 | |
Alex Light | 2161193 | 2017-09-26 13:07:39 -0700 | [diff] [blame] | 471 | // Before allowing the jump, make sure no code is actively inspecting the method to avoid |
| 472 | // jumping from interpreter to OSR while e.g. single stepping. Note that we could selectively |
| 473 | // disable OSR when single stepping, but that's currently hard to know at this point. |
| 474 | if (Runtime::Current()->GetRuntimeCallbacks()->IsMethodBeingInspected(method)) { |
Aart Bik | 29bdaee | 2016-05-18 15:44:07 -0700 | [diff] [blame] | 475 | return false; |
| 476 | } |
| 477 | |
Nicolas Geoffray | d186dd8 | 2016-02-16 10:03:44 +0000 | [diff] [blame] | 478 | // We found a stack map, now fill the frame with dex register values from the interpreter's |
| 479 | // shadow frame. |
David Srbecky | fd89b07 | 2018-06-03 12:00:22 +0100 | [diff] [blame] | 480 | DexRegisterMap vreg_map = code_info.GetDexRegisterMapOf(stack_map); |
Nicolas Geoffray | d186dd8 | 2016-02-16 10:03:44 +0000 | [diff] [blame] | 481 | |
| 482 | frame_size = osr_method->GetFrameSizeInBytes(); |
| 483 | |
| 484 | // Allocate memory to put shadow frame values. The osr stub will copy that memory to |
| 485 | // stack. |
| 486 | // Note that we could pass the shadow frame to the stub, and let it copy the values there, |
| 487 | // but that is engineering complexity not worth the effort for something like OSR. |
| 488 | memory = reinterpret_cast<void**>(malloc(frame_size)); |
| 489 | CHECK(memory != nullptr); |
| 490 | memset(memory, 0, frame_size); |
| 491 | |
| 492 | // Art ABI: ArtMethod is at the bottom of the stack. |
| 493 | memory[0] = method; |
| 494 | |
| 495 | shadow_frame = thread->PopShadowFrame(); |
David Srbecky | fd89b07 | 2018-06-03 12:00:22 +0100 | [diff] [blame] | 496 | if (vreg_map.empty()) { |
Nicolas Geoffray | d186dd8 | 2016-02-16 10:03:44 +0000 | [diff] [blame] | 497 | // If we don't have a dex register map, then there are no live dex registers at |
| 498 | // this dex pc. |
| 499 | } else { |
David Srbecky | fd89b07 | 2018-06-03 12:00:22 +0100 | [diff] [blame] | 500 | DCHECK_EQ(vreg_map.size(), number_of_vregs); |
Nicolas Geoffray | d186dd8 | 2016-02-16 10:03:44 +0000 | [diff] [blame] | 501 | for (uint16_t vreg = 0; vreg < number_of_vregs; ++vreg) { |
David Srbecky | e140212 | 2018-06-13 18:20:45 +0100 | [diff] [blame] | 502 | DexRegisterLocation::Kind location = vreg_map[vreg].GetKind(); |
Nicolas Geoffray | d186dd8 | 2016-02-16 10:03:44 +0000 | [diff] [blame] | 503 | if (location == DexRegisterLocation::Kind::kNone) { |
Nicolas Geoffray | c0b2796 | 2016-02-16 12:06:05 +0000 | [diff] [blame] | 504 | // Dex register is dead or uninitialized. |
Nicolas Geoffray | d186dd8 | 2016-02-16 10:03:44 +0000 | [diff] [blame] | 505 | continue; |
| 506 | } |
| 507 | |
| 508 | if (location == DexRegisterLocation::Kind::kConstant) { |
| 509 | // We skip constants because the compiled code knows how to handle them. |
| 510 | continue; |
| 511 | } |
| 512 | |
David Srbecky | 7dc1178 | 2016-02-25 13:23:56 +0000 | [diff] [blame] | 513 | DCHECK_EQ(location, DexRegisterLocation::Kind::kInStack); |
Nicolas Geoffray | d186dd8 | 2016-02-16 10:03:44 +0000 | [diff] [blame] | 514 | |
| 515 | int32_t vreg_value = shadow_frame->GetVReg(vreg); |
David Srbecky | e140212 | 2018-06-13 18:20:45 +0100 | [diff] [blame] | 516 | int32_t slot_offset = vreg_map[vreg].GetStackOffsetInBytes(); |
Nicolas Geoffray | d186dd8 | 2016-02-16 10:03:44 +0000 | [diff] [blame] | 517 | DCHECK_LT(slot_offset, static_cast<int32_t>(frame_size)); |
| 518 | DCHECK_GT(slot_offset, 0); |
| 519 | (reinterpret_cast<int32_t*>(memory))[slot_offset / sizeof(int32_t)] = vreg_value; |
| 520 | } |
| 521 | } |
| 522 | |
David Srbecky | 052f8ca | 2018-04-26 15:42:54 +0100 | [diff] [blame] | 523 | native_pc = stack_map.GetNativePcOffset(kRuntimeISA) + |
David Srbecky | 09ed098 | 2016-02-12 21:58:43 +0000 | [diff] [blame] | 524 | osr_method->GetEntryPoint(); |
Nicolas Geoffray | d186dd8 | 2016-02-16 10:03:44 +0000 | [diff] [blame] | 525 | VLOG(jit) << "Jumping to " |
| 526 | << method_name |
| 527 | << "@" |
| 528 | << std::hex << reinterpret_cast<uintptr_t>(native_pc); |
Nicolas Geoffray | b331feb | 2016-02-05 16:51:53 +0000 | [diff] [blame] | 529 | } |
| 530 | |
Nicolas Geoffray | b331feb | 2016-02-05 16:51:53 +0000 | [diff] [blame] | 531 | { |
| 532 | ManagedStack fragment; |
| 533 | thread->PushManagedStackFragment(&fragment); |
| 534 | (*art_quick_osr_stub)(memory, |
| 535 | frame_size, |
| 536 | native_pc, |
| 537 | result, |
Nicolas Geoffray | d186dd8 | 2016-02-16 10:03:44 +0000 | [diff] [blame] | 538 | shorty, |
Nicolas Geoffray | b331feb | 2016-02-05 16:51:53 +0000 | [diff] [blame] | 539 | thread); |
Nicolas Geoffray | d186dd8 | 2016-02-16 10:03:44 +0000 | [diff] [blame] | 540 | |
Nicolas Geoffray | b331feb | 2016-02-05 16:51:53 +0000 | [diff] [blame] | 541 | if (UNLIKELY(thread->GetException() == Thread::GetDeoptimizationException())) { |
| 542 | thread->DeoptimizeWithDeoptimizationException(result); |
| 543 | } |
| 544 | thread->PopManagedStackFragment(fragment); |
| 545 | } |
| 546 | free(memory); |
| 547 | thread->PushShadowFrame(shadow_frame); |
Nicolas Geoffray | d186dd8 | 2016-02-16 10:03:44 +0000 | [diff] [blame] | 548 | VLOG(jit) << "Done running OSR code for " << method_name; |
Nicolas Geoffray | b331feb | 2016-02-05 16:51:53 +0000 | [diff] [blame] | 549 | return true; |
| 550 | } |
| 551 | |
Nicolas Geoffray | a4f8154 | 2016-03-08 16:57:48 +0000 | [diff] [blame] | 552 | void Jit::AddMemoryUsage(ArtMethod* method, size_t bytes) { |
| 553 | if (bytes > 4 * MB) { |
| 554 | LOG(INFO) << "Compiler allocated " |
| 555 | << PrettySize(bytes) |
| 556 | << " to compile " |
David Sehr | 709b070 | 2016-10-13 09:12:37 -0700 | [diff] [blame] | 557 | << ArtMethod::PrettyMethod(method); |
Nicolas Geoffray | a4f8154 | 2016-03-08 16:57:48 +0000 | [diff] [blame] | 558 | } |
| 559 | MutexLock mu(Thread::Current(), lock_); |
| 560 | memory_use_.AddValue(bytes); |
| 561 | } |
| 562 | |
Roland Levillain | bbc6e7e | 2018-08-24 16:58:47 +0100 | [diff] [blame] | 563 | class JitCompileTask final : public Task { |
Nicolas Geoffray | 274fe4a | 2016-04-12 16:33:24 +0100 | [diff] [blame] | 564 | public: |
| 565 | enum TaskKind { |
| 566 | kAllocateProfile, |
| 567 | kCompile, |
| 568 | kCompileOsr |
| 569 | }; |
| 570 | |
| 571 | JitCompileTask(ArtMethod* method, TaskKind kind) : method_(method), kind_(kind) { |
| 572 | ScopedObjectAccess soa(Thread::Current()); |
| 573 | // Add a global ref to the class to prevent class unloading until compilation is done. |
| 574 | klass_ = soa.Vm()->AddGlobalRef(soa.Self(), method_->GetDeclaringClass()); |
| 575 | CHECK(klass_ != nullptr); |
| 576 | } |
| 577 | |
| 578 | ~JitCompileTask() { |
| 579 | ScopedObjectAccess soa(Thread::Current()); |
| 580 | soa.Vm()->DeleteGlobalRef(soa.Self(), klass_); |
| 581 | } |
| 582 | |
Roland Levillain | bbc6e7e | 2018-08-24 16:58:47 +0100 | [diff] [blame] | 583 | void Run(Thread* self) override { |
Nicolas Geoffray | 274fe4a | 2016-04-12 16:33:24 +0100 | [diff] [blame] | 584 | ScopedObjectAccess soa(self); |
| 585 | if (kind_ == kCompile) { |
Andreas Gampe | 98ea9d9 | 2018-10-19 14:06:15 -0700 | [diff] [blame] | 586 | Runtime::Current()->GetJit()->CompileMethod(method_, self, /* osr= */ false); |
Nicolas Geoffray | 274fe4a | 2016-04-12 16:33:24 +0100 | [diff] [blame] | 587 | } else if (kind_ == kCompileOsr) { |
Andreas Gampe | 98ea9d9 | 2018-10-19 14:06:15 -0700 | [diff] [blame] | 588 | Runtime::Current()->GetJit()->CompileMethod(method_, self, /* osr= */ true); |
Nicolas Geoffray | 274fe4a | 2016-04-12 16:33:24 +0100 | [diff] [blame] | 589 | } else { |
| 590 | DCHECK(kind_ == kAllocateProfile); |
Andreas Gampe | 98ea9d9 | 2018-10-19 14:06:15 -0700 | [diff] [blame] | 591 | if (ProfilingInfo::Create(self, method_, /* retry_allocation= */ true)) { |
David Sehr | 709b070 | 2016-10-13 09:12:37 -0700 | [diff] [blame] | 592 | VLOG(jit) << "Start profiling " << ArtMethod::PrettyMethod(method_); |
Nicolas Geoffray | 274fe4a | 2016-04-12 16:33:24 +0100 | [diff] [blame] | 593 | } |
| 594 | } |
Calin Juravle | a263892 | 2016-04-29 16:44:11 +0100 | [diff] [blame] | 595 | ProfileSaver::NotifyJitActivity(); |
Nicolas Geoffray | 274fe4a | 2016-04-12 16:33:24 +0100 | [diff] [blame] | 596 | } |
| 597 | |
Roland Levillain | bbc6e7e | 2018-08-24 16:58:47 +0100 | [diff] [blame] | 598 | void Finalize() override { |
Nicolas Geoffray | 274fe4a | 2016-04-12 16:33:24 +0100 | [diff] [blame] | 599 | delete this; |
| 600 | } |
| 601 | |
| 602 | private: |
| 603 | ArtMethod* const method_; |
| 604 | const TaskKind kind_; |
| 605 | jobject klass_; |
| 606 | |
| 607 | DISALLOW_IMPLICIT_CONSTRUCTORS(JitCompileTask); |
| 608 | }; |
| 609 | |
Orion Hodson | 52f5a1f | 2018-05-02 11:05:44 +0100 | [diff] [blame] | 610 | static bool IgnoreSamplesForMethod(ArtMethod* method) REQUIRES_SHARED(Locks::mutator_lock_) { |
| 611 | if (method->IsClassInitializer() || !method->IsCompilable()) { |
| 612 | // We do not want to compile such methods. |
| 613 | return true; |
| 614 | } |
| 615 | if (method->IsNative()) { |
| 616 | ObjPtr<mirror::Class> klass = method->GetDeclaringClass(); |
Vladimir Marko | c7aa87e | 2018-05-24 15:19:52 +0100 | [diff] [blame] | 617 | if (klass == GetClassRoot<mirror::MethodHandle>() || |
| 618 | klass == GetClassRoot<mirror::VarHandle>()) { |
Orion Hodson | 52f5a1f | 2018-05-02 11:05:44 +0100 | [diff] [blame] | 619 | // MethodHandle and VarHandle invocation methods are required to throw an |
| 620 | // UnsupportedOperationException if invoked reflectively. We achieve this by having native |
| 621 | // implementations that arise the exception. We need to disable JIT compilation of these JNI |
| 622 | // methods as it can lead to transitioning between JIT compiled JNI stubs and generic JNI |
| 623 | // stubs. Since these stubs have different stack representations we can then crash in stack |
| 624 | // walking (b/78151261). |
| 625 | return true; |
| 626 | } |
| 627 | } |
| 628 | return false; |
| 629 | } |
| 630 | |
Nicolas Geoffray | 71cd50f | 2016-04-14 15:00:33 +0100 | [diff] [blame] | 631 | void Jit::AddSamples(Thread* self, ArtMethod* method, uint16_t count, bool with_backedges) { |
Nicolas Geoffray | 274fe4a | 2016-04-12 16:33:24 +0100 | [diff] [blame] | 632 | if (thread_pool_ == nullptr) { |
| 633 | // Should only see this when shutting down. |
| 634 | DCHECK(Runtime::Current()->IsShuttingDown(self)); |
| 635 | return; |
| 636 | } |
Orion Hodson | 52f5a1f | 2018-05-02 11:05:44 +0100 | [diff] [blame] | 637 | if (IgnoreSamplesForMethod(method)) { |
Nicolas Geoffray | 274fe4a | 2016-04-12 16:33:24 +0100 | [diff] [blame] | 638 | return; |
| 639 | } |
Nicolas Geoffray | 47b9580 | 2018-05-16 15:42:17 +0100 | [diff] [blame] | 640 | if (HotMethodThreshold() == 0) { |
David Srbecky | f4886df | 2017-12-11 16:06:29 +0000 | [diff] [blame] | 641 | // Tests might request JIT on first use (compiled synchronously in the interpreter). |
| 642 | return; |
| 643 | } |
Nicolas Geoffray | 274fe4a | 2016-04-12 16:33:24 +0100 | [diff] [blame] | 644 | DCHECK(thread_pool_ != nullptr); |
Nicolas Geoffray | 47b9580 | 2018-05-16 15:42:17 +0100 | [diff] [blame] | 645 | DCHECK_GT(WarmMethodThreshold(), 0); |
| 646 | DCHECK_GT(HotMethodThreshold(), WarmMethodThreshold()); |
| 647 | DCHECK_GT(OSRMethodThreshold(), HotMethodThreshold()); |
| 648 | DCHECK_GE(PriorityThreadWeight(), 1); |
| 649 | DCHECK_LE(PriorityThreadWeight(), HotMethodThreshold()); |
Nicolas Geoffray | 274fe4a | 2016-04-12 16:33:24 +0100 | [diff] [blame] | 650 | |
Nicolas Geoffray | 47b9580 | 2018-05-16 15:42:17 +0100 | [diff] [blame] | 651 | uint16_t starting_count = method->GetCounter(); |
Vladimir Marko | a710d91 | 2017-09-12 14:56:07 +0100 | [diff] [blame] | 652 | if (Jit::ShouldUsePriorityThreadWeight(self)) { |
Nicolas Geoffray | 47b9580 | 2018-05-16 15:42:17 +0100 | [diff] [blame] | 653 | count *= PriorityThreadWeight(); |
Nicolas Geoffray | 274fe4a | 2016-04-12 16:33:24 +0100 | [diff] [blame] | 654 | } |
Nicolas Geoffray | 47b9580 | 2018-05-16 15:42:17 +0100 | [diff] [blame] | 655 | uint32_t new_count = starting_count + count; |
Vladimir Marko | 2196c65 | 2017-11-30 16:16:07 +0000 | [diff] [blame] | 656 | // Note: Native method have no "warm" state or profiling info. |
Nicolas Geoffray | 47b9580 | 2018-05-16 15:42:17 +0100 | [diff] [blame] | 657 | if (LIKELY(!method->IsNative()) && starting_count < WarmMethodThreshold()) { |
| 658 | if ((new_count >= WarmMethodThreshold()) && |
Nicolas Geoffray | 941c6ec | 2017-06-09 11:53:23 +0000 | [diff] [blame] | 659 | (method->GetProfilingInfo(kRuntimePointerSize) == nullptr)) { |
Andreas Gampe | 98ea9d9 | 2018-10-19 14:06:15 -0700 | [diff] [blame] | 660 | bool success = ProfilingInfo::Create(self, method, /* retry_allocation= */ false); |
Nicolas Geoffray | 941c6ec | 2017-06-09 11:53:23 +0000 | [diff] [blame] | 661 | if (success) { |
| 662 | VLOG(jit) << "Start profiling " << method->PrettyMethod(); |
| 663 | } |
Nicolas Geoffray | 274fe4a | 2016-04-12 16:33:24 +0100 | [diff] [blame] | 664 | |
Nicolas Geoffray | 941c6ec | 2017-06-09 11:53:23 +0000 | [diff] [blame] | 665 | if (thread_pool_ == nullptr) { |
| 666 | // Calling ProfilingInfo::Create might put us in a suspended state, which could |
| 667 | // lead to the thread pool being deleted when we are shutting down. |
| 668 | DCHECK(Runtime::Current()->IsShuttingDown(self)); |
| 669 | return; |
| 670 | } |
Nicolas Geoffray | 274fe4a | 2016-04-12 16:33:24 +0100 | [diff] [blame] | 671 | |
Nicolas Geoffray | 941c6ec | 2017-06-09 11:53:23 +0000 | [diff] [blame] | 672 | if (!success) { |
| 673 | // We failed allocating. Instead of doing the collection on the Java thread, we push |
| 674 | // an allocation to a compiler thread, that will do the collection. |
| 675 | thread_pool_->AddTask(self, new JitCompileTask(method, JitCompileTask::kAllocateProfile)); |
| 676 | } |
Nicolas Geoffray | 274fe4a | 2016-04-12 16:33:24 +0100 | [diff] [blame] | 677 | } |
| 678 | // Avoid jumping more than one state at a time. |
Nicolas Geoffray | 47b9580 | 2018-05-16 15:42:17 +0100 | [diff] [blame] | 679 | new_count = std::min(new_count, static_cast<uint32_t>(HotMethodThreshold() - 1)); |
| 680 | } else if (UseJitCompilation()) { |
| 681 | if (starting_count < HotMethodThreshold()) { |
| 682 | if ((new_count >= HotMethodThreshold()) && |
Calin Juravle | ffc8707 | 2016-04-20 14:22:09 +0100 | [diff] [blame] | 683 | !code_cache_->ContainsPc(method->GetEntryPointFromQuickCompiledCode())) { |
| 684 | DCHECK(thread_pool_ != nullptr); |
| 685 | thread_pool_->AddTask(self, new JitCompileTask(method, JitCompileTask::kCompile)); |
| 686 | } |
| 687 | // Avoid jumping more than one state at a time. |
Nicolas Geoffray | 47b9580 | 2018-05-16 15:42:17 +0100 | [diff] [blame] | 688 | new_count = std::min(new_count, static_cast<uint32_t>(OSRMethodThreshold() - 1)); |
| 689 | } else if (starting_count < OSRMethodThreshold()) { |
Calin Juravle | ffc8707 | 2016-04-20 14:22:09 +0100 | [diff] [blame] | 690 | if (!with_backedges) { |
| 691 | // If the samples don't contain any back edge, we don't increment the hotness. |
| 692 | return; |
| 693 | } |
Vladimir Marko | 2196c65 | 2017-11-30 16:16:07 +0000 | [diff] [blame] | 694 | DCHECK(!method->IsNative()); // No back edges reported for native methods. |
Nicolas Geoffray | 47b9580 | 2018-05-16 15:42:17 +0100 | [diff] [blame] | 695 | if ((new_count >= OSRMethodThreshold()) && !code_cache_->IsOsrCompiled(method)) { |
Calin Juravle | ffc8707 | 2016-04-20 14:22:09 +0100 | [diff] [blame] | 696 | DCHECK(thread_pool_ != nullptr); |
| 697 | thread_pool_->AddTask(self, new JitCompileTask(method, JitCompileTask::kCompileOsr)); |
| 698 | } |
Nicolas Geoffray | 274fe4a | 2016-04-12 16:33:24 +0100 | [diff] [blame] | 699 | } |
| 700 | } |
| 701 | // Update hotness counter |
| 702 | method->SetCounter(new_count); |
| 703 | } |
| 704 | |
Alex Light | 59b950f | 2018-10-08 10:43:06 -0700 | [diff] [blame] | 705 | class ScopedSetRuntimeThread { |
| 706 | public: |
| 707 | explicit ScopedSetRuntimeThread(Thread* self) |
| 708 | : self_(self), was_runtime_thread_(self_->IsRuntimeThread()) { |
| 709 | self_->SetIsRuntimeThread(true); |
| 710 | } |
| 711 | |
| 712 | ~ScopedSetRuntimeThread() { |
| 713 | self_->SetIsRuntimeThread(was_runtime_thread_); |
| 714 | } |
| 715 | |
| 716 | private: |
| 717 | Thread* self_; |
| 718 | bool was_runtime_thread_; |
| 719 | }; |
| 720 | |
Nicolas Geoffray | 274fe4a | 2016-04-12 16:33:24 +0100 | [diff] [blame] | 721 | void Jit::MethodEntered(Thread* thread, ArtMethod* method) { |
Calin Juravle | ffc8707 | 2016-04-20 14:22:09 +0100 | [diff] [blame] | 722 | Runtime* runtime = Runtime::Current(); |
| 723 | if (UNLIKELY(runtime->UseJitCompilation() && runtime->GetJit()->JitAtFirstUse())) { |
Vladimir Marko | be0c7cf | 2018-03-19 13:40:56 +0000 | [diff] [blame] | 724 | ArtMethod* np_method = method->GetInterfaceMethodIfProxy(kRuntimePointerSize); |
Vladimir Marko | be0c7cf | 2018-03-19 13:40:56 +0000 | [diff] [blame] | 725 | if (np_method->IsCompilable()) { |
Vladimir Marko | f8655b3 | 2018-03-21 17:53:56 +0000 | [diff] [blame] | 726 | if (!np_method->IsNative()) { |
| 727 | // The compiler requires a ProfilingInfo object for non-native methods. |
Andreas Gampe | 98ea9d9 | 2018-10-19 14:06:15 -0700 | [diff] [blame] | 728 | ProfilingInfo::Create(thread, np_method, /* retry_allocation= */ true); |
Vladimir Marko | f8655b3 | 2018-03-21 17:53:56 +0000 | [diff] [blame] | 729 | } |
Vladimir Marko | be0c7cf | 2018-03-19 13:40:56 +0000 | [diff] [blame] | 730 | JitCompileTask compile_task(method, JitCompileTask::kCompile); |
Alex Light | 59b950f | 2018-10-08 10:43:06 -0700 | [diff] [blame] | 731 | // Fake being in a runtime thread so that class-load behavior will be the same as normal jit. |
| 732 | ScopedSetRuntimeThread ssrt(thread); |
Vladimir Marko | be0c7cf | 2018-03-19 13:40:56 +0000 | [diff] [blame] | 733 | compile_task.Run(thread); |
| 734 | } |
Nicolas Geoffray | 274fe4a | 2016-04-12 16:33:24 +0100 | [diff] [blame] | 735 | return; |
| 736 | } |
| 737 | |
Andreas Gampe | 542451c | 2016-07-26 09:02:02 -0700 | [diff] [blame] | 738 | ProfilingInfo* profiling_info = method->GetProfilingInfo(kRuntimePointerSize); |
Nicolas Geoffray | 274fe4a | 2016-04-12 16:33:24 +0100 | [diff] [blame] | 739 | // Update the entrypoint if the ProfilingInfo has one. The interpreter will call it |
Alex Light | 2d441b1 | 2018-06-08 15:33:21 -0700 | [diff] [blame] | 740 | // instead of interpreting the method. We don't update it for instrumentation as the entrypoint |
| 741 | // must remain the instrumentation entrypoint. |
| 742 | if ((profiling_info != nullptr) && |
| 743 | (profiling_info->GetSavedEntryPoint() != nullptr) && |
| 744 | (method->GetEntryPointFromQuickCompiledCode() != GetQuickInstrumentationEntryPoint())) { |
Nicolas Geoffray | 480d510 | 2016-04-18 12:09:30 +0100 | [diff] [blame] | 745 | Runtime::Current()->GetInstrumentation()->UpdateMethodsCode( |
| 746 | method, profiling_info->GetSavedEntryPoint()); |
Nicolas Geoffray | 274fe4a | 2016-04-12 16:33:24 +0100 | [diff] [blame] | 747 | } else { |
Andreas Gampe | 98ea9d9 | 2018-10-19 14:06:15 -0700 | [diff] [blame] | 748 | AddSamples(thread, method, 1, /* with_backedges= */false); |
Nicolas Geoffray | 274fe4a | 2016-04-12 16:33:24 +0100 | [diff] [blame] | 749 | } |
| 750 | } |
| 751 | |
Mathieu Chartier | ef41db7 | 2016-10-25 15:08:01 -0700 | [diff] [blame] | 752 | void Jit::InvokeVirtualOrInterface(ObjPtr<mirror::Object> this_object, |
Nicolas Geoffray | 274fe4a | 2016-04-12 16:33:24 +0100 | [diff] [blame] | 753 | ArtMethod* caller, |
| 754 | uint32_t dex_pc, |
| 755 | ArtMethod* callee ATTRIBUTE_UNUSED) { |
Mathieu Chartier | 268764d | 2016-09-13 12:09:38 -0700 | [diff] [blame] | 756 | ScopedAssertNoThreadSuspension ants(__FUNCTION__); |
Nicolas Geoffray | 274fe4a | 2016-04-12 16:33:24 +0100 | [diff] [blame] | 757 | DCHECK(this_object != nullptr); |
Andreas Gampe | 542451c | 2016-07-26 09:02:02 -0700 | [diff] [blame] | 758 | ProfilingInfo* info = caller->GetProfilingInfo(kRuntimePointerSize); |
Nicolas Geoffray | 274fe4a | 2016-04-12 16:33:24 +0100 | [diff] [blame] | 759 | if (info != nullptr) { |
Nicolas Geoffray | 274fe4a | 2016-04-12 16:33:24 +0100 | [diff] [blame] | 760 | info->AddInvokeInfo(dex_pc, this_object->GetClass()); |
| 761 | } |
| 762 | } |
| 763 | |
| 764 | void Jit::WaitForCompilationToFinish(Thread* self) { |
| 765 | if (thread_pool_ != nullptr) { |
| 766 | thread_pool_->Wait(self, false, false); |
| 767 | } |
| 768 | } |
| 769 | |
Nicolas Geoffray | 021c5f2 | 2016-12-16 11:22:05 +0000 | [diff] [blame] | 770 | void Jit::Stop() { |
| 771 | Thread* self = Thread::Current(); |
| 772 | // TODO(ngeoffray): change API to not require calling WaitForCompilationToFinish twice. |
| 773 | WaitForCompilationToFinish(self); |
| 774 | GetThreadPool()->StopWorkers(self); |
| 775 | WaitForCompilationToFinish(self); |
| 776 | } |
| 777 | |
| 778 | void Jit::Start() { |
David Srbecky | d25eb2c | 2018-07-19 12:17:04 +0000 | [diff] [blame] | 779 | GetThreadPool()->StartWorkers(Thread::Current()); |
Nicolas Geoffray | 021c5f2 | 2016-12-16 11:22:05 +0000 | [diff] [blame] | 780 | } |
| 781 | |
Andreas Gampe | f149b3f | 2016-11-16 14:58:24 -0800 | [diff] [blame] | 782 | ScopedJitSuspend::ScopedJitSuspend() { |
| 783 | jit::Jit* jit = Runtime::Current()->GetJit(); |
| 784 | was_on_ = (jit != nullptr) && (jit->GetThreadPool() != nullptr); |
| 785 | if (was_on_) { |
Nicolas Geoffray | 021c5f2 | 2016-12-16 11:22:05 +0000 | [diff] [blame] | 786 | jit->Stop(); |
Andreas Gampe | f149b3f | 2016-11-16 14:58:24 -0800 | [diff] [blame] | 787 | } |
| 788 | } |
| 789 | |
| 790 | ScopedJitSuspend::~ScopedJitSuspend() { |
| 791 | if (was_on_) { |
| 792 | DCHECK(Runtime::Current()->GetJit() != nullptr); |
| 793 | DCHECK(Runtime::Current()->GetJit()->GetThreadPool() != nullptr); |
Nicolas Geoffray | 021c5f2 | 2016-12-16 11:22:05 +0000 | [diff] [blame] | 794 | Runtime::Current()->GetJit()->Start(); |
Andreas Gampe | f149b3f | 2016-11-16 14:58:24 -0800 | [diff] [blame] | 795 | } |
| 796 | } |
| 797 | |
Mathieu Chartier | e5f13e5 | 2015-02-24 09:37:21 -0800 | [diff] [blame] | 798 | } // namespace jit |
| 799 | } // namespace art |