blob: 8cf37fbeed7e01c2edd60d1aa67e979a23f4935b [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#ifndef ART_RUNTIME_JIT_JIT_H_
18#define ART_RUNTIME_JIT_JIT_H_
19
Nicolas Geoffraya4f81542016-03-08 16:57:48 +000020#include "base/histogram-inl.h"
Mathieu Chartiere5f13e52015-02-24 09:37:21 -080021#include "base/macros.h"
22#include "base/mutex.h"
David Srbecky21821472019-07-29 15:10:31 +010023#include "base/runtime_debug.h"
Mathieu Chartiera4885cb2015-03-09 15:38:54 -070024#include "base/timing_logger.h"
Nicolas Geoffray9ac09ee2019-05-08 23:38:27 +010025#include "handle.h"
Mathieu Chartieref41db72016-10-25 15:08:01 -070026#include "jit/profile_saver_options.h"
27#include "obj_ptr.h"
Mathieu Chartiere5f13e52015-02-24 09:37:21 -080028#include "thread_pool.h"
29
30namespace art {
31
Mathieu Chartiere401d142015-04-22 13:56:20 -070032class ArtMethod;
David Sehr9323e6e2016-09-13 08:58:35 -070033class ClassLinker;
Nicolas Geoffray9ac09ee2019-05-08 23:38:27 +010034class DexFile;
Nicolas Geoffraydc2fbb62019-04-11 22:55:50 +010035class OatDexFile;
Mathieu Chartiere5f13e52015-02-24 09:37:21 -080036struct RuntimeArgumentMap;
Vladimir Marko3a21e382016-09-02 12:38:38 +010037union JValue;
Mathieu Chartiere5f13e52015-02-24 09:37:21 -080038
David Sehr709b0702016-10-13 09:12:37 -070039namespace mirror {
40class Object;
41class Class;
Nicolas Geoffray9ac09ee2019-05-08 23:38:27 +010042class ClassLoader;
Nicolas Geoffray0f8950a2019-07-24 13:22:11 +010043class DexCache;
Nicolas Geoffraya48c3df2019-06-27 13:11:12 +000044class String;
David Sehr709b0702016-10-13 09:12:37 -070045} // namespace mirror
46
Mathieu Chartiere5f13e52015-02-24 09:37:21 -080047namespace jit {
48
49class JitCodeCache;
Nicolas Geoffray7f7539b2019-06-06 16:20:54 +010050class JitMemoryRegion;
Mathieu Chartiere5f13e52015-02-24 09:37:21 -080051class JitOptions;
52
Nicolas Geoffray274fe4a2016-04-12 16:33:24 +010053static constexpr int16_t kJitCheckForOSR = -1;
54static constexpr int16_t kJitHotnessDisabled = -2;
Nicolas Geoffray47b95802018-05-16 15:42:17 +010055// At what priority to schedule jit threads. 9 is the lowest foreground priority on device.
56// See android/os/Process.java.
57static constexpr int kJitPoolThreadPthreadDefaultPriority = 9;
David Srbecky81448a22019-08-01 14:29:53 +010058// We check whether to jit-compile the method every Nth invoke.
59// The tests often use threshold of 1000 (and thus 500 to start profiling).
60static constexpr uint32_t kJitSamplesBatchSize = 512; // Must be power of 2.
Nicolas Geoffray47b95802018-05-16 15:42:17 +010061
62class JitOptions {
63 public:
64 static JitOptions* CreateFromRuntimeArguments(const RuntimeArgumentMap& options);
65
66 uint16_t GetCompileThreshold() const {
67 return compile_threshold_;
68 }
69
70 uint16_t GetWarmupThreshold() const {
71 return warmup_threshold_;
72 }
73
74 uint16_t GetOsrThreshold() const {
75 return osr_threshold_;
76 }
77
78 uint16_t GetPriorityThreadWeight() const {
79 return priority_thread_weight_;
80 }
81
82 uint16_t GetInvokeTransitionWeight() const {
83 return invoke_transition_weight_;
84 }
85
86 size_t GetCodeCacheInitialCapacity() const {
87 return code_cache_initial_capacity_;
88 }
89
90 size_t GetCodeCacheMaxCapacity() const {
91 return code_cache_max_capacity_;
92 }
93
94 bool DumpJitInfoOnShutdown() const {
95 return dump_info_on_shutdown_;
96 }
97
98 const ProfileSaverOptions& GetProfileSaverOptions() const {
99 return profile_saver_options_;
100 }
101
102 bool GetSaveProfilingInfo() const {
103 return profile_saver_options_.IsEnabled();
104 }
105
106 int GetThreadPoolPthreadPriority() const {
107 return thread_pool_pthread_priority_;
108 }
109
110 bool UseJitCompilation() const {
111 return use_jit_compilation_;
112 }
113
114 void SetUseJitCompilation(bool b) {
115 use_jit_compilation_ = b;
116 }
117
118 void SetSaveProfilingInfo(bool save_profiling_info) {
119 profile_saver_options_.SetEnabled(save_profiling_info);
120 }
121
122 void SetWaitForJitNotificationsToSaveProfile(bool value) {
123 profile_saver_options_.SetWaitForJitNotificationsToSave(value);
124 }
125
126 void SetProfileAOTCode(bool value) {
127 profile_saver_options_.SetProfileAOTCode(value);
128 }
129
130 void SetJitAtFirstUse() {
131 use_jit_compilation_ = true;
132 compile_threshold_ = 0;
133 }
134
135 private:
David Srbeckye3fc2d12018-11-30 13:41:14 +0000136 // We add the sample in batches of size kJitSamplesBatchSize.
137 // This method rounds the threshold so that it is multiple of the batch size.
138 static uint32_t RoundUpThreshold(uint32_t threshold);
139
Nicolas Geoffray47b95802018-05-16 15:42:17 +0100140 bool use_jit_compilation_;
141 size_t code_cache_initial_capacity_;
142 size_t code_cache_max_capacity_;
David Srbeckye3fc2d12018-11-30 13:41:14 +0000143 uint32_t compile_threshold_;
144 uint32_t warmup_threshold_;
145 uint32_t osr_threshold_;
Nicolas Geoffray47b95802018-05-16 15:42:17 +0100146 uint16_t priority_thread_weight_;
147 uint16_t invoke_transition_weight_;
148 bool dump_info_on_shutdown_;
149 int thread_pool_pthread_priority_;
150 ProfileSaverOptions profile_saver_options_;
151
152 JitOptions()
153 : use_jit_compilation_(false),
154 code_cache_initial_capacity_(0),
155 code_cache_max_capacity_(0),
156 compile_threshold_(0),
157 warmup_threshold_(0),
158 osr_threshold_(0),
159 priority_thread_weight_(0),
160 invoke_transition_weight_(0),
161 dump_info_on_shutdown_(false),
Nicolas Geoffrayc9de61c2018-11-27 17:34:31 +0000162 thread_pool_pthread_priority_(kJitPoolThreadPthreadDefaultPriority) {}
Nicolas Geoffray47b95802018-05-16 15:42:17 +0100163
164 DISALLOW_COPY_AND_ASSIGN(JitOptions);
165};
Nicolas Geoffray274fe4a2016-04-12 16:33:24 +0100166
Mathieu Chartiere5f13e52015-02-24 09:37:21 -0800167class Jit {
168 public:
Nicolas Geoffray71cd50f2016-04-14 15:00:33 +0100169 static constexpr size_t kDefaultPriorityThreadWeightRatio = 1000;
Nicolas Geoffraybd553eb2016-04-28 13:56:04 +0100170 static constexpr size_t kDefaultInvokeTransitionWeightRatio = 500;
buzbee42a09cb02017-02-01 09:08:31 -0800171 // How frequently should the interpreter check to see if OSR compilation is ready.
David Srbeckye3fc2d12018-11-30 13:41:14 +0000172 static constexpr int16_t kJitRecheckOSRThreshold = 101; // Prime number to avoid patterns.
Mathieu Chartiere5f13e52015-02-24 09:37:21 -0800173
David Srbecky21821472019-07-29 15:10:31 +0100174 DECLARE_RUNTIME_DEBUG_FLAG(kSlowMode);
175
Mathieu Chartiere5f13e52015-02-24 09:37:21 -0800176 virtual ~Jit();
Orion Hodsonad28f5e2018-10-17 09:08:17 +0100177
178 // Create JIT itself.
179 static Jit* Create(JitCodeCache* code_cache, JitOptions* options);
180
Nicolas Geoffrayd2f13ba2019-06-04 16:48:58 +0100181 bool CompileMethod(ArtMethod* method, Thread* self, bool baseline, bool osr, bool prejit)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700182 REQUIRES_SHARED(Locks::mutator_lock_);
Nicolas Geoffray274fe4a2016-04-12 16:33:24 +0100183
Mathieu Chartiere5f13e52015-02-24 09:37:21 -0800184 const JitCodeCache* GetCodeCache() const {
Orion Hodsonad28f5e2018-10-17 09:08:17 +0100185 return code_cache_;
Mathieu Chartiere5f13e52015-02-24 09:37:21 -0800186 }
Nicolas Geoffray274fe4a2016-04-12 16:33:24 +0100187
Mathieu Chartiere5f13e52015-02-24 09:37:21 -0800188 JitCodeCache* GetCodeCache() {
Orion Hodsonad28f5e2018-10-17 09:08:17 +0100189 return code_cache_;
Mathieu Chartiere5f13e52015-02-24 09:37:21 -0800190 }
Nicolas Geoffray274fe4a2016-04-12 16:33:24 +0100191
Orion Hodsonad28f5e2018-10-17 09:08:17 +0100192 void CreateThreadPool();
Mathieu Chartiere5f13e52015-02-24 09:37:21 -0800193 void DeleteThreadPool();
Mathieu Chartier93c21ba2018-12-10 13:08:30 -0800194 void WaitForWorkersToBeCreated();
Orion Hodsonad28f5e2018-10-17 09:08:17 +0100195
Mathieu Chartiera4885cb2015-03-09 15:38:54 -0700196 // Dump interesting info: #methods compiled, code vs data size, compile / verify cumulative
197 // loggers.
Nicolas Geoffraya4f81542016-03-08 16:57:48 +0000198 void DumpInfo(std::ostream& os) REQUIRES(!lock_);
Mathieu Chartiera4885cb2015-03-09 15:38:54 -0700199 // Add a timing logger to cumulative_timings_.
200 void AddTimingLogger(const TimingLogger& logger);
Nicolas Geoffraya4f81542016-03-08 16:57:48 +0000201
202 void AddMemoryUsage(ArtMethod* method, size_t bytes)
203 REQUIRES(!lock_)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700204 REQUIRES_SHARED(Locks::mutator_lock_);
Nicolas Geoffraya4f81542016-03-08 16:57:48 +0000205
Nicolas Geoffray47b95802018-05-16 15:42:17 +0100206 uint16_t OSRMethodThreshold() const {
207 return options_->GetOsrThreshold();
Mathieu Chartiera50f9cf2015-09-25 11:34:45 -0700208 }
Mathieu Chartiere5f13e52015-02-24 09:37:21 -0800209
Nicolas Geoffray47b95802018-05-16 15:42:17 +0100210 uint16_t HotMethodThreshold() const {
211 return options_->GetCompileThreshold();
Nicolas Geoffray274fe4a2016-04-12 16:33:24 +0100212 }
213
Nicolas Geoffray47b95802018-05-16 15:42:17 +0100214 uint16_t WarmMethodThreshold() const {
215 return options_->GetWarmupThreshold();
Nicolas Geoffray274fe4a2016-04-12 16:33:24 +0100216 }
217
218 uint16_t PriorityThreadWeight() const {
Nicolas Geoffray47b95802018-05-16 15:42:17 +0100219 return options_->GetPriorityThreadWeight();
Nicolas Geoffray274fe4a2016-04-12 16:33:24 +0100220 }
221
Nicolas Geoffraya48c3df2019-06-27 13:11:12 +0000222 // Return whether we should do JIT compilation. Note this will returns false
223 // if we only need to save profile information and not compile methods.
Nicolas Geoffray2fef66b2019-06-26 22:00:02 +0000224 bool UseJitCompilation() const {
225 return options_->UseJitCompilation();
226 }
Calin Juravleffc87072016-04-20 14:22:09 +0100227
Calin Juravle138dbff2016-06-28 19:36:58 +0100228 bool GetSaveProfilingInfo() const {
Nicolas Geoffray47b95802018-05-16 15:42:17 +0100229 return options_->GetSaveProfilingInfo();
Calin Juravleffc87072016-04-20 14:22:09 +0100230 }
231
Nicolas Geoffray274fe4a2016-04-12 16:33:24 +0100232 // Wait until there is no more pending compilation tasks.
233 void WaitForCompilationToFinish(Thread* self);
234
235 // Profiling methods.
236 void MethodEntered(Thread* thread, ArtMethod* method)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700237 REQUIRES_SHARED(Locks::mutator_lock_);
Nicolas Geoffray274fe4a2016-04-12 16:33:24 +0100238
David Srbeckye3fc2d12018-11-30 13:41:14 +0000239 ALWAYS_INLINE void AddSamples(Thread* self,
240 ArtMethod* method,
241 uint16_t samples,
242 bool with_backedges)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700243 REQUIRES_SHARED(Locks::mutator_lock_);
Nicolas Geoffray274fe4a2016-04-12 16:33:24 +0100244
Mathieu Chartieref41db72016-10-25 15:08:01 -0700245 void InvokeVirtualOrInterface(ObjPtr<mirror::Object> this_object,
Nicolas Geoffray274fe4a2016-04-12 16:33:24 +0100246 ArtMethod* caller,
247 uint32_t dex_pc,
248 ArtMethod* callee)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700249 REQUIRES_SHARED(Locks::mutator_lock_);
Nicolas Geoffray274fe4a2016-04-12 16:33:24 +0100250
Nicolas Geoffray71cd50f2016-04-14 15:00:33 +0100251 void NotifyInterpreterToCompiledCodeTransition(Thread* self, ArtMethod* caller)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700252 REQUIRES_SHARED(Locks::mutator_lock_) {
Nicolas Geoffray47b95802018-05-16 15:42:17 +0100253 AddSamples(self, caller, options_->GetInvokeTransitionWeight(), false);
Nicolas Geoffray71cd50f2016-04-14 15:00:33 +0100254 }
255
256 void NotifyCompiledCodeToInterpreterTransition(Thread* self, ArtMethod* callee)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700257 REQUIRES_SHARED(Locks::mutator_lock_) {
Nicolas Geoffray47b95802018-05-16 15:42:17 +0100258 AddSamples(self, callee, options_->GetInvokeTransitionWeight(), false);
Nicolas Geoffray71cd50f2016-04-14 15:00:33 +0100259 }
260
Calin Juravlec90bc922016-02-24 10:13:09 +0000261 // Starts the profile saver if the config options allow profile recording.
262 // The profile will be stored in the specified `filename` and will contain
263 // information collected from the given `code_paths` (a set of dex locations).
Calin Juravlec90bc922016-02-24 10:13:09 +0000264 void StartProfileSaver(const std::string& filename,
Calin Juravle77651c42017-03-03 18:04:02 -0800265 const std::vector<std::string>& code_paths);
Calin Juravle4d77b6a2015-12-01 18:38:09 +0000266 void StopProfileSaver();
Calin Juravle31f2c152015-10-23 17:56:15 +0100267
Calin Juravleb8e69992016-03-09 15:37:48 +0000268 void DumpForSigQuit(std::ostream& os) REQUIRES(!lock_);
Nicolas Geoffrayaee21562015-12-15 16:39:44 +0000269
Tamas Berghammer160e6df2016-01-05 14:29:02 +0000270 static void NewTypeLoadedIfUsingJit(mirror::Class* type)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700271 REQUIRES_SHARED(Locks::mutator_lock_);
Tamas Berghammer160e6df2016-01-05 14:29:02 +0000272
Tamas Berghammerfffbee42016-01-15 13:09:34 +0000273 // If debug info generation is turned on then write the type information for types already loaded
274 // into the specified class linker to the jit debug interface,
275 void DumpTypeInfoForLoadedTypes(ClassLinker* linker);
276
Nicolas Geoffray35122442016-03-02 12:05:30 +0000277 // Return whether we should try to JIT compiled code as soon as an ArtMethod is invoked.
Siva Chandra05d24152016-01-05 17:43:17 -0800278 bool JitAtFirstUse();
279
Nicolas Geoffray35122442016-03-02 12:05:30 +0000280 // Return whether we can invoke JIT code for `method`.
281 bool CanInvokeCompiledCode(ArtMethod* method);
282
Calin Juravleb2771b42016-04-07 17:09:25 +0100283 // Return whether the runtime should use a priority thread weight when sampling.
Vladimir Markoa710d912017-09-12 14:56:07 +0100284 static bool ShouldUsePriorityThreadWeight(Thread* self);
Calin Juravleb2771b42016-04-07 17:09:25 +0100285
Nicolas Geoffrayb331feb2016-02-05 16:51:53 +0000286 // If an OSR compiled version is available for `method`,
287 // and `dex_pc + dex_pc_offset` is an entry point of that compiled
288 // version, this method will jump to the compiled code, let it run,
289 // and return true afterwards. Return false otherwise.
290 static bool MaybeDoOnStackReplacement(Thread* thread,
291 ArtMethod* method,
292 uint32_t dex_pc,
293 int32_t dex_pc_offset,
294 JValue* result)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700295 REQUIRES_SHARED(Locks::mutator_lock_);
Nicolas Geoffrayb331feb2016-02-05 16:51:53 +0000296
Nicolas Geoffraya7edd0d2018-11-07 03:18:16 +0000297 // Load the compiler library.
298 static bool LoadCompilerLibrary(std::string* error_msg);
Mathieu Chartier72918ea2016-03-24 11:07:06 -0700299
Andreas Gampef149b3f2016-11-16 14:58:24 -0800300 ThreadPool* GetThreadPool() const {
301 return thread_pool_.get();
302 }
303
Nicolas Geoffray021c5f22016-12-16 11:22:05 +0000304 // Stop the JIT by waiting for all current compilations and enqueued compilations to finish.
305 void Stop();
306
307 // Start JIT threads.
308 void Start();
309
Nicolas Geoffrayce9ed362018-11-29 03:19:28 +0000310 // Transition to a child state.
Nicolas Geoffray0d54cfb2019-05-03 09:13:52 +0100311 void PostForkChildAction(bool is_system_server, bool is_zygote);
Nicolas Geoffrayce9ed362018-11-29 03:19:28 +0000312
313 // Prepare for forking.
314 void PreZygoteFork();
315
316 // Adjust state after forking.
317 void PostZygoteFork();
Nicolas Geoffrayc9de61c2018-11-27 17:34:31 +0000318
Nicolas Geoffray0f8950a2019-07-24 13:22:11 +0100319 // Compile methods from the given profile (.prof extension). If `add_to_queue`
320 // is true, methods in the profile are added to the JIT queue. Otherwise they are compiled
Nicolas Geoffray9ac09ee2019-05-08 23:38:27 +0100321 // directly.
Nicolas Geoffraye32d24c2019-07-05 10:28:59 +0100322 // Return the number of methods added to the queue.
323 uint32_t CompileMethodsFromProfile(Thread* self,
324 const std::vector<const DexFile*>& dex_files,
325 const std::string& profile_path,
326 Handle<mirror::ClassLoader> class_loader,
327 bool add_to_queue);
Nicolas Geoffray9ac09ee2019-05-08 23:38:27 +0100328
Nicolas Geoffray0f8950a2019-07-24 13:22:11 +0100329 // Compile methods from the given boot profile (.bprof extension). If `add_to_queue`
330 // is true, methods in the profile are added to the JIT queue. Otherwise they are compiled
331 // directly.
332 // Return the number of methods added to the queue.
333 uint32_t CompileMethodsFromBootProfile(Thread* self,
334 const std::vector<const DexFile*>& dex_files,
335 const std::string& profile_path,
336 Handle<mirror::ClassLoader> class_loader,
337 bool add_to_queue);
338
Nicolas Geoffray9ac09ee2019-05-08 23:38:27 +0100339 // Register the dex files to the JIT. This is to perform any compilation/optimization
340 // at the point of loading the dex files.
341 void RegisterDexFiles(const std::vector<std::unique_ptr<const DexFile>>& dex_files,
Nicolas Geoffray741a0702019-06-10 11:18:11 +0100342 jobject class_loader);
Nicolas Geoffrayde1b2a22019-02-27 09:10:57 +0000343
Nicolas Geoffraya48c3df2019-06-27 13:11:12 +0000344 // Called by the compiler to know whether it can directly encode the
345 // method/class/string.
Nicolas Geoffray05b41c42019-06-28 12:46:33 +0100346 bool CanEncodeMethod(ArtMethod* method, bool is_for_shared_region) const
347 REQUIRES_SHARED(Locks::mutator_lock_);
Nicolas Geoffraya48c3df2019-06-27 13:11:12 +0000348 bool CanEncodeClass(ObjPtr<mirror::Class> cls, bool is_for_shared_region) const
349 REQUIRES_SHARED(Locks::mutator_lock_);
350 bool CanEncodeString(ObjPtr<mirror::String> string, bool is_for_shared_region) const
351 REQUIRES_SHARED(Locks::mutator_lock_);
352 bool CanAssumeInitialized(ObjPtr<mirror::Class> cls, bool is_for_shared_region) const
353 REQUIRES_SHARED(Locks::mutator_lock_);
354
Mathieu Chartiere5f13e52015-02-24 09:37:21 -0800355 private:
Orion Hodsonad28f5e2018-10-17 09:08:17 +0100356 Jit(JitCodeCache* code_cache, JitOptions* options);
Mathieu Chartiere5f13e52015-02-24 09:37:21 -0800357
Nicolas Geoffray0f8950a2019-07-24 13:22:11 +0100358 // Compile an individual method listed in a profile. If `add_to_queue` is
359 // true and the method was resolved, return true. Otherwise return false.
360 bool CompileMethodFromProfile(Thread* self,
361 ClassLinker* linker,
362 uint32_t method_idx,
363 Handle<mirror::DexCache> dex_cache,
364 Handle<mirror::ClassLoader> class_loader,
365 bool add_to_queue)
366 REQUIRES_SHARED(Locks::mutator_lock_);
367
David Srbeckye3fc2d12018-11-30 13:41:14 +0000368 // Compile the method if the number of samples passes a threshold.
369 // Returns false if we can not compile now - don't increment the counter and retry later.
370 bool MaybeCompileMethod(Thread* self,
371 ArtMethod* method,
372 uint32_t old_count,
373 uint32_t new_count,
374 bool with_backedges)
375 REQUIRES_SHARED(Locks::mutator_lock_);
376
Orion Hodsonad28f5e2018-10-17 09:08:17 +0100377 static bool BindCompilerMethods(std::string* error_msg);
Mathieu Chartierc1bc4152016-03-24 17:22:52 -0700378
Mathieu Chartiere5f13e52015-02-24 09:37:21 -0800379 // JIT compiler
Mathieu Chartier72918ea2016-03-24 11:07:06 -0700380 static void* jit_library_handle_;
381 static void* jit_compiler_handle_;
Nicolas Geoffrayc9de61c2018-11-27 17:34:31 +0000382 static void* (*jit_load_)(void);
Mathieu Chartier72918ea2016-03-24 11:07:06 -0700383 static void (*jit_unload_)(void*);
Nicolas Geoffray7f7539b2019-06-06 16:20:54 +0100384 static bool (*jit_compile_method_)(void*, JitMemoryRegion*, ArtMethod*, Thread*, bool, bool);
Mathieu Chartier72918ea2016-03-24 11:07:06 -0700385 static void (*jit_types_loaded_)(void*, mirror::Class**, size_t count);
Nicolas Geoffrayc9de61c2018-11-27 17:34:31 +0000386 static void (*jit_update_options_)(void*);
387 static bool (*jit_generate_debug_info_)(void*);
388 template <typename T> static bool LoadSymbol(T*, const char* symbol, std::string* error_msg);
Nicolas Geoffray47b95802018-05-16 15:42:17 +0100389
Orion Hodsonad28f5e2018-10-17 09:08:17 +0100390 // JIT resources owned by runtime.
391 jit::JitCodeCache* const code_cache_;
Nicolas Geoffray47b95802018-05-16 15:42:17 +0100392 const JitOptions* const options_;
393
Nicolas Geoffray47b95802018-05-16 15:42:17 +0100394 std::unique_ptr<ThreadPool> thread_pool_;
Nicolas Geoffraydc2fbb62019-04-11 22:55:50 +0100395 std::vector<std::unique_ptr<OatDexFile>> type_lookup_tables_;
Nicolas Geoffray47b95802018-05-16 15:42:17 +0100396
Mathieu Chartiera4885cb2015-03-09 15:38:54 -0700397 // Performance monitoring.
Mathieu Chartiera4885cb2015-03-09 15:38:54 -0700398 CumulativeLogger cumulative_timings_;
Nicolas Geoffraya4f81542016-03-08 16:57:48 +0000399 Histogram<uint64_t> memory_use_ GUARDED_BY(lock_);
400 Mutex lock_ DEFAULT_MUTEX_ACQUIRED_AFTER;
Mathieu Chartiera4885cb2015-03-09 15:38:54 -0700401
Mathieu Chartier3130cdf2015-05-03 15:20:23 -0700402 DISALLOW_COPY_AND_ASSIGN(Jit);
Mathieu Chartiere5f13e52015-02-24 09:37:21 -0800403};
404
Andreas Gampef149b3f2016-11-16 14:58:24 -0800405// Helper class to stop the JIT for a given scope. This will wait for the JIT to quiesce.
406class ScopedJitSuspend {
407 public:
408 ScopedJitSuspend();
409 ~ScopedJitSuspend();
410
411 private:
412 bool was_on_;
413};
414
Mathieu Chartiere5f13e52015-02-24 09:37:21 -0800415} // namespace jit
416} // namespace art
417
418#endif // ART_RUNTIME_JIT_JIT_H_