blob: 5bd9a6b76b267b5f8806d2c95cfb418b8f431664 [file] [log] [blame]
Mathieu Chartiere5f13e52015-02-24 09:37:21 -08001/*
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 Chartiere401d142015-04-22 13:56:20 -070021#include "art_method-inl.h"
Andreas Gampe2a5c4682015-08-14 08:22:54 -070022#include "debugger.h"
Mathieu Chartiere5f13e52015-02-24 09:37:21 -080023#include "entrypoints/runtime_asm_entrypoints.h"
24#include "interpreter/interpreter.h"
25#include "jit_code_cache.h"
26#include "jit_instrumentation.h"
Calin Juravle31f2c152015-10-23 17:56:15 +010027#include "oat_file_manager.h"
Nicolas Geoffrayb331feb2016-02-05 16:51:53 +000028#include "oat_quick_method_header.h"
Calin Juravle31f2c152015-10-23 17:56:15 +010029#include "offline_profiling_info.h"
Calin Juravle4d77b6a2015-12-01 18:38:09 +000030#include "profile_saver.h"
Mathieu Chartiere5f13e52015-02-24 09:37:21 -080031#include "runtime.h"
32#include "runtime_options.h"
Nicolas Geoffrayb331feb2016-02-05 16:51:53 +000033#include "stack_map.h"
Mathieu Chartiere5f13e52015-02-24 09:37:21 -080034#include "utils.h"
35
36namespace art {
37namespace jit {
38
Nicolas Geoffrayd186dd82016-02-16 10:03:44 +000039static constexpr bool kEnableOnStackReplacement = true;
Nicolas Geoffraye8662132016-02-15 10:00:42 +000040
Mathieu Chartiere5f13e52015-02-24 09:37:21 -080041JitOptions* JitOptions::CreateFromRuntimeArguments(const RuntimeArgumentMap& options) {
Mathieu Chartiere5f13e52015-02-24 09:37:21 -080042 auto* jit_options = new JitOptions;
Mathieu Chartier455f67c2015-03-17 13:48:29 -070043 jit_options->use_jit_ = options.GetOrDefault(RuntimeArgumentMap::UseJIT);
Nicolas Geoffray83f080a2016-03-08 16:50:21 +000044
Nicolas Geoffray0a3be162015-11-18 11:15:22 +000045 jit_options->code_cache_initial_capacity_ =
46 options.GetOrDefault(RuntimeArgumentMap::JITCodeCacheInitialCapacity);
47 jit_options->code_cache_max_capacity_ =
48 options.GetOrDefault(RuntimeArgumentMap::JITCodeCacheMaxCapacity);
Mathieu Chartiera4885cb2015-03-09 15:38:54 -070049 jit_options->dump_info_on_shutdown_ =
50 options.Exists(RuntimeArgumentMap::DumpJITInfoOnShutdown);
Calin Juravle31f2c152015-10-23 17:56:15 +010051 jit_options->save_profiling_info_ =
Nicolas Geoffray83f080a2016-03-08 16:50:21 +000052 options.GetOrDefault(RuntimeArgumentMap::JITSaveProfilingInfo);
53
54 jit_options->compile_threshold_ = options.GetOrDefault(RuntimeArgumentMap::JITCompileThreshold);
55 if (jit_options->compile_threshold_ > std::numeric_limits<uint16_t>::max()) {
56 LOG(FATAL) << "Method compilation threshold is above its internal limit.";
57 }
58
59 if (options.Exists(RuntimeArgumentMap::JITWarmupThreshold)) {
60 jit_options->warmup_threshold_ = *options.Get(RuntimeArgumentMap::JITWarmupThreshold);
61 if (jit_options->warmup_threshold_ > std::numeric_limits<uint16_t>::max()) {
62 LOG(FATAL) << "Method warmup threshold is above its internal limit.";
63 }
64 } else {
65 jit_options->warmup_threshold_ = jit_options->compile_threshold_ / 2;
66 }
67
68 if (options.Exists(RuntimeArgumentMap::JITOsrThreshold)) {
69 jit_options->osr_threshold_ = *options.Get(RuntimeArgumentMap::JITOsrThreshold);
70 if (jit_options->osr_threshold_ > std::numeric_limits<uint16_t>::max()) {
71 LOG(FATAL) << "Method on stack replacement threshold is above its internal limit.";
72 }
73 } else {
74 jit_options->osr_threshold_ = jit_options->compile_threshold_ * 2;
75 if (jit_options->osr_threshold_ > std::numeric_limits<uint16_t>::max()) {
76 jit_options->osr_threshold_ = std::numeric_limits<uint16_t>::max();
77 }
78 }
79
Mathieu Chartiere5f13e52015-02-24 09:37:21 -080080 return jit_options;
81}
82
Mathieu Chartiera4885cb2015-03-09 15:38:54 -070083void Jit::DumpInfo(std::ostream& os) {
Nicolas Geoffraybcd94c82016-03-03 13:23:33 +000084 code_cache_->Dump(os);
Mathieu Chartiera4885cb2015-03-09 15:38:54 -070085 cumulative_timings_.Dump(os);
86}
87
88void Jit::AddTimingLogger(const TimingLogger& logger) {
89 cumulative_timings_.AddLogger(logger);
90}
91
Nicolas Geoffraya25dce92016-01-12 16:41:10 +000092Jit::Jit() : jit_library_handle_(nullptr),
93 jit_compiler_handle_(nullptr),
94 jit_load_(nullptr),
95 jit_compile_method_(nullptr),
96 dump_info_on_shutdown_(false),
97 cumulative_timings_("JIT timings"),
98 save_profiling_info_(false),
99 generate_debug_info_(false) {
Mathieu Chartiere5f13e52015-02-24 09:37:21 -0800100}
101
102Jit* Jit::Create(JitOptions* options, std::string* error_msg) {
103 std::unique_ptr<Jit> jit(new Jit);
Mathieu Chartiera4885cb2015-03-09 15:38:54 -0700104 jit->dump_info_on_shutdown_ = options->DumpJitInfoOnShutdown();
Mathieu Chartiere5f13e52015-02-24 09:37:21 -0800105 if (!jit->LoadCompiler(error_msg)) {
106 return nullptr;
107 }
Nicolas Geoffray0a3be162015-11-18 11:15:22 +0000108 jit->code_cache_.reset(JitCodeCache::Create(
Nicolas Geoffraya25dce92016-01-12 16:41:10 +0000109 options->GetCodeCacheInitialCapacity(),
110 options->GetCodeCacheMaxCapacity(),
111 jit->generate_debug_info_,
112 error_msg));
Mathieu Chartiere5f13e52015-02-24 09:37:21 -0800113 if (jit->GetCodeCache() == nullptr) {
114 return nullptr;
115 }
Calin Juravle4d77b6a2015-12-01 18:38:09 +0000116 jit->save_profiling_info_ = options->GetSaveProfilingInfo();
Nicolas Geoffraybcd94c82016-03-03 13:23:33 +0000117 VLOG(jit) << "JIT created with initial_capacity="
Nicolas Geoffray0a3be162015-11-18 11:15:22 +0000118 << PrettySize(options->GetCodeCacheInitialCapacity())
119 << ", max_capacity=" << PrettySize(options->GetCodeCacheMaxCapacity())
Calin Juravle4d77b6a2015-12-01 18:38:09 +0000120 << ", compile_threshold=" << options->GetCompileThreshold()
121 << ", save_profiling_info=" << options->GetSaveProfilingInfo();
Mathieu Chartiere5f13e52015-02-24 09:37:21 -0800122 return jit.release();
123}
124
125bool Jit::LoadCompiler(std::string* error_msg) {
126 jit_library_handle_ = dlopen(
127 kIsDebugBuild ? "libartd-compiler.so" : "libart-compiler.so", RTLD_NOW);
128 if (jit_library_handle_ == nullptr) {
129 std::ostringstream oss;
130 oss << "JIT could not load libart-compiler.so: " << dlerror();
131 *error_msg = oss.str();
132 return false;
133 }
Nicolas Geoffray5b82d332016-02-18 14:22:32 +0000134 jit_load_ = reinterpret_cast<void* (*)(bool*)>(dlsym(jit_library_handle_, "jit_load"));
Mathieu Chartiere5f13e52015-02-24 09:37:21 -0800135 if (jit_load_ == nullptr) {
136 dlclose(jit_library_handle_);
137 *error_msg = "JIT couldn't find jit_load entry point";
138 return false;
139 }
140 jit_unload_ = reinterpret_cast<void (*)(void*)>(
141 dlsym(jit_library_handle_, "jit_unload"));
142 if (jit_unload_ == nullptr) {
143 dlclose(jit_library_handle_);
144 *error_msg = "JIT couldn't find jit_unload entry point";
145 return false;
146 }
Nicolas Geoffrayb331feb2016-02-05 16:51:53 +0000147 jit_compile_method_ = reinterpret_cast<bool (*)(void*, ArtMethod*, Thread*, bool)>(
Mathieu Chartiere5f13e52015-02-24 09:37:21 -0800148 dlsym(jit_library_handle_, "jit_compile_method"));
149 if (jit_compile_method_ == nullptr) {
150 dlclose(jit_library_handle_);
151 *error_msg = "JIT couldn't find jit_compile_method entry point";
152 return false;
153 }
Tamas Berghammerfffbee42016-01-15 13:09:34 +0000154 jit_types_loaded_ = reinterpret_cast<void (*)(void*, mirror::Class**, size_t)>(
155 dlsym(jit_library_handle_, "jit_types_loaded"));
156 if (jit_types_loaded_ == nullptr) {
Tamas Berghammer160e6df2016-01-05 14:29:02 +0000157 dlclose(jit_library_handle_);
Tamas Berghammerfffbee42016-01-15 13:09:34 +0000158 *error_msg = "JIT couldn't find jit_types_loaded entry point";
Tamas Berghammer160e6df2016-01-05 14:29:02 +0000159 return false;
160 }
Nicolas Geoffraya25dce92016-01-12 16:41:10 +0000161 bool will_generate_debug_symbols = false;
Mathieu Chartiere5f13e52015-02-24 09:37:21 -0800162 VLOG(jit) << "Calling JitLoad interpreter_only="
163 << Runtime::Current()->GetInstrumentation()->InterpretOnly();
Nicolas Geoffray5b82d332016-02-18 14:22:32 +0000164 jit_compiler_handle_ = (jit_load_)(&will_generate_debug_symbols);
Mathieu Chartiere5f13e52015-02-24 09:37:21 -0800165 if (jit_compiler_handle_ == nullptr) {
166 dlclose(jit_library_handle_);
167 *error_msg = "JIT couldn't load compiler";
168 return false;
169 }
Nicolas Geoffraya25dce92016-01-12 16:41:10 +0000170 generate_debug_info_ = will_generate_debug_symbols;
Mathieu Chartiere5f13e52015-02-24 09:37:21 -0800171 return true;
172}
173
Nicolas Geoffrayb331feb2016-02-05 16:51:53 +0000174bool Jit::CompileMethod(ArtMethod* method, Thread* self, bool osr) {
Mathieu Chartiere5f13e52015-02-24 09:37:21 -0800175 DCHECK(!method->IsRuntimeMethod());
Nicolas Geoffrayd9994f02016-02-11 17:35:55 +0000176
Nicolas Geoffray73be1e82015-09-17 15:22:56 +0100177 // Don't compile the method if it has breakpoints.
Mathieu Chartierd8565452015-03-26 09:41:50 -0700178 if (Dbg::IsDebuggerActive() && Dbg::MethodHasAnyBreakpoints(method)) {
179 VLOG(jit) << "JIT not compiling " << PrettyMethod(method) << " due to breakpoint";
180 return false;
181 }
Nicolas Geoffray73be1e82015-09-17 15:22:56 +0100182
183 // Don't compile the method if we are supposed to be deoptimized.
184 instrumentation::Instrumentation* instrumentation = Runtime::Current()->GetInstrumentation();
185 if (instrumentation->AreAllMethodsDeoptimized() || instrumentation->IsDeoptimized(method)) {
Nicolas Geoffraya42363f2015-12-17 14:57:09 +0000186 VLOG(jit) << "JIT not compiling " << PrettyMethod(method) << " due to deoptimization";
Nicolas Geoffray73be1e82015-09-17 15:22:56 +0100187 return false;
188 }
189
Nicolas Geoffrayd9994f02016-02-11 17:35:55 +0000190 // If we get a request to compile a proxy method, we pass the actual Java method
191 // of that proxy method, as the compiler does not expect a proxy method.
192 ArtMethod* method_to_compile = method->GetInterfaceMethodIfProxy(sizeof(void*));
193 if (!code_cache_->NotifyCompilationOf(method_to_compile, self, osr)) {
Nicolas Geoffray73be1e82015-09-17 15:22:56 +0100194 return false;
195 }
Nicolas Geoffrayd9994f02016-02-11 17:35:55 +0000196 bool success = jit_compile_method_(jit_compiler_handle_, method_to_compile, self, osr);
197 code_cache_->DoneCompiling(method_to_compile, self);
Nicolas Geoffray73be1e82015-09-17 15:22:56 +0100198 return success;
Mathieu Chartiere5f13e52015-02-24 09:37:21 -0800199}
200
201void Jit::CreateThreadPool() {
202 CHECK(instrumentation_cache_.get() != nullptr);
203 instrumentation_cache_->CreateThreadPool();
204}
205
206void Jit::DeleteThreadPool() {
207 if (instrumentation_cache_.get() != nullptr) {
Nicolas Geoffray629e9352015-11-04 17:22:16 +0000208 instrumentation_cache_->DeleteThreadPool(Thread::Current());
Mathieu Chartiere5f13e52015-02-24 09:37:21 -0800209 }
210}
211
Calin Juravle4d77b6a2015-12-01 18:38:09 +0000212void Jit::StartProfileSaver(const std::string& filename,
Calin Juravlec90bc922016-02-24 10:13:09 +0000213 const std::vector<std::string>& code_paths,
214 const std::string& foreign_dex_profile_path,
215 const std::string& app_dir) {
Calin Juravle4d77b6a2015-12-01 18:38:09 +0000216 if (save_profiling_info_) {
Calin Juravlec90bc922016-02-24 10:13:09 +0000217 ProfileSaver::Start(filename, code_cache_.get(), code_paths, foreign_dex_profile_path, app_dir);
Calin Juravle31f2c152015-10-23 17:56:15 +0100218 }
Calin Juravle4d77b6a2015-12-01 18:38:09 +0000219}
220
221void Jit::StopProfileSaver() {
222 if (save_profiling_info_ && ProfileSaver::IsStarted()) {
223 ProfileSaver::Stop();
Calin Juravle31f2c152015-10-23 17:56:15 +0100224 }
225}
226
Siva Chandra05d24152016-01-05 17:43:17 -0800227bool Jit::JitAtFirstUse() {
228 if (instrumentation_cache_ != nullptr) {
229 return instrumentation_cache_->HotMethodThreshold() == 0;
230 }
231 return false;
232}
233
Nicolas Geoffray35122442016-03-02 12:05:30 +0000234bool Jit::CanInvokeCompiledCode(ArtMethod* method) {
235 return code_cache_->ContainsPc(method->GetEntryPointFromQuickCompiledCode());
236}
237
Mathieu Chartiere5f13e52015-02-24 09:37:21 -0800238Jit::~Jit() {
Calin Juravle4d77b6a2015-12-01 18:38:09 +0000239 DCHECK(!save_profiling_info_ || !ProfileSaver::IsStarted());
Mathieu Chartiera4885cb2015-03-09 15:38:54 -0700240 if (dump_info_on_shutdown_) {
241 DumpInfo(LOG(INFO));
242 }
Mathieu Chartiere5f13e52015-02-24 09:37:21 -0800243 DeleteThreadPool();
244 if (jit_compiler_handle_ != nullptr) {
245 jit_unload_(jit_compiler_handle_);
246 }
247 if (jit_library_handle_ != nullptr) {
248 dlclose(jit_library_handle_);
249 }
250}
251
Nicolas Geoffrayb331feb2016-02-05 16:51:53 +0000252void Jit::CreateInstrumentationCache(size_t compile_threshold,
253 size_t warmup_threshold,
254 size_t osr_threshold) {
Nicolas Geoffray5550ca82015-08-21 18:38:30 +0100255 instrumentation_cache_.reset(
Nicolas Geoffrayb331feb2016-02-05 16:51:53 +0000256 new jit::JitInstrumentationCache(compile_threshold, warmup_threshold, osr_threshold));
Mathieu Chartiere5f13e52015-02-24 09:37:21 -0800257}
258
Tamas Berghammer160e6df2016-01-05 14:29:02 +0000259void Jit::NewTypeLoadedIfUsingJit(mirror::Class* type) {
260 jit::Jit* jit = Runtime::Current()->GetJit();
261 if (jit != nullptr && jit->generate_debug_info_) {
Tamas Berghammerfffbee42016-01-15 13:09:34 +0000262 DCHECK(jit->jit_types_loaded_ != nullptr);
263 jit->jit_types_loaded_(jit->jit_compiler_handle_, &type, 1);
264 }
265}
266
267void Jit::DumpTypeInfoForLoadedTypes(ClassLinker* linker) {
268 struct CollectClasses : public ClassVisitor {
Mathieu Chartier1aa8ec22016-02-01 10:34:47 -0800269 bool operator()(mirror::Class* klass) override {
Tamas Berghammerfffbee42016-01-15 13:09:34 +0000270 classes_.push_back(klass);
271 return true;
272 }
Mathieu Chartier9b1c9b72016-02-02 10:09:58 -0800273 std::vector<mirror::Class*> classes_;
Tamas Berghammerfffbee42016-01-15 13:09:34 +0000274 };
275
276 if (generate_debug_info_) {
277 ScopedObjectAccess so(Thread::Current());
278
279 CollectClasses visitor;
280 linker->VisitClasses(&visitor);
281 jit_types_loaded_(jit_compiler_handle_, visitor.classes_.data(), visitor.classes_.size());
Tamas Berghammer160e6df2016-01-05 14:29:02 +0000282 }
283}
284
Nicolas Geoffrayb331feb2016-02-05 16:51:53 +0000285extern "C" void art_quick_osr_stub(void** stack,
286 uint32_t stack_size_in_bytes,
287 const uint8_t* native_pc,
288 JValue* result,
289 const char* shorty,
290 Thread* self);
291
292bool Jit::MaybeDoOnStackReplacement(Thread* thread,
293 ArtMethod* method,
294 uint32_t dex_pc,
295 int32_t dex_pc_offset,
296 JValue* result) {
Nicolas Geoffraye8662132016-02-15 10:00:42 +0000297 if (!kEnableOnStackReplacement) {
298 return false;
299 }
300
Nicolas Geoffrayb331feb2016-02-05 16:51:53 +0000301 Jit* jit = Runtime::Current()->GetJit();
302 if (jit == nullptr) {
303 return false;
304 }
305
306 if (kRuntimeISA == kMips || kRuntimeISA == kMips64) {
Nicolas Geoffrayc0b27962016-02-16 12:06:05 +0000307 VLOG(jit) << "OSR not supported on this platform: " << kRuntimeISA;
Nicolas Geoffrayb331feb2016-02-05 16:51:53 +0000308 return false;
309 }
310
Nicolas Geoffrayb88d59e2016-02-17 11:31:49 +0000311 if (UNLIKELY(__builtin_frame_address(0) < thread->GetStackEnd())) {
312 // Don't attempt to do an OSR if we are close to the stack limit. Since
313 // the interpreter frames are still on stack, OSR has the potential
314 // to stack overflow even for a simple loop.
315 // b/27094810.
316 return false;
317 }
318
Nicolas Geoffrayd9bc4332016-02-05 23:32:25 +0000319 // Get the actual Java method if this method is from a proxy class. The compiler
320 // and the JIT code cache do not expect methods from proxy classes.
321 method = method->GetInterfaceMethodIfProxy(sizeof(void*));
322
Nicolas Geoffrayb331feb2016-02-05 16:51:53 +0000323 // Cheap check if the method has been compiled already. That's an indicator that we should
324 // osr into it.
325 if (!jit->GetCodeCache()->ContainsPc(method->GetEntryPointFromQuickCompiledCode())) {
326 return false;
327 }
328
Nicolas Geoffrayc0b27962016-02-16 12:06:05 +0000329 // Fetch some data before looking up for an OSR method. We don't want thread
330 // suspension once we hold an OSR method, as the JIT code cache could delete the OSR
331 // method while we are being suspended.
Nicolas Geoffrayb331feb2016-02-05 16:51:53 +0000332 const size_t number_of_vregs = method->GetCodeItem()->registers_size_;
Nicolas Geoffrayd186dd82016-02-16 10:03:44 +0000333 const char* shorty = method->GetShorty();
334 std::string method_name(VLOG_IS_ON(jit) ? PrettyMethod(method) : "");
335 void** memory = nullptr;
336 size_t frame_size = 0;
337 ShadowFrame* shadow_frame = nullptr;
338 const uint8_t* native_pc = nullptr;
Nicolas Geoffrayb331feb2016-02-05 16:51:53 +0000339
Nicolas Geoffrayd186dd82016-02-16 10:03:44 +0000340 {
341 ScopedAssertNoThreadSuspension sts(thread, "Holding OSR method");
342 const OatQuickMethodHeader* osr_method = jit->GetCodeCache()->LookupOsrMethodHeader(method);
343 if (osr_method == nullptr) {
344 // No osr method yet, just return to the interpreter.
345 return false;
Nicolas Geoffrayb331feb2016-02-05 16:51:53 +0000346 }
Nicolas Geoffrayd186dd82016-02-16 10:03:44 +0000347
348 CodeInfo code_info = osr_method->GetOptimizedCodeInfo();
349 StackMapEncoding encoding = code_info.ExtractEncoding();
350
351 // Find stack map starting at the target dex_pc.
352 StackMap stack_map = code_info.GetOsrStackMapForDexPc(dex_pc + dex_pc_offset, encoding);
353 if (!stack_map.IsValid()) {
354 // There is no OSR stack map for this dex pc offset. Just return to the interpreter in the
355 // hope that the next branch has one.
356 return false;
357 }
358
359 // We found a stack map, now fill the frame with dex register values from the interpreter's
360 // shadow frame.
361 DexRegisterMap vreg_map =
362 code_info.GetDexRegisterMapOf(stack_map, encoding, number_of_vregs);
363
364 frame_size = osr_method->GetFrameSizeInBytes();
365
366 // Allocate memory to put shadow frame values. The osr stub will copy that memory to
367 // stack.
368 // Note that we could pass the shadow frame to the stub, and let it copy the values there,
369 // but that is engineering complexity not worth the effort for something like OSR.
370 memory = reinterpret_cast<void**>(malloc(frame_size));
371 CHECK(memory != nullptr);
372 memset(memory, 0, frame_size);
373
374 // Art ABI: ArtMethod is at the bottom of the stack.
375 memory[0] = method;
376
377 shadow_frame = thread->PopShadowFrame();
378 if (!vreg_map.IsValid()) {
379 // If we don't have a dex register map, then there are no live dex registers at
380 // this dex pc.
381 } else {
382 for (uint16_t vreg = 0; vreg < number_of_vregs; ++vreg) {
383 DexRegisterLocation::Kind location =
384 vreg_map.GetLocationKind(vreg, number_of_vregs, code_info, encoding);
385 if (location == DexRegisterLocation::Kind::kNone) {
Nicolas Geoffrayc0b27962016-02-16 12:06:05 +0000386 // Dex register is dead or uninitialized.
Nicolas Geoffrayd186dd82016-02-16 10:03:44 +0000387 continue;
388 }
389
390 if (location == DexRegisterLocation::Kind::kConstant) {
391 // We skip constants because the compiled code knows how to handle them.
392 continue;
393 }
394
David Srbecky7dc11782016-02-25 13:23:56 +0000395 DCHECK_EQ(location, DexRegisterLocation::Kind::kInStack);
Nicolas Geoffrayd186dd82016-02-16 10:03:44 +0000396
397 int32_t vreg_value = shadow_frame->GetVReg(vreg);
398 int32_t slot_offset = vreg_map.GetStackOffsetInBytes(vreg,
399 number_of_vregs,
400 code_info,
401 encoding);
402 DCHECK_LT(slot_offset, static_cast<int32_t>(frame_size));
403 DCHECK_GT(slot_offset, 0);
404 (reinterpret_cast<int32_t*>(memory))[slot_offset / sizeof(int32_t)] = vreg_value;
405 }
406 }
407
408 native_pc = stack_map.GetNativePcOffset(encoding) + osr_method->GetEntryPoint();
409 VLOG(jit) << "Jumping to "
410 << method_name
411 << "@"
412 << std::hex << reinterpret_cast<uintptr_t>(native_pc);
Nicolas Geoffrayb331feb2016-02-05 16:51:53 +0000413 }
414
Nicolas Geoffrayb331feb2016-02-05 16:51:53 +0000415 {
416 ManagedStack fragment;
417 thread->PushManagedStackFragment(&fragment);
418 (*art_quick_osr_stub)(memory,
419 frame_size,
420 native_pc,
421 result,
Nicolas Geoffrayd186dd82016-02-16 10:03:44 +0000422 shorty,
Nicolas Geoffrayb331feb2016-02-05 16:51:53 +0000423 thread);
Nicolas Geoffrayd186dd82016-02-16 10:03:44 +0000424
Nicolas Geoffrayb331feb2016-02-05 16:51:53 +0000425 if (UNLIKELY(thread->GetException() == Thread::GetDeoptimizationException())) {
426 thread->DeoptimizeWithDeoptimizationException(result);
427 }
428 thread->PopManagedStackFragment(fragment);
429 }
430 free(memory);
431 thread->PushShadowFrame(shadow_frame);
Nicolas Geoffrayd186dd82016-02-16 10:03:44 +0000432 VLOG(jit) << "Done running OSR code for " << method_name;
Nicolas Geoffrayb331feb2016-02-05 16:51:53 +0000433 return true;
434}
435
Mathieu Chartiere5f13e52015-02-24 09:37:21 -0800436} // namespace jit
437} // namespace art