blob: 0147f3732581820a06ef00b01645690338660c89 [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"
Mathieu Chartiera4885cb2015-03-09 15:38:54 -070023#include "base/timing_logger.h"
Nicolas Geoffray9ac09ee2019-05-08 23:38:27 +010024#include "handle.h"
Mathieu Chartieref41db72016-10-25 15:08:01 -070025#include "jit/profile_saver_options.h"
26#include "obj_ptr.h"
Mathieu Chartiere5f13e52015-02-24 09:37:21 -080027#include "thread_pool.h"
28
29namespace art {
30
Mathieu Chartiere401d142015-04-22 13:56:20 -070031class ArtMethod;
David Sehr9323e6e2016-09-13 08:58:35 -070032class ClassLinker;
Nicolas Geoffray9ac09ee2019-05-08 23:38:27 +010033class DexFile;
Nicolas Geoffraydc2fbb62019-04-11 22:55:50 +010034class OatDexFile;
Mathieu Chartiere5f13e52015-02-24 09:37:21 -080035struct RuntimeArgumentMap;
Vladimir Marko3a21e382016-09-02 12:38:38 +010036union JValue;
Mathieu Chartiere5f13e52015-02-24 09:37:21 -080037
David Sehr709b0702016-10-13 09:12:37 -070038namespace mirror {
39class Object;
40class Class;
Nicolas Geoffray9ac09ee2019-05-08 23:38:27 +010041class ClassLoader;
Nicolas Geoffray0f8950a2019-07-24 13:22:11 +010042class DexCache;
Nicolas Geoffraya48c3df2019-06-27 13:11:12 +000043class String;
David Sehr709b0702016-10-13 09:12:37 -070044} // namespace mirror
45
Mathieu Chartiere5f13e52015-02-24 09:37:21 -080046namespace jit {
47
48class JitCodeCache;
Nicolas Geoffray7f7539b2019-06-06 16:20:54 +010049class JitMemoryRegion;
Mathieu Chartiere5f13e52015-02-24 09:37:21 -080050class JitOptions;
51
Nicolas Geoffray274fe4a2016-04-12 16:33:24 +010052static constexpr int16_t kJitCheckForOSR = -1;
53static constexpr int16_t kJitHotnessDisabled = -2;
Nicolas Geoffray47b95802018-05-16 15:42:17 +010054// At what priority to schedule jit threads. 9 is the lowest foreground priority on device.
55// See android/os/Process.java.
56static constexpr int kJitPoolThreadPthreadDefaultPriority = 9;
David Srbeckye3fc2d12018-11-30 13:41:14 +000057static constexpr uint32_t kJitSamplesBatchSize = 32; // Must be power of 2.
Nicolas Geoffray47b95802018-05-16 15:42:17 +010058
59class JitOptions {
60 public:
61 static JitOptions* CreateFromRuntimeArguments(const RuntimeArgumentMap& options);
62
63 uint16_t GetCompileThreshold() const {
64 return compile_threshold_;
65 }
66
67 uint16_t GetWarmupThreshold() const {
68 return warmup_threshold_;
69 }
70
71 uint16_t GetOsrThreshold() const {
72 return osr_threshold_;
73 }
74
75 uint16_t GetPriorityThreadWeight() const {
76 return priority_thread_weight_;
77 }
78
79 uint16_t GetInvokeTransitionWeight() const {
80 return invoke_transition_weight_;
81 }
82
83 size_t GetCodeCacheInitialCapacity() const {
84 return code_cache_initial_capacity_;
85 }
86
87 size_t GetCodeCacheMaxCapacity() const {
88 return code_cache_max_capacity_;
89 }
90
91 bool DumpJitInfoOnShutdown() const {
92 return dump_info_on_shutdown_;
93 }
94
95 const ProfileSaverOptions& GetProfileSaverOptions() const {
96 return profile_saver_options_;
97 }
98
99 bool GetSaveProfilingInfo() const {
100 return profile_saver_options_.IsEnabled();
101 }
102
103 int GetThreadPoolPthreadPriority() const {
104 return thread_pool_pthread_priority_;
105 }
106
107 bool UseJitCompilation() const {
108 return use_jit_compilation_;
109 }
110
111 void SetUseJitCompilation(bool b) {
112 use_jit_compilation_ = b;
113 }
114
115 void SetSaveProfilingInfo(bool save_profiling_info) {
116 profile_saver_options_.SetEnabled(save_profiling_info);
117 }
118
119 void SetWaitForJitNotificationsToSaveProfile(bool value) {
120 profile_saver_options_.SetWaitForJitNotificationsToSave(value);
121 }
122
123 void SetProfileAOTCode(bool value) {
124 profile_saver_options_.SetProfileAOTCode(value);
125 }
126
127 void SetJitAtFirstUse() {
128 use_jit_compilation_ = true;
129 compile_threshold_ = 0;
130 }
131
132 private:
David Srbeckye3fc2d12018-11-30 13:41:14 +0000133 // We add the sample in batches of size kJitSamplesBatchSize.
134 // This method rounds the threshold so that it is multiple of the batch size.
135 static uint32_t RoundUpThreshold(uint32_t threshold);
136
Nicolas Geoffray47b95802018-05-16 15:42:17 +0100137 bool use_jit_compilation_;
138 size_t code_cache_initial_capacity_;
139 size_t code_cache_max_capacity_;
David Srbeckye3fc2d12018-11-30 13:41:14 +0000140 uint32_t compile_threshold_;
141 uint32_t warmup_threshold_;
142 uint32_t osr_threshold_;
Nicolas Geoffray47b95802018-05-16 15:42:17 +0100143 uint16_t priority_thread_weight_;
144 uint16_t invoke_transition_weight_;
145 bool dump_info_on_shutdown_;
146 int thread_pool_pthread_priority_;
147 ProfileSaverOptions profile_saver_options_;
148
149 JitOptions()
150 : use_jit_compilation_(false),
151 code_cache_initial_capacity_(0),
152 code_cache_max_capacity_(0),
153 compile_threshold_(0),
154 warmup_threshold_(0),
155 osr_threshold_(0),
156 priority_thread_weight_(0),
157 invoke_transition_weight_(0),
158 dump_info_on_shutdown_(false),
Nicolas Geoffrayc9de61c2018-11-27 17:34:31 +0000159 thread_pool_pthread_priority_(kJitPoolThreadPthreadDefaultPriority) {}
Nicolas Geoffray47b95802018-05-16 15:42:17 +0100160
161 DISALLOW_COPY_AND_ASSIGN(JitOptions);
162};
Nicolas Geoffray274fe4a2016-04-12 16:33:24 +0100163
Mathieu Chartiere5f13e52015-02-24 09:37:21 -0800164class Jit {
165 public:
Nicolas Geoffray71cd50f2016-04-14 15:00:33 +0100166 static constexpr size_t kDefaultPriorityThreadWeightRatio = 1000;
Nicolas Geoffraybd553eb2016-04-28 13:56:04 +0100167 static constexpr size_t kDefaultInvokeTransitionWeightRatio = 500;
buzbee42a09cb02017-02-01 09:08:31 -0800168 // How frequently should the interpreter check to see if OSR compilation is ready.
David Srbeckye3fc2d12018-11-30 13:41:14 +0000169 static constexpr int16_t kJitRecheckOSRThreshold = 101; // Prime number to avoid patterns.
Mathieu Chartiere5f13e52015-02-24 09:37:21 -0800170
171 virtual ~Jit();
Orion Hodsonad28f5e2018-10-17 09:08:17 +0100172
173 // Create JIT itself.
174 static Jit* Create(JitCodeCache* code_cache, JitOptions* options);
175
Nicolas Geoffrayd2f13ba2019-06-04 16:48:58 +0100176 bool CompileMethod(ArtMethod* method, Thread* self, bool baseline, bool osr, bool prejit)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700177 REQUIRES_SHARED(Locks::mutator_lock_);
Nicolas Geoffray274fe4a2016-04-12 16:33:24 +0100178
Mathieu Chartiere5f13e52015-02-24 09:37:21 -0800179 const JitCodeCache* GetCodeCache() const {
Orion Hodsonad28f5e2018-10-17 09:08:17 +0100180 return code_cache_;
Mathieu Chartiere5f13e52015-02-24 09:37:21 -0800181 }
Nicolas Geoffray274fe4a2016-04-12 16:33:24 +0100182
Mathieu Chartiere5f13e52015-02-24 09:37:21 -0800183 JitCodeCache* GetCodeCache() {
Orion Hodsonad28f5e2018-10-17 09:08:17 +0100184 return code_cache_;
Mathieu Chartiere5f13e52015-02-24 09:37:21 -0800185 }
Nicolas Geoffray274fe4a2016-04-12 16:33:24 +0100186
Orion Hodsonad28f5e2018-10-17 09:08:17 +0100187 void CreateThreadPool();
Mathieu Chartiere5f13e52015-02-24 09:37:21 -0800188 void DeleteThreadPool();
Mathieu Chartier93c21ba2018-12-10 13:08:30 -0800189 void WaitForWorkersToBeCreated();
Orion Hodsonad28f5e2018-10-17 09:08:17 +0100190
Mathieu Chartiera4885cb2015-03-09 15:38:54 -0700191 // Dump interesting info: #methods compiled, code vs data size, compile / verify cumulative
192 // loggers.
Nicolas Geoffraya4f81542016-03-08 16:57:48 +0000193 void DumpInfo(std::ostream& os) REQUIRES(!lock_);
Mathieu Chartiera4885cb2015-03-09 15:38:54 -0700194 // Add a timing logger to cumulative_timings_.
195 void AddTimingLogger(const TimingLogger& logger);
Nicolas Geoffraya4f81542016-03-08 16:57:48 +0000196
197 void AddMemoryUsage(ArtMethod* method, size_t bytes)
198 REQUIRES(!lock_)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700199 REQUIRES_SHARED(Locks::mutator_lock_);
Nicolas Geoffraya4f81542016-03-08 16:57:48 +0000200
Nicolas Geoffray47b95802018-05-16 15:42:17 +0100201 uint16_t OSRMethodThreshold() const {
202 return options_->GetOsrThreshold();
Mathieu Chartiera50f9cf2015-09-25 11:34:45 -0700203 }
Mathieu Chartiere5f13e52015-02-24 09:37:21 -0800204
Nicolas Geoffray47b95802018-05-16 15:42:17 +0100205 uint16_t HotMethodThreshold() const {
206 return options_->GetCompileThreshold();
Nicolas Geoffray274fe4a2016-04-12 16:33:24 +0100207 }
208
Nicolas Geoffray47b95802018-05-16 15:42:17 +0100209 uint16_t WarmMethodThreshold() const {
210 return options_->GetWarmupThreshold();
Nicolas Geoffray274fe4a2016-04-12 16:33:24 +0100211 }
212
213 uint16_t PriorityThreadWeight() const {
Nicolas Geoffray47b95802018-05-16 15:42:17 +0100214 return options_->GetPriorityThreadWeight();
Nicolas Geoffray274fe4a2016-04-12 16:33:24 +0100215 }
216
Nicolas Geoffraya48c3df2019-06-27 13:11:12 +0000217 // Return whether we should do JIT compilation. Note this will returns false
218 // if we only need to save profile information and not compile methods.
Nicolas Geoffray2fef66b2019-06-26 22:00:02 +0000219 bool UseJitCompilation() const {
220 return options_->UseJitCompilation();
221 }
Calin Juravleffc87072016-04-20 14:22:09 +0100222
Calin Juravle138dbff2016-06-28 19:36:58 +0100223 bool GetSaveProfilingInfo() const {
Nicolas Geoffray47b95802018-05-16 15:42:17 +0100224 return options_->GetSaveProfilingInfo();
Calin Juravleffc87072016-04-20 14:22:09 +0100225 }
226
Nicolas Geoffray274fe4a2016-04-12 16:33:24 +0100227 // Wait until there is no more pending compilation tasks.
228 void WaitForCompilationToFinish(Thread* self);
229
230 // Profiling methods.
231 void MethodEntered(Thread* thread, ArtMethod* method)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700232 REQUIRES_SHARED(Locks::mutator_lock_);
Nicolas Geoffray274fe4a2016-04-12 16:33:24 +0100233
David Srbeckye3fc2d12018-11-30 13:41:14 +0000234 ALWAYS_INLINE void AddSamples(Thread* self,
235 ArtMethod* method,
236 uint16_t samples,
237 bool with_backedges)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700238 REQUIRES_SHARED(Locks::mutator_lock_);
Nicolas Geoffray274fe4a2016-04-12 16:33:24 +0100239
Mathieu Chartieref41db72016-10-25 15:08:01 -0700240 void InvokeVirtualOrInterface(ObjPtr<mirror::Object> this_object,
Nicolas Geoffray274fe4a2016-04-12 16:33:24 +0100241 ArtMethod* caller,
242 uint32_t dex_pc,
243 ArtMethod* callee)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700244 REQUIRES_SHARED(Locks::mutator_lock_);
Nicolas Geoffray274fe4a2016-04-12 16:33:24 +0100245
Nicolas Geoffray71cd50f2016-04-14 15:00:33 +0100246 void NotifyInterpreterToCompiledCodeTransition(Thread* self, ArtMethod* caller)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700247 REQUIRES_SHARED(Locks::mutator_lock_) {
Nicolas Geoffray47b95802018-05-16 15:42:17 +0100248 AddSamples(self, caller, options_->GetInvokeTransitionWeight(), false);
Nicolas Geoffray71cd50f2016-04-14 15:00:33 +0100249 }
250
251 void NotifyCompiledCodeToInterpreterTransition(Thread* self, ArtMethod* callee)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700252 REQUIRES_SHARED(Locks::mutator_lock_) {
Nicolas Geoffray47b95802018-05-16 15:42:17 +0100253 AddSamples(self, callee, options_->GetInvokeTransitionWeight(), false);
Nicolas Geoffray71cd50f2016-04-14 15:00:33 +0100254 }
255
Calin Juravlec90bc922016-02-24 10:13:09 +0000256 // Starts the profile saver if the config options allow profile recording.
257 // The profile will be stored in the specified `filename` and will contain
258 // information collected from the given `code_paths` (a set of dex locations).
Calin Juravlec90bc922016-02-24 10:13:09 +0000259 void StartProfileSaver(const std::string& filename,
Calin Juravle77651c42017-03-03 18:04:02 -0800260 const std::vector<std::string>& code_paths);
Calin Juravle4d77b6a2015-12-01 18:38:09 +0000261 void StopProfileSaver();
Calin Juravle31f2c152015-10-23 17:56:15 +0100262
Calin Juravleb8e69992016-03-09 15:37:48 +0000263 void DumpForSigQuit(std::ostream& os) REQUIRES(!lock_);
Nicolas Geoffrayaee21562015-12-15 16:39:44 +0000264
Tamas Berghammer160e6df2016-01-05 14:29:02 +0000265 static void NewTypeLoadedIfUsingJit(mirror::Class* type)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700266 REQUIRES_SHARED(Locks::mutator_lock_);
Tamas Berghammer160e6df2016-01-05 14:29:02 +0000267
Tamas Berghammerfffbee42016-01-15 13:09:34 +0000268 // If debug info generation is turned on then write the type information for types already loaded
269 // into the specified class linker to the jit debug interface,
270 void DumpTypeInfoForLoadedTypes(ClassLinker* linker);
271
Nicolas Geoffray35122442016-03-02 12:05:30 +0000272 // Return whether we should try to JIT compiled code as soon as an ArtMethod is invoked.
Siva Chandra05d24152016-01-05 17:43:17 -0800273 bool JitAtFirstUse();
274
Nicolas Geoffray35122442016-03-02 12:05:30 +0000275 // Return whether we can invoke JIT code for `method`.
276 bool CanInvokeCompiledCode(ArtMethod* method);
277
Calin Juravleb2771b42016-04-07 17:09:25 +0100278 // Return whether the runtime should use a priority thread weight when sampling.
Vladimir Markoa710d912017-09-12 14:56:07 +0100279 static bool ShouldUsePriorityThreadWeight(Thread* self);
Calin Juravleb2771b42016-04-07 17:09:25 +0100280
Nicolas Geoffrayb331feb2016-02-05 16:51:53 +0000281 // If an OSR compiled version is available for `method`,
282 // and `dex_pc + dex_pc_offset` is an entry point of that compiled
283 // version, this method will jump to the compiled code, let it run,
284 // and return true afterwards. Return false otherwise.
285 static bool MaybeDoOnStackReplacement(Thread* thread,
286 ArtMethod* method,
287 uint32_t dex_pc,
288 int32_t dex_pc_offset,
289 JValue* result)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700290 REQUIRES_SHARED(Locks::mutator_lock_);
Nicolas Geoffrayb331feb2016-02-05 16:51:53 +0000291
Nicolas Geoffraya7edd0d2018-11-07 03:18:16 +0000292 // Load the compiler library.
293 static bool LoadCompilerLibrary(std::string* error_msg);
Mathieu Chartier72918ea2016-03-24 11:07:06 -0700294
Andreas Gampef149b3f2016-11-16 14:58:24 -0800295 ThreadPool* GetThreadPool() const {
296 return thread_pool_.get();
297 }
298
Nicolas Geoffray021c5f22016-12-16 11:22:05 +0000299 // Stop the JIT by waiting for all current compilations and enqueued compilations to finish.
300 void Stop();
301
302 // Start JIT threads.
303 void Start();
304
Nicolas Geoffrayce9ed362018-11-29 03:19:28 +0000305 // Transition to a child state.
Nicolas Geoffray0d54cfb2019-05-03 09:13:52 +0100306 void PostForkChildAction(bool is_system_server, bool is_zygote);
Nicolas Geoffrayce9ed362018-11-29 03:19:28 +0000307
308 // Prepare for forking.
309 void PreZygoteFork();
310
311 // Adjust state after forking.
312 void PostZygoteFork();
Nicolas Geoffrayc9de61c2018-11-27 17:34:31 +0000313
Nicolas Geoffray0f8950a2019-07-24 13:22:11 +0100314 // Compile methods from the given profile (.prof extension). If `add_to_queue`
315 // is true, methods in the profile are added to the JIT queue. Otherwise they are compiled
Nicolas Geoffray9ac09ee2019-05-08 23:38:27 +0100316 // directly.
Nicolas Geoffraye32d24c2019-07-05 10:28:59 +0100317 // Return the number of methods added to the queue.
318 uint32_t CompileMethodsFromProfile(Thread* self,
319 const std::vector<const DexFile*>& dex_files,
320 const std::string& profile_path,
321 Handle<mirror::ClassLoader> class_loader,
322 bool add_to_queue);
Nicolas Geoffray9ac09ee2019-05-08 23:38:27 +0100323
Nicolas Geoffray0f8950a2019-07-24 13:22:11 +0100324 // Compile methods from the given boot profile (.bprof extension). If `add_to_queue`
325 // is true, methods in the profile are added to the JIT queue. Otherwise they are compiled
326 // directly.
327 // Return the number of methods added to the queue.
328 uint32_t CompileMethodsFromBootProfile(Thread* self,
329 const std::vector<const DexFile*>& dex_files,
330 const std::string& profile_path,
331 Handle<mirror::ClassLoader> class_loader,
332 bool add_to_queue);
333
Nicolas Geoffray9ac09ee2019-05-08 23:38:27 +0100334 // Register the dex files to the JIT. This is to perform any compilation/optimization
335 // at the point of loading the dex files.
336 void RegisterDexFiles(const std::vector<std::unique_ptr<const DexFile>>& dex_files,
Nicolas Geoffray741a0702019-06-10 11:18:11 +0100337 jobject class_loader);
Nicolas Geoffrayde1b2a22019-02-27 09:10:57 +0000338
Nicolas Geoffraya48c3df2019-06-27 13:11:12 +0000339 // Called by the compiler to know whether it can directly encode the
340 // method/class/string.
Nicolas Geoffray05b41c42019-06-28 12:46:33 +0100341 bool CanEncodeMethod(ArtMethod* method, bool is_for_shared_region) const
342 REQUIRES_SHARED(Locks::mutator_lock_);
Nicolas Geoffraya48c3df2019-06-27 13:11:12 +0000343 bool CanEncodeClass(ObjPtr<mirror::Class> cls, bool is_for_shared_region) const
344 REQUIRES_SHARED(Locks::mutator_lock_);
345 bool CanEncodeString(ObjPtr<mirror::String> string, bool is_for_shared_region) const
346 REQUIRES_SHARED(Locks::mutator_lock_);
347 bool CanAssumeInitialized(ObjPtr<mirror::Class> cls, bool is_for_shared_region) const
348 REQUIRES_SHARED(Locks::mutator_lock_);
349
Mathieu Chartiere5f13e52015-02-24 09:37:21 -0800350 private:
Orion Hodsonad28f5e2018-10-17 09:08:17 +0100351 Jit(JitCodeCache* code_cache, JitOptions* options);
Mathieu Chartiere5f13e52015-02-24 09:37:21 -0800352
Nicolas Geoffray0f8950a2019-07-24 13:22:11 +0100353 // Compile an individual method listed in a profile. If `add_to_queue` is
354 // true and the method was resolved, return true. Otherwise return false.
355 bool CompileMethodFromProfile(Thread* self,
356 ClassLinker* linker,
357 uint32_t method_idx,
358 Handle<mirror::DexCache> dex_cache,
359 Handle<mirror::ClassLoader> class_loader,
360 bool add_to_queue)
361 REQUIRES_SHARED(Locks::mutator_lock_);
362
David Srbeckye3fc2d12018-11-30 13:41:14 +0000363 // Compile the method if the number of samples passes a threshold.
364 // Returns false if we can not compile now - don't increment the counter and retry later.
365 bool MaybeCompileMethod(Thread* self,
366 ArtMethod* method,
367 uint32_t old_count,
368 uint32_t new_count,
369 bool with_backedges)
370 REQUIRES_SHARED(Locks::mutator_lock_);
371
Orion Hodsonad28f5e2018-10-17 09:08:17 +0100372 static bool BindCompilerMethods(std::string* error_msg);
Mathieu Chartierc1bc4152016-03-24 17:22:52 -0700373
Mathieu Chartiere5f13e52015-02-24 09:37:21 -0800374 // JIT compiler
Mathieu Chartier72918ea2016-03-24 11:07:06 -0700375 static void* jit_library_handle_;
376 static void* jit_compiler_handle_;
Nicolas Geoffrayc9de61c2018-11-27 17:34:31 +0000377 static void* (*jit_load_)(void);
Mathieu Chartier72918ea2016-03-24 11:07:06 -0700378 static void (*jit_unload_)(void*);
Nicolas Geoffray7f7539b2019-06-06 16:20:54 +0100379 static bool (*jit_compile_method_)(void*, JitMemoryRegion*, ArtMethod*, Thread*, bool, bool);
Mathieu Chartier72918ea2016-03-24 11:07:06 -0700380 static void (*jit_types_loaded_)(void*, mirror::Class**, size_t count);
Nicolas Geoffrayc9de61c2018-11-27 17:34:31 +0000381 static void (*jit_update_options_)(void*);
382 static bool (*jit_generate_debug_info_)(void*);
383 template <typename T> static bool LoadSymbol(T*, const char* symbol, std::string* error_msg);
Nicolas Geoffray47b95802018-05-16 15:42:17 +0100384
Orion Hodsonad28f5e2018-10-17 09:08:17 +0100385 // JIT resources owned by runtime.
386 jit::JitCodeCache* const code_cache_;
Nicolas Geoffray47b95802018-05-16 15:42:17 +0100387 const JitOptions* const options_;
388
Nicolas Geoffray47b95802018-05-16 15:42:17 +0100389 std::unique_ptr<ThreadPool> thread_pool_;
Nicolas Geoffraydc2fbb62019-04-11 22:55:50 +0100390 std::vector<std::unique_ptr<OatDexFile>> type_lookup_tables_;
Nicolas Geoffray47b95802018-05-16 15:42:17 +0100391
Mathieu Chartiera4885cb2015-03-09 15:38:54 -0700392 // Performance monitoring.
Mathieu Chartiera4885cb2015-03-09 15:38:54 -0700393 CumulativeLogger cumulative_timings_;
Nicolas Geoffraya4f81542016-03-08 16:57:48 +0000394 Histogram<uint64_t> memory_use_ GUARDED_BY(lock_);
395 Mutex lock_ DEFAULT_MUTEX_ACQUIRED_AFTER;
Mathieu Chartiera4885cb2015-03-09 15:38:54 -0700396
Mathieu Chartier3130cdf2015-05-03 15:20:23 -0700397 DISALLOW_COPY_AND_ASSIGN(Jit);
Mathieu Chartiere5f13e52015-02-24 09:37:21 -0800398};
399
Andreas Gampef149b3f2016-11-16 14:58:24 -0800400// Helper class to stop the JIT for a given scope. This will wait for the JIT to quiesce.
401class ScopedJitSuspend {
402 public:
403 ScopedJitSuspend();
404 ~ScopedJitSuspend();
405
406 private:
407 bool was_on_;
408};
409
Mathieu Chartiere5f13e52015-02-24 09:37:21 -0800410} // namespace jit
411} // namespace art
412
413#endif // ART_RUNTIME_JIT_JIT_H_