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 | #ifndef ART_RUNTIME_JIT_JIT_H_ |
| 18 | #define ART_RUNTIME_JIT_JIT_H_ |
| 19 | |
Nicolas Geoffray | a4f8154 | 2016-03-08 16:57:48 +0000 | [diff] [blame] | 20 | #include "base/arena_allocator.h" |
| 21 | #include "base/histogram-inl.h" |
Mathieu Chartier | e5f13e5 | 2015-02-24 09:37:21 -0800 | [diff] [blame] | 22 | #include "base/macros.h" |
| 23 | #include "base/mutex.h" |
Mathieu Chartier | a4885cb | 2015-03-09 15:38:54 -0700 | [diff] [blame] | 24 | #include "base/timing_logger.h" |
Mathieu Chartier | ef41db7 | 2016-10-25 15:08:01 -0700 | [diff] [blame] | 25 | #include "jit/profile_saver_options.h" |
| 26 | #include "obj_ptr.h" |
Mathieu Chartier | e5f13e5 | 2015-02-24 09:37:21 -0800 | [diff] [blame] | 27 | #include "object_callbacks.h" |
Calin Juravle | 33083d6 | 2017-01-18 15:29:12 -0800 | [diff] [blame] | 28 | #include "profile_compilation_info.h" |
Mathieu Chartier | e5f13e5 | 2015-02-24 09:37:21 -0800 | [diff] [blame] | 29 | #include "thread_pool.h" |
| 30 | |
| 31 | namespace art { |
| 32 | |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 33 | class ArtMethod; |
David Sehr | 9323e6e | 2016-09-13 08:58:35 -0700 | [diff] [blame] | 34 | class ClassLinker; |
Mathieu Chartier | e5f13e5 | 2015-02-24 09:37:21 -0800 | [diff] [blame] | 35 | struct RuntimeArgumentMap; |
Vladimir Marko | 3a21e38 | 2016-09-02 12:38:38 +0100 | [diff] [blame] | 36 | union JValue; |
Mathieu Chartier | e5f13e5 | 2015-02-24 09:37:21 -0800 | [diff] [blame] | 37 | |
David Sehr | 709b070 | 2016-10-13 09:12:37 -0700 | [diff] [blame] | 38 | namespace mirror { |
| 39 | class Object; |
| 40 | class Class; |
| 41 | } // namespace mirror |
| 42 | |
Mathieu Chartier | e5f13e5 | 2015-02-24 09:37:21 -0800 | [diff] [blame] | 43 | namespace jit { |
| 44 | |
| 45 | class JitCodeCache; |
Mathieu Chartier | e5f13e5 | 2015-02-24 09:37:21 -0800 | [diff] [blame] | 46 | class JitOptions; |
| 47 | |
Nicolas Geoffray | 274fe4a | 2016-04-12 16:33:24 +0100 | [diff] [blame] | 48 | static constexpr int16_t kJitCheckForOSR = -1; |
| 49 | static constexpr int16_t kJitHotnessDisabled = -2; |
| 50 | |
Mathieu Chartier | e5f13e5 | 2015-02-24 09:37:21 -0800 | [diff] [blame] | 51 | class Jit { |
| 52 | public: |
| 53 | static constexpr bool kStressMode = kIsDebugBuild; |
Nicolas Geoffray | 83f080a | 2016-03-08 16:50:21 +0000 | [diff] [blame] | 54 | static constexpr size_t kDefaultCompileThreshold = kStressMode ? 2 : 10000; |
Nicolas Geoffray | 71cd50f | 2016-04-14 15:00:33 +0100 | [diff] [blame] | 55 | static constexpr size_t kDefaultPriorityThreadWeightRatio = 1000; |
Nicolas Geoffray | bd553eb | 2016-04-28 13:56:04 +0100 | [diff] [blame] | 56 | static constexpr size_t kDefaultInvokeTransitionWeightRatio = 500; |
buzbee | 42a09cb0 | 2017-02-01 09:08:31 -0800 | [diff] [blame] | 57 | // How frequently should the interpreter check to see if OSR compilation is ready. |
| 58 | static constexpr int16_t kJitRecheckOSRThreshold = 100; |
Mathieu Chartier | e5f13e5 | 2015-02-24 09:37:21 -0800 | [diff] [blame] | 59 | |
| 60 | virtual ~Jit(); |
| 61 | static Jit* Create(JitOptions* options, std::string* error_msg); |
Nicolas Geoffray | b331feb | 2016-02-05 16:51:53 +0000 | [diff] [blame] | 62 | bool CompileMethod(ArtMethod* method, Thread* self, bool osr) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 63 | REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | e5f13e5 | 2015-02-24 09:37:21 -0800 | [diff] [blame] | 64 | void CreateThreadPool(); |
Nicolas Geoffray | 274fe4a | 2016-04-12 16:33:24 +0100 | [diff] [blame] | 65 | |
Mathieu Chartier | e5f13e5 | 2015-02-24 09:37:21 -0800 | [diff] [blame] | 66 | const JitCodeCache* GetCodeCache() const { |
| 67 | return code_cache_.get(); |
| 68 | } |
Nicolas Geoffray | 274fe4a | 2016-04-12 16:33:24 +0100 | [diff] [blame] | 69 | |
Mathieu Chartier | e5f13e5 | 2015-02-24 09:37:21 -0800 | [diff] [blame] | 70 | JitCodeCache* GetCodeCache() { |
| 71 | return code_cache_.get(); |
| 72 | } |
Nicolas Geoffray | 274fe4a | 2016-04-12 16:33:24 +0100 | [diff] [blame] | 73 | |
Mathieu Chartier | e5f13e5 | 2015-02-24 09:37:21 -0800 | [diff] [blame] | 74 | void DeleteThreadPool(); |
Mathieu Chartier | a4885cb | 2015-03-09 15:38:54 -0700 | [diff] [blame] | 75 | // Dump interesting info: #methods compiled, code vs data size, compile / verify cumulative |
| 76 | // loggers. |
Nicolas Geoffray | a4f8154 | 2016-03-08 16:57:48 +0000 | [diff] [blame] | 77 | void DumpInfo(std::ostream& os) REQUIRES(!lock_); |
Mathieu Chartier | a4885cb | 2015-03-09 15:38:54 -0700 | [diff] [blame] | 78 | // Add a timing logger to cumulative_timings_. |
| 79 | void AddTimingLogger(const TimingLogger& logger); |
Nicolas Geoffray | a4f8154 | 2016-03-08 16:57:48 +0000 | [diff] [blame] | 80 | |
| 81 | void AddMemoryUsage(ArtMethod* method, size_t bytes) |
| 82 | REQUIRES(!lock_) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 83 | REQUIRES_SHARED(Locks::mutator_lock_); |
Nicolas Geoffray | a4f8154 | 2016-03-08 16:57:48 +0000 | [diff] [blame] | 84 | |
Nicolas Geoffray | 274fe4a | 2016-04-12 16:33:24 +0100 | [diff] [blame] | 85 | size_t OSRMethodThreshold() const { |
| 86 | return osr_method_threshold_; |
Mathieu Chartier | a50f9cf | 2015-09-25 11:34:45 -0700 | [diff] [blame] | 87 | } |
Mathieu Chartier | e5f13e5 | 2015-02-24 09:37:21 -0800 | [diff] [blame] | 88 | |
Nicolas Geoffray | 274fe4a | 2016-04-12 16:33:24 +0100 | [diff] [blame] | 89 | size_t HotMethodThreshold() const { |
| 90 | return hot_method_threshold_; |
| 91 | } |
| 92 | |
| 93 | size_t WarmMethodThreshold() const { |
| 94 | return warm_method_threshold_; |
| 95 | } |
| 96 | |
| 97 | uint16_t PriorityThreadWeight() const { |
| 98 | return priority_thread_weight_; |
| 99 | } |
| 100 | |
Calin Juravle | ffc8707 | 2016-04-20 14:22:09 +0100 | [diff] [blame] | 101 | // Returns false if we only need to save profile information and not compile methods. |
| 102 | bool UseJitCompilation() const { |
| 103 | return use_jit_compilation_; |
| 104 | } |
| 105 | |
Calin Juravle | 138dbff | 2016-06-28 19:36:58 +0100 | [diff] [blame] | 106 | bool GetSaveProfilingInfo() const { |
| 107 | return profile_saver_options_.IsEnabled(); |
Calin Juravle | ffc8707 | 2016-04-20 14:22:09 +0100 | [diff] [blame] | 108 | } |
| 109 | |
Nicolas Geoffray | 274fe4a | 2016-04-12 16:33:24 +0100 | [diff] [blame] | 110 | // Wait until there is no more pending compilation tasks. |
| 111 | void WaitForCompilationToFinish(Thread* self); |
| 112 | |
| 113 | // Profiling methods. |
| 114 | void MethodEntered(Thread* thread, ArtMethod* method) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 115 | REQUIRES_SHARED(Locks::mutator_lock_); |
Nicolas Geoffray | 274fe4a | 2016-04-12 16:33:24 +0100 | [diff] [blame] | 116 | |
Nicolas Geoffray | 71cd50f | 2016-04-14 15:00:33 +0100 | [diff] [blame] | 117 | void AddSamples(Thread* self, ArtMethod* method, uint16_t samples, bool with_backedges) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 118 | REQUIRES_SHARED(Locks::mutator_lock_); |
Nicolas Geoffray | 274fe4a | 2016-04-12 16:33:24 +0100 | [diff] [blame] | 119 | |
Mathieu Chartier | ef41db7 | 2016-10-25 15:08:01 -0700 | [diff] [blame] | 120 | void InvokeVirtualOrInterface(ObjPtr<mirror::Object> this_object, |
Nicolas Geoffray | 274fe4a | 2016-04-12 16:33:24 +0100 | [diff] [blame] | 121 | ArtMethod* caller, |
| 122 | uint32_t dex_pc, |
| 123 | ArtMethod* callee) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 124 | REQUIRES_SHARED(Locks::mutator_lock_); |
Nicolas Geoffray | 274fe4a | 2016-04-12 16:33:24 +0100 | [diff] [blame] | 125 | |
Nicolas Geoffray | 71cd50f | 2016-04-14 15:00:33 +0100 | [diff] [blame] | 126 | void NotifyInterpreterToCompiledCodeTransition(Thread* self, ArtMethod* caller) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 127 | REQUIRES_SHARED(Locks::mutator_lock_) { |
Calin Juravle | 155ff3d | 2016-04-27 14:14:58 +0100 | [diff] [blame] | 128 | AddSamples(self, caller, invoke_transition_weight_, false); |
Nicolas Geoffray | 71cd50f | 2016-04-14 15:00:33 +0100 | [diff] [blame] | 129 | } |
| 130 | |
| 131 | void NotifyCompiledCodeToInterpreterTransition(Thread* self, ArtMethod* callee) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 132 | REQUIRES_SHARED(Locks::mutator_lock_) { |
Calin Juravle | 155ff3d | 2016-04-27 14:14:58 +0100 | [diff] [blame] | 133 | AddSamples(self, callee, invoke_transition_weight_, false); |
Nicolas Geoffray | 71cd50f | 2016-04-14 15:00:33 +0100 | [diff] [blame] | 134 | } |
| 135 | |
Calin Juravle | c90bc92 | 2016-02-24 10:13:09 +0000 | [diff] [blame] | 136 | // Starts the profile saver if the config options allow profile recording. |
| 137 | // The profile will be stored in the specified `filename` and will contain |
| 138 | // information collected from the given `code_paths` (a set of dex locations). |
Calin Juravle | c90bc92 | 2016-02-24 10:13:09 +0000 | [diff] [blame] | 139 | void StartProfileSaver(const std::string& filename, |
Calin Juravle | 77651c4 | 2017-03-03 18:04:02 -0800 | [diff] [blame] | 140 | const std::vector<std::string>& code_paths); |
Calin Juravle | 4d77b6a | 2015-12-01 18:38:09 +0000 | [diff] [blame] | 141 | void StopProfileSaver(); |
Calin Juravle | 31f2c15 | 2015-10-23 17:56:15 +0100 | [diff] [blame] | 142 | |
Calin Juravle | b8e6999 | 2016-03-09 15:37:48 +0000 | [diff] [blame] | 143 | void DumpForSigQuit(std::ostream& os) REQUIRES(!lock_); |
Nicolas Geoffray | aee2156 | 2015-12-15 16:39:44 +0000 | [diff] [blame] | 144 | |
Tamas Berghammer | 160e6df | 2016-01-05 14:29:02 +0000 | [diff] [blame] | 145 | static void NewTypeLoadedIfUsingJit(mirror::Class* type) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 146 | REQUIRES_SHARED(Locks::mutator_lock_); |
Tamas Berghammer | 160e6df | 2016-01-05 14:29:02 +0000 | [diff] [blame] | 147 | |
Tamas Berghammer | fffbee4 | 2016-01-15 13:09:34 +0000 | [diff] [blame] | 148 | // If debug info generation is turned on then write the type information for types already loaded |
| 149 | // into the specified class linker to the jit debug interface, |
| 150 | void DumpTypeInfoForLoadedTypes(ClassLinker* linker); |
| 151 | |
Nicolas Geoffray | 3512244 | 2016-03-02 12:05:30 +0000 | [diff] [blame] | 152 | // Return whether we should try to JIT compiled code as soon as an ArtMethod is invoked. |
Siva Chandra | 05d2415 | 2016-01-05 17:43:17 -0800 | [diff] [blame] | 153 | bool JitAtFirstUse(); |
| 154 | |
Nicolas Geoffray | 3512244 | 2016-03-02 12:05:30 +0000 | [diff] [blame] | 155 | // Return whether we can invoke JIT code for `method`. |
| 156 | bool CanInvokeCompiledCode(ArtMethod* method); |
| 157 | |
Calin Juravle | b2771b4 | 2016-04-07 17:09:25 +0100 | [diff] [blame] | 158 | // Return whether the runtime should use a priority thread weight when sampling. |
| 159 | static bool ShouldUsePriorityThreadWeight(); |
| 160 | |
Nicolas Geoffray | b331feb | 2016-02-05 16:51:53 +0000 | [diff] [blame] | 161 | // If an OSR compiled version is available for `method`, |
| 162 | // and `dex_pc + dex_pc_offset` is an entry point of that compiled |
| 163 | // version, this method will jump to the compiled code, let it run, |
| 164 | // and return true afterwards. Return false otherwise. |
| 165 | static bool MaybeDoOnStackReplacement(Thread* thread, |
| 166 | ArtMethod* method, |
| 167 | uint32_t dex_pc, |
| 168 | int32_t dex_pc_offset, |
| 169 | JValue* result) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 170 | REQUIRES_SHARED(Locks::mutator_lock_); |
Nicolas Geoffray | b331feb | 2016-02-05 16:51:53 +0000 | [diff] [blame] | 171 | |
Mathieu Chartier | c1bc415 | 2016-03-24 17:22:52 -0700 | [diff] [blame] | 172 | static bool LoadCompilerLibrary(std::string* error_msg); |
Mathieu Chartier | 72918ea | 2016-03-24 11:07:06 -0700 | [diff] [blame] | 173 | |
Andreas Gampe | f149b3f | 2016-11-16 14:58:24 -0800 | [diff] [blame] | 174 | ThreadPool* GetThreadPool() const { |
| 175 | return thread_pool_.get(); |
| 176 | } |
| 177 | |
Nicolas Geoffray | 021c5f2 | 2016-12-16 11:22:05 +0000 | [diff] [blame] | 178 | // Stop the JIT by waiting for all current compilations and enqueued compilations to finish. |
| 179 | void Stop(); |
| 180 | |
| 181 | // Start JIT threads. |
| 182 | void Start(); |
| 183 | |
Mathieu Chartier | e5f13e5 | 2015-02-24 09:37:21 -0800 | [diff] [blame] | 184 | private: |
| 185 | Jit(); |
Mathieu Chartier | e5f13e5 | 2015-02-24 09:37:21 -0800 | [diff] [blame] | 186 | |
Mathieu Chartier | c1bc415 | 2016-03-24 17:22:52 -0700 | [diff] [blame] | 187 | static bool LoadCompiler(std::string* error_msg); |
| 188 | |
Mathieu Chartier | e5f13e5 | 2015-02-24 09:37:21 -0800 | [diff] [blame] | 189 | // JIT compiler |
Mathieu Chartier | 72918ea | 2016-03-24 11:07:06 -0700 | [diff] [blame] | 190 | static void* jit_library_handle_; |
| 191 | static void* jit_compiler_handle_; |
| 192 | static void* (*jit_load_)(bool*); |
| 193 | static void (*jit_unload_)(void*); |
| 194 | static bool (*jit_compile_method_)(void*, ArtMethod*, Thread*, bool); |
| 195 | static void (*jit_types_loaded_)(void*, mirror::Class**, size_t count); |
Mathieu Chartier | e5f13e5 | 2015-02-24 09:37:21 -0800 | [diff] [blame] | 196 | |
Mathieu Chartier | a4885cb | 2015-03-09 15:38:54 -0700 | [diff] [blame] | 197 | // Performance monitoring. |
| 198 | bool dump_info_on_shutdown_; |
| 199 | CumulativeLogger cumulative_timings_; |
Nicolas Geoffray | a4f8154 | 2016-03-08 16:57:48 +0000 | [diff] [blame] | 200 | Histogram<uint64_t> memory_use_ GUARDED_BY(lock_); |
| 201 | Mutex lock_ DEFAULT_MUTEX_ACQUIRED_AFTER; |
Mathieu Chartier | a4885cb | 2015-03-09 15:38:54 -0700 | [diff] [blame] | 202 | |
Mathieu Chartier | e5f13e5 | 2015-02-24 09:37:21 -0800 | [diff] [blame] | 203 | std::unique_ptr<jit::JitCodeCache> code_cache_; |
Mathieu Chartier | 3130cdf | 2015-05-03 15:20:23 -0700 | [diff] [blame] | 204 | |
Calin Juravle | ffc8707 | 2016-04-20 14:22:09 +0100 | [diff] [blame] | 205 | bool use_jit_compilation_; |
Calin Juravle | 138dbff | 2016-06-28 19:36:58 +0100 | [diff] [blame] | 206 | ProfileSaverOptions profile_saver_options_; |
Mathieu Chartier | 72918ea | 2016-03-24 11:07:06 -0700 | [diff] [blame] | 207 | static bool generate_debug_info_; |
Nicolas Geoffray | 274fe4a | 2016-04-12 16:33:24 +0100 | [diff] [blame] | 208 | uint16_t hot_method_threshold_; |
| 209 | uint16_t warm_method_threshold_; |
| 210 | uint16_t osr_method_threshold_; |
| 211 | uint16_t priority_thread_weight_; |
Calin Juravle | 155ff3d | 2016-04-27 14:14:58 +0100 | [diff] [blame] | 212 | uint16_t invoke_transition_weight_; |
Nicolas Geoffray | 274fe4a | 2016-04-12 16:33:24 +0100 | [diff] [blame] | 213 | std::unique_ptr<ThreadPool> thread_pool_; |
Calin Juravle | 4d77b6a | 2015-12-01 18:38:09 +0000 | [diff] [blame] | 214 | |
Mathieu Chartier | 3130cdf | 2015-05-03 15:20:23 -0700 | [diff] [blame] | 215 | DISALLOW_COPY_AND_ASSIGN(Jit); |
Mathieu Chartier | e5f13e5 | 2015-02-24 09:37:21 -0800 | [diff] [blame] | 216 | }; |
| 217 | |
| 218 | class JitOptions { |
| 219 | public: |
| 220 | static JitOptions* CreateFromRuntimeArguments(const RuntimeArgumentMap& options); |
| 221 | size_t GetCompileThreshold() const { |
| 222 | return compile_threshold_; |
| 223 | } |
Nicolas Geoffray | 5550ca8 | 2015-08-21 18:38:30 +0100 | [diff] [blame] | 224 | size_t GetWarmupThreshold() const { |
| 225 | return warmup_threshold_; |
| 226 | } |
Nicolas Geoffray | b331feb | 2016-02-05 16:51:53 +0000 | [diff] [blame] | 227 | size_t GetOsrThreshold() const { |
| 228 | return osr_threshold_; |
| 229 | } |
Calin Juravle | b2771b4 | 2016-04-07 17:09:25 +0100 | [diff] [blame] | 230 | uint16_t GetPriorityThreadWeight() const { |
| 231 | return priority_thread_weight_; |
| 232 | } |
Calin Juravle | 155ff3d | 2016-04-27 14:14:58 +0100 | [diff] [blame] | 233 | size_t GetInvokeTransitionWeight() const { |
| 234 | return invoke_transition_weight_; |
| 235 | } |
Nicolas Geoffray | 0a3be16 | 2015-11-18 11:15:22 +0000 | [diff] [blame] | 236 | size_t GetCodeCacheInitialCapacity() const { |
| 237 | return code_cache_initial_capacity_; |
| 238 | } |
| 239 | size_t GetCodeCacheMaxCapacity() const { |
| 240 | return code_cache_max_capacity_; |
Mathieu Chartier | e5f13e5 | 2015-02-24 09:37:21 -0800 | [diff] [blame] | 241 | } |
Mathieu Chartier | a4885cb | 2015-03-09 15:38:54 -0700 | [diff] [blame] | 242 | bool DumpJitInfoOnShutdown() const { |
| 243 | return dump_info_on_shutdown_; |
| 244 | } |
Calin Juravle | 138dbff | 2016-06-28 19:36:58 +0100 | [diff] [blame] | 245 | const ProfileSaverOptions& GetProfileSaverOptions() const { |
| 246 | return profile_saver_options_; |
| 247 | } |
Calin Juravle | 31f2c15 | 2015-10-23 17:56:15 +0100 | [diff] [blame] | 248 | bool GetSaveProfilingInfo() const { |
Calin Juravle | 138dbff | 2016-06-28 19:36:58 +0100 | [diff] [blame] | 249 | return profile_saver_options_.IsEnabled(); |
Calin Juravle | 31f2c15 | 2015-10-23 17:56:15 +0100 | [diff] [blame] | 250 | } |
Calin Juravle | ffc8707 | 2016-04-20 14:22:09 +0100 | [diff] [blame] | 251 | bool UseJitCompilation() const { |
| 252 | return use_jit_compilation_; |
Mathieu Chartier | 455f67c | 2015-03-17 13:48:29 -0700 | [diff] [blame] | 253 | } |
Calin Juravle | ffc8707 | 2016-04-20 14:22:09 +0100 | [diff] [blame] | 254 | void SetUseJitCompilation(bool b) { |
| 255 | use_jit_compilation_ = b; |
Mathieu Chartier | 455f67c | 2015-03-17 13:48:29 -0700 | [diff] [blame] | 256 | } |
Calin Juravle | 138dbff | 2016-06-28 19:36:58 +0100 | [diff] [blame] | 257 | void SetSaveProfilingInfo(bool save_profiling_info) { |
| 258 | profile_saver_options_.SetEnabled(save_profiling_info); |
Calin Juravle | 31f2c15 | 2015-10-23 17:56:15 +0100 | [diff] [blame] | 259 | } |
Siva Chandra | 05d2415 | 2016-01-05 17:43:17 -0800 | [diff] [blame] | 260 | void SetJitAtFirstUse() { |
Calin Juravle | ffc8707 | 2016-04-20 14:22:09 +0100 | [diff] [blame] | 261 | use_jit_compilation_ = true; |
Siva Chandra | 05d2415 | 2016-01-05 17:43:17 -0800 | [diff] [blame] | 262 | compile_threshold_ = 0; |
| 263 | } |
Mathieu Chartier | e5f13e5 | 2015-02-24 09:37:21 -0800 | [diff] [blame] | 264 | |
| 265 | private: |
Calin Juravle | ffc8707 | 2016-04-20 14:22:09 +0100 | [diff] [blame] | 266 | bool use_jit_compilation_; |
Nicolas Geoffray | 0a3be16 | 2015-11-18 11:15:22 +0000 | [diff] [blame] | 267 | size_t code_cache_initial_capacity_; |
| 268 | size_t code_cache_max_capacity_; |
Mathieu Chartier | e5f13e5 | 2015-02-24 09:37:21 -0800 | [diff] [blame] | 269 | size_t compile_threshold_; |
Nicolas Geoffray | 5550ca8 | 2015-08-21 18:38:30 +0100 | [diff] [blame] | 270 | size_t warmup_threshold_; |
Nicolas Geoffray | b331feb | 2016-02-05 16:51:53 +0000 | [diff] [blame] | 271 | size_t osr_threshold_; |
Calin Juravle | b2771b4 | 2016-04-07 17:09:25 +0100 | [diff] [blame] | 272 | uint16_t priority_thread_weight_; |
Calin Juravle | 155ff3d | 2016-04-27 14:14:58 +0100 | [diff] [blame] | 273 | size_t invoke_transition_weight_; |
Mathieu Chartier | a4885cb | 2015-03-09 15:38:54 -0700 | [diff] [blame] | 274 | bool dump_info_on_shutdown_; |
Calin Juravle | 138dbff | 2016-06-28 19:36:58 +0100 | [diff] [blame] | 275 | ProfileSaverOptions profile_saver_options_; |
Mathieu Chartier | e5f13e5 | 2015-02-24 09:37:21 -0800 | [diff] [blame] | 276 | |
Nicolas Geoffray | 0a3be16 | 2015-11-18 11:15:22 +0000 | [diff] [blame] | 277 | JitOptions() |
Calin Juravle | ffc8707 | 2016-04-20 14:22:09 +0100 | [diff] [blame] | 278 | : use_jit_compilation_(false), |
Nicolas Geoffray | 0a3be16 | 2015-11-18 11:15:22 +0000 | [diff] [blame] | 279 | code_cache_initial_capacity_(0), |
| 280 | code_cache_max_capacity_(0), |
| 281 | compile_threshold_(0), |
Andreas Gampe | d9911ee | 2017-03-27 13:27:24 -0700 | [diff] [blame^] | 282 | warmup_threshold_(0), |
| 283 | osr_threshold_(0), |
| 284 | priority_thread_weight_(0), |
| 285 | invoke_transition_weight_(0), |
Calin Juravle | 138dbff | 2016-06-28 19:36:58 +0100 | [diff] [blame] | 286 | dump_info_on_shutdown_(false) {} |
Mathieu Chartier | 3130cdf | 2015-05-03 15:20:23 -0700 | [diff] [blame] | 287 | |
| 288 | DISALLOW_COPY_AND_ASSIGN(JitOptions); |
Mathieu Chartier | e5f13e5 | 2015-02-24 09:37:21 -0800 | [diff] [blame] | 289 | }; |
| 290 | |
Andreas Gampe | f149b3f | 2016-11-16 14:58:24 -0800 | [diff] [blame] | 291 | // Helper class to stop the JIT for a given scope. This will wait for the JIT to quiesce. |
| 292 | class ScopedJitSuspend { |
| 293 | public: |
| 294 | ScopedJitSuspend(); |
| 295 | ~ScopedJitSuspend(); |
| 296 | |
| 297 | private: |
| 298 | bool was_on_; |
| 299 | }; |
| 300 | |
Mathieu Chartier | e5f13e5 | 2015-02-24 09:37:21 -0800 | [diff] [blame] | 301 | } // namespace jit |
| 302 | } // namespace art |
| 303 | |
| 304 | #endif // ART_RUNTIME_JIT_JIT_H_ |