blob: 91b006a3eaf15e2a9bd407f1177d02df511746ec [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 Geoffray0a3be162015-11-18 11:15:22 +000044 jit_options->code_cache_initial_capacity_ =
45 options.GetOrDefault(RuntimeArgumentMap::JITCodeCacheInitialCapacity);
46 jit_options->code_cache_max_capacity_ =
47 options.GetOrDefault(RuntimeArgumentMap::JITCodeCacheMaxCapacity);
Mathieu Chartiere5f13e52015-02-24 09:37:21 -080048 jit_options->compile_threshold_ =
49 options.GetOrDefault(RuntimeArgumentMap::JITCompileThreshold);
Nicolas Geoffrayb331feb2016-02-05 16:51:53 +000050 // TODO(ngeoffray): Make this a proper option.
51 jit_options->osr_threshold_ = jit_options->compile_threshold_ * 2;
Nicolas Geoffray5550ca82015-08-21 18:38:30 +010052 jit_options->warmup_threshold_ =
53 options.GetOrDefault(RuntimeArgumentMap::JITWarmupThreshold);
Mathieu Chartiera4885cb2015-03-09 15:38:54 -070054 jit_options->dump_info_on_shutdown_ =
55 options.Exists(RuntimeArgumentMap::DumpJITInfoOnShutdown);
Calin Juravle31f2c152015-10-23 17:56:15 +010056 jit_options->save_profiling_info_ =
57 options.GetOrDefault(RuntimeArgumentMap::JITSaveProfilingInfo);;
Mathieu Chartiere5f13e52015-02-24 09:37:21 -080058 return jit_options;
59}
60
Mathieu Chartiera4885cb2015-03-09 15:38:54 -070061void Jit::DumpInfo(std::ostream& os) {
Nicolas Geoffrayaee21562015-12-15 16:39:44 +000062 os << "JIT code cache size=" << PrettySize(code_cache_->CodeCacheSize()) << "\n"
63 << "JIT data cache size=" << PrettySize(code_cache_->DataCacheSize()) << "\n"
64 << "JIT current capacity=" << PrettySize(code_cache_->GetCurrentCapacity()) << "\n"
Nicolas Geoffray0a522232016-01-19 09:34:58 +000065 << "JIT number of compiled code=" << code_cache_->NumberOfCompiledCode() << "\n"
Nicolas Geoffrayfcdd7292016-02-25 13:27:47 +000066 << "JIT total number of compilations=" << code_cache_->NumberOfCompilations() << "\n"
67 << "JIT total number of osr compilations=" << code_cache_->NumberOfOsrCompilations() << "\n";
Mathieu Chartiera4885cb2015-03-09 15:38:54 -070068 cumulative_timings_.Dump(os);
69}
70
71void Jit::AddTimingLogger(const TimingLogger& logger) {
72 cumulative_timings_.AddLogger(logger);
73}
74
Nicolas Geoffraya25dce92016-01-12 16:41:10 +000075Jit::Jit() : jit_library_handle_(nullptr),
76 jit_compiler_handle_(nullptr),
77 jit_load_(nullptr),
78 jit_compile_method_(nullptr),
79 dump_info_on_shutdown_(false),
80 cumulative_timings_("JIT timings"),
81 save_profiling_info_(false),
82 generate_debug_info_(false) {
Mathieu Chartiere5f13e52015-02-24 09:37:21 -080083}
84
85Jit* Jit::Create(JitOptions* options, std::string* error_msg) {
86 std::unique_ptr<Jit> jit(new Jit);
Mathieu Chartiera4885cb2015-03-09 15:38:54 -070087 jit->dump_info_on_shutdown_ = options->DumpJitInfoOnShutdown();
Mathieu Chartiere5f13e52015-02-24 09:37:21 -080088 if (!jit->LoadCompiler(error_msg)) {
89 return nullptr;
90 }
Nicolas Geoffray0a3be162015-11-18 11:15:22 +000091 jit->code_cache_.reset(JitCodeCache::Create(
Nicolas Geoffraya25dce92016-01-12 16:41:10 +000092 options->GetCodeCacheInitialCapacity(),
93 options->GetCodeCacheMaxCapacity(),
94 jit->generate_debug_info_,
95 error_msg));
Mathieu Chartiere5f13e52015-02-24 09:37:21 -080096 if (jit->GetCodeCache() == nullptr) {
97 return nullptr;
98 }
Calin Juravle4d77b6a2015-12-01 18:38:09 +000099 jit->save_profiling_info_ = options->GetSaveProfilingInfo();
Nicolas Geoffray0a3be162015-11-18 11:15:22 +0000100 LOG(INFO) << "JIT created with initial_capacity="
101 << PrettySize(options->GetCodeCacheInitialCapacity())
102 << ", max_capacity=" << PrettySize(options->GetCodeCacheMaxCapacity())
Calin Juravle4d77b6a2015-12-01 18:38:09 +0000103 << ", compile_threshold=" << options->GetCompileThreshold()
104 << ", save_profiling_info=" << options->GetSaveProfilingInfo();
Mathieu Chartiere5f13e52015-02-24 09:37:21 -0800105 return jit.release();
106}
107
108bool Jit::LoadCompiler(std::string* error_msg) {
109 jit_library_handle_ = dlopen(
110 kIsDebugBuild ? "libartd-compiler.so" : "libart-compiler.so", RTLD_NOW);
111 if (jit_library_handle_ == nullptr) {
112 std::ostringstream oss;
113 oss << "JIT could not load libart-compiler.so: " << dlerror();
114 *error_msg = oss.str();
115 return false;
116 }
Nicolas Geoffray5b82d332016-02-18 14:22:32 +0000117 jit_load_ = reinterpret_cast<void* (*)(bool*)>(dlsym(jit_library_handle_, "jit_load"));
Mathieu Chartiere5f13e52015-02-24 09:37:21 -0800118 if (jit_load_ == nullptr) {
119 dlclose(jit_library_handle_);
120 *error_msg = "JIT couldn't find jit_load entry point";
121 return false;
122 }
123 jit_unload_ = reinterpret_cast<void (*)(void*)>(
124 dlsym(jit_library_handle_, "jit_unload"));
125 if (jit_unload_ == nullptr) {
126 dlclose(jit_library_handle_);
127 *error_msg = "JIT couldn't find jit_unload entry point";
128 return false;
129 }
Nicolas Geoffrayb331feb2016-02-05 16:51:53 +0000130 jit_compile_method_ = reinterpret_cast<bool (*)(void*, ArtMethod*, Thread*, bool)>(
Mathieu Chartiere5f13e52015-02-24 09:37:21 -0800131 dlsym(jit_library_handle_, "jit_compile_method"));
132 if (jit_compile_method_ == nullptr) {
133 dlclose(jit_library_handle_);
134 *error_msg = "JIT couldn't find jit_compile_method entry point";
135 return false;
136 }
Tamas Berghammerfffbee42016-01-15 13:09:34 +0000137 jit_types_loaded_ = reinterpret_cast<void (*)(void*, mirror::Class**, size_t)>(
138 dlsym(jit_library_handle_, "jit_types_loaded"));
139 if (jit_types_loaded_ == nullptr) {
Tamas Berghammer160e6df2016-01-05 14:29:02 +0000140 dlclose(jit_library_handle_);
Tamas Berghammerfffbee42016-01-15 13:09:34 +0000141 *error_msg = "JIT couldn't find jit_types_loaded entry point";
Tamas Berghammer160e6df2016-01-05 14:29:02 +0000142 return false;
143 }
Nicolas Geoffraya25dce92016-01-12 16:41:10 +0000144 bool will_generate_debug_symbols = false;
Mathieu Chartiere5f13e52015-02-24 09:37:21 -0800145 VLOG(jit) << "Calling JitLoad interpreter_only="
146 << Runtime::Current()->GetInstrumentation()->InterpretOnly();
Nicolas Geoffray5b82d332016-02-18 14:22:32 +0000147 jit_compiler_handle_ = (jit_load_)(&will_generate_debug_symbols);
Mathieu Chartiere5f13e52015-02-24 09:37:21 -0800148 if (jit_compiler_handle_ == nullptr) {
149 dlclose(jit_library_handle_);
150 *error_msg = "JIT couldn't load compiler";
151 return false;
152 }
Nicolas Geoffraya25dce92016-01-12 16:41:10 +0000153 generate_debug_info_ = will_generate_debug_symbols;
Mathieu Chartiere5f13e52015-02-24 09:37:21 -0800154 return true;
155}
156
Nicolas Geoffrayb331feb2016-02-05 16:51:53 +0000157bool Jit::CompileMethod(ArtMethod* method, Thread* self, bool osr) {
Mathieu Chartiere5f13e52015-02-24 09:37:21 -0800158 DCHECK(!method->IsRuntimeMethod());
Nicolas Geoffrayd9994f02016-02-11 17:35:55 +0000159
Nicolas Geoffray73be1e82015-09-17 15:22:56 +0100160 // Don't compile the method if it has breakpoints.
Mathieu Chartierd8565452015-03-26 09:41:50 -0700161 if (Dbg::IsDebuggerActive() && Dbg::MethodHasAnyBreakpoints(method)) {
162 VLOG(jit) << "JIT not compiling " << PrettyMethod(method) << " due to breakpoint";
163 return false;
164 }
Nicolas Geoffray73be1e82015-09-17 15:22:56 +0100165
166 // Don't compile the method if we are supposed to be deoptimized.
167 instrumentation::Instrumentation* instrumentation = Runtime::Current()->GetInstrumentation();
168 if (instrumentation->AreAllMethodsDeoptimized() || instrumentation->IsDeoptimized(method)) {
Nicolas Geoffraya42363f2015-12-17 14:57:09 +0000169 VLOG(jit) << "JIT not compiling " << PrettyMethod(method) << " due to deoptimization";
Nicolas Geoffray73be1e82015-09-17 15:22:56 +0100170 return false;
171 }
172
Nicolas Geoffrayd9994f02016-02-11 17:35:55 +0000173 // If we get a request to compile a proxy method, we pass the actual Java method
174 // of that proxy method, as the compiler does not expect a proxy method.
175 ArtMethod* method_to_compile = method->GetInterfaceMethodIfProxy(sizeof(void*));
176 if (!code_cache_->NotifyCompilationOf(method_to_compile, self, osr)) {
Nicolas Geoffrayb331feb2016-02-05 16:51:53 +0000177 VLOG(jit) << "JIT not compiling " << PrettyMethod(method) << " due to code cache";
Nicolas Geoffray73be1e82015-09-17 15:22:56 +0100178 return false;
179 }
Nicolas Geoffrayd9994f02016-02-11 17:35:55 +0000180 bool success = jit_compile_method_(jit_compiler_handle_, method_to_compile, self, osr);
181 code_cache_->DoneCompiling(method_to_compile, self);
Nicolas Geoffray73be1e82015-09-17 15:22:56 +0100182 return success;
Mathieu Chartiere5f13e52015-02-24 09:37:21 -0800183}
184
185void Jit::CreateThreadPool() {
186 CHECK(instrumentation_cache_.get() != nullptr);
187 instrumentation_cache_->CreateThreadPool();
188}
189
190void Jit::DeleteThreadPool() {
191 if (instrumentation_cache_.get() != nullptr) {
Nicolas Geoffray629e9352015-11-04 17:22:16 +0000192 instrumentation_cache_->DeleteThreadPool(Thread::Current());
Mathieu Chartiere5f13e52015-02-24 09:37:21 -0800193 }
194}
195
Calin Juravle4d77b6a2015-12-01 18:38:09 +0000196void Jit::StartProfileSaver(const std::string& filename,
197 const std::vector<std::string>& code_paths) {
198 if (save_profiling_info_) {
199 ProfileSaver::Start(filename, code_cache_.get(), code_paths);
Calin Juravle31f2c152015-10-23 17:56:15 +0100200 }
Calin Juravle4d77b6a2015-12-01 18:38:09 +0000201}
202
203void Jit::StopProfileSaver() {
204 if (save_profiling_info_ && ProfileSaver::IsStarted()) {
205 ProfileSaver::Stop();
Calin Juravle31f2c152015-10-23 17:56:15 +0100206 }
207}
208
Siva Chandra05d24152016-01-05 17:43:17 -0800209bool Jit::JitAtFirstUse() {
210 if (instrumentation_cache_ != nullptr) {
211 return instrumentation_cache_->HotMethodThreshold() == 0;
212 }
213 return false;
214}
215
Nicolas Geoffray35122442016-03-02 12:05:30 +0000216bool Jit::CanInvokeCompiledCode(ArtMethod* method) {
217 return code_cache_->ContainsPc(method->GetEntryPointFromQuickCompiledCode());
218}
219
Mathieu Chartiere5f13e52015-02-24 09:37:21 -0800220Jit::~Jit() {
Calin Juravle4d77b6a2015-12-01 18:38:09 +0000221 DCHECK(!save_profiling_info_ || !ProfileSaver::IsStarted());
Mathieu Chartiera4885cb2015-03-09 15:38:54 -0700222 if (dump_info_on_shutdown_) {
223 DumpInfo(LOG(INFO));
224 }
Mathieu Chartiere5f13e52015-02-24 09:37:21 -0800225 DeleteThreadPool();
226 if (jit_compiler_handle_ != nullptr) {
227 jit_unload_(jit_compiler_handle_);
228 }
229 if (jit_library_handle_ != nullptr) {
230 dlclose(jit_library_handle_);
231 }
232}
233
Nicolas Geoffrayb331feb2016-02-05 16:51:53 +0000234void Jit::CreateInstrumentationCache(size_t compile_threshold,
235 size_t warmup_threshold,
236 size_t osr_threshold) {
Nicolas Geoffray5550ca82015-08-21 18:38:30 +0100237 instrumentation_cache_.reset(
Nicolas Geoffrayb331feb2016-02-05 16:51:53 +0000238 new jit::JitInstrumentationCache(compile_threshold, warmup_threshold, osr_threshold));
Mathieu Chartiere5f13e52015-02-24 09:37:21 -0800239}
240
Tamas Berghammer160e6df2016-01-05 14:29:02 +0000241void Jit::NewTypeLoadedIfUsingJit(mirror::Class* type) {
242 jit::Jit* jit = Runtime::Current()->GetJit();
243 if (jit != nullptr && jit->generate_debug_info_) {
Tamas Berghammerfffbee42016-01-15 13:09:34 +0000244 DCHECK(jit->jit_types_loaded_ != nullptr);
245 jit->jit_types_loaded_(jit->jit_compiler_handle_, &type, 1);
246 }
247}
248
249void Jit::DumpTypeInfoForLoadedTypes(ClassLinker* linker) {
250 struct CollectClasses : public ClassVisitor {
Mathieu Chartier1aa8ec22016-02-01 10:34:47 -0800251 bool operator()(mirror::Class* klass) override {
Tamas Berghammerfffbee42016-01-15 13:09:34 +0000252 classes_.push_back(klass);
253 return true;
254 }
Mathieu Chartier9b1c9b72016-02-02 10:09:58 -0800255 std::vector<mirror::Class*> classes_;
Tamas Berghammerfffbee42016-01-15 13:09:34 +0000256 };
257
258 if (generate_debug_info_) {
259 ScopedObjectAccess so(Thread::Current());
260
261 CollectClasses visitor;
262 linker->VisitClasses(&visitor);
263 jit_types_loaded_(jit_compiler_handle_, visitor.classes_.data(), visitor.classes_.size());
Tamas Berghammer160e6df2016-01-05 14:29:02 +0000264 }
265}
266
Nicolas Geoffrayb331feb2016-02-05 16:51:53 +0000267extern "C" void art_quick_osr_stub(void** stack,
268 uint32_t stack_size_in_bytes,
269 const uint8_t* native_pc,
270 JValue* result,
271 const char* shorty,
272 Thread* self);
273
274bool Jit::MaybeDoOnStackReplacement(Thread* thread,
275 ArtMethod* method,
276 uint32_t dex_pc,
277 int32_t dex_pc_offset,
278 JValue* result) {
Nicolas Geoffraye8662132016-02-15 10:00:42 +0000279 if (!kEnableOnStackReplacement) {
280 return false;
281 }
282
Nicolas Geoffrayb331feb2016-02-05 16:51:53 +0000283 Jit* jit = Runtime::Current()->GetJit();
284 if (jit == nullptr) {
285 return false;
286 }
287
288 if (kRuntimeISA == kMips || kRuntimeISA == kMips64) {
Nicolas Geoffrayc0b27962016-02-16 12:06:05 +0000289 VLOG(jit) << "OSR not supported on this platform: " << kRuntimeISA;
Nicolas Geoffrayb331feb2016-02-05 16:51:53 +0000290 return false;
291 }
292
Nicolas Geoffrayb88d59e2016-02-17 11:31:49 +0000293 if (UNLIKELY(__builtin_frame_address(0) < thread->GetStackEnd())) {
294 // Don't attempt to do an OSR if we are close to the stack limit. Since
295 // the interpreter frames are still on stack, OSR has the potential
296 // to stack overflow even for a simple loop.
297 // b/27094810.
298 return false;
299 }
300
Nicolas Geoffrayd9bc4332016-02-05 23:32:25 +0000301 // Get the actual Java method if this method is from a proxy class. The compiler
302 // and the JIT code cache do not expect methods from proxy classes.
303 method = method->GetInterfaceMethodIfProxy(sizeof(void*));
304
Nicolas Geoffrayb331feb2016-02-05 16:51:53 +0000305 // Cheap check if the method has been compiled already. That's an indicator that we should
306 // osr into it.
307 if (!jit->GetCodeCache()->ContainsPc(method->GetEntryPointFromQuickCompiledCode())) {
308 return false;
309 }
310
Nicolas Geoffrayc0b27962016-02-16 12:06:05 +0000311 // Fetch some data before looking up for an OSR method. We don't want thread
312 // suspension once we hold an OSR method, as the JIT code cache could delete the OSR
313 // method while we are being suspended.
Nicolas Geoffrayb331feb2016-02-05 16:51:53 +0000314 const size_t number_of_vregs = method->GetCodeItem()->registers_size_;
Nicolas Geoffrayd186dd82016-02-16 10:03:44 +0000315 const char* shorty = method->GetShorty();
316 std::string method_name(VLOG_IS_ON(jit) ? PrettyMethod(method) : "");
317 void** memory = nullptr;
318 size_t frame_size = 0;
319 ShadowFrame* shadow_frame = nullptr;
320 const uint8_t* native_pc = nullptr;
Nicolas Geoffrayb331feb2016-02-05 16:51:53 +0000321
Nicolas Geoffrayd186dd82016-02-16 10:03:44 +0000322 {
323 ScopedAssertNoThreadSuspension sts(thread, "Holding OSR method");
324 const OatQuickMethodHeader* osr_method = jit->GetCodeCache()->LookupOsrMethodHeader(method);
325 if (osr_method == nullptr) {
326 // No osr method yet, just return to the interpreter.
327 return false;
Nicolas Geoffrayb331feb2016-02-05 16:51:53 +0000328 }
Nicolas Geoffrayd186dd82016-02-16 10:03:44 +0000329
330 CodeInfo code_info = osr_method->GetOptimizedCodeInfo();
331 StackMapEncoding encoding = code_info.ExtractEncoding();
332
333 // Find stack map starting at the target dex_pc.
334 StackMap stack_map = code_info.GetOsrStackMapForDexPc(dex_pc + dex_pc_offset, encoding);
335 if (!stack_map.IsValid()) {
336 // There is no OSR stack map for this dex pc offset. Just return to the interpreter in the
337 // hope that the next branch has one.
338 return false;
339 }
340
341 // We found a stack map, now fill the frame with dex register values from the interpreter's
342 // shadow frame.
343 DexRegisterMap vreg_map =
344 code_info.GetDexRegisterMapOf(stack_map, encoding, number_of_vregs);
345
346 frame_size = osr_method->GetFrameSizeInBytes();
347
348 // Allocate memory to put shadow frame values. The osr stub will copy that memory to
349 // stack.
350 // Note that we could pass the shadow frame to the stub, and let it copy the values there,
351 // but that is engineering complexity not worth the effort for something like OSR.
352 memory = reinterpret_cast<void**>(malloc(frame_size));
353 CHECK(memory != nullptr);
354 memset(memory, 0, frame_size);
355
356 // Art ABI: ArtMethod is at the bottom of the stack.
357 memory[0] = method;
358
359 shadow_frame = thread->PopShadowFrame();
360 if (!vreg_map.IsValid()) {
361 // If we don't have a dex register map, then there are no live dex registers at
362 // this dex pc.
363 } else {
364 for (uint16_t vreg = 0; vreg < number_of_vregs; ++vreg) {
365 DexRegisterLocation::Kind location =
366 vreg_map.GetLocationKind(vreg, number_of_vregs, code_info, encoding);
367 if (location == DexRegisterLocation::Kind::kNone) {
Nicolas Geoffrayc0b27962016-02-16 12:06:05 +0000368 // Dex register is dead or uninitialized.
Nicolas Geoffrayd186dd82016-02-16 10:03:44 +0000369 continue;
370 }
371
372 if (location == DexRegisterLocation::Kind::kConstant) {
373 // We skip constants because the compiled code knows how to handle them.
374 continue;
375 }
376
David Srbecky7dc11782016-02-25 13:23:56 +0000377 DCHECK_EQ(location, DexRegisterLocation::Kind::kInStack);
Nicolas Geoffrayd186dd82016-02-16 10:03:44 +0000378
379 int32_t vreg_value = shadow_frame->GetVReg(vreg);
380 int32_t slot_offset = vreg_map.GetStackOffsetInBytes(vreg,
381 number_of_vregs,
382 code_info,
383 encoding);
384 DCHECK_LT(slot_offset, static_cast<int32_t>(frame_size));
385 DCHECK_GT(slot_offset, 0);
386 (reinterpret_cast<int32_t*>(memory))[slot_offset / sizeof(int32_t)] = vreg_value;
387 }
388 }
389
390 native_pc = stack_map.GetNativePcOffset(encoding) + osr_method->GetEntryPoint();
391 VLOG(jit) << "Jumping to "
392 << method_name
393 << "@"
394 << std::hex << reinterpret_cast<uintptr_t>(native_pc);
Nicolas Geoffrayb331feb2016-02-05 16:51:53 +0000395 }
396
Nicolas Geoffrayb331feb2016-02-05 16:51:53 +0000397 {
398 ManagedStack fragment;
399 thread->PushManagedStackFragment(&fragment);
400 (*art_quick_osr_stub)(memory,
401 frame_size,
402 native_pc,
403 result,
Nicolas Geoffrayd186dd82016-02-16 10:03:44 +0000404 shorty,
Nicolas Geoffrayb331feb2016-02-05 16:51:53 +0000405 thread);
Nicolas Geoffrayd186dd82016-02-16 10:03:44 +0000406
Nicolas Geoffrayb331feb2016-02-05 16:51:53 +0000407 if (UNLIKELY(thread->GetException() == Thread::GetDeoptimizationException())) {
408 thread->DeoptimizeWithDeoptimizationException(result);
409 }
410 thread->PopManagedStackFragment(fragment);
411 }
412 free(memory);
413 thread->PushShadowFrame(shadow_frame);
Nicolas Geoffrayd186dd82016-02-16 10:03:44 +0000414 VLOG(jit) << "Done running OSR code for " << method_name;
Nicolas Geoffrayb331feb2016-02-05 16:51:53 +0000415 return true;
416}
417
Mathieu Chartiere5f13e52015-02-24 09:37:21 -0800418} // namespace jit
419} // namespace art