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_CODE_CACHE_H_ |
| 18 | #define ART_RUNTIME_JIT_JIT_CODE_CACHE_H_ |
| 19 | |
| 20 | #include "instrumentation.h" |
| 21 | |
| 22 | #include "atomic.h" |
| 23 | #include "base/macros.h" |
| 24 | #include "base/mutex.h" |
Nicolas Geoffray | 1dad3f6 | 2015-10-23 14:59:54 +0100 | [diff] [blame] | 25 | #include "gc/accounting/bitmap.h" |
Mathieu Chartier | e5f13e5 | 2015-02-24 09:37:21 -0800 | [diff] [blame] | 26 | #include "gc_root.h" |
| 27 | #include "jni.h" |
| 28 | #include "oat_file.h" |
| 29 | #include "object_callbacks.h" |
| 30 | #include "safe_map.h" |
| 31 | #include "thread_pool.h" |
| 32 | |
| 33 | namespace art { |
| 34 | |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 35 | class ArtMethod; |
Nicolas Geoffray | 1dad3f6 | 2015-10-23 14:59:54 +0100 | [diff] [blame] | 36 | class LinearAlloc; |
Nicolas Geoffray | 26705e2 | 2015-10-28 12:50:11 +0000 | [diff] [blame] | 37 | class ProfilingInfo; |
Mathieu Chartier | e5f13e5 | 2015-02-24 09:37:21 -0800 | [diff] [blame] | 38 | |
Mathieu Chartier | e5f13e5 | 2015-02-24 09:37:21 -0800 | [diff] [blame] | 39 | namespace jit { |
| 40 | |
| 41 | class JitInstrumentationCache; |
| 42 | |
Nicolas Geoffray | 0a3be16 | 2015-11-18 11:15:22 +0000 | [diff] [blame] | 43 | // Alignment in bits that will suit all architectures. |
Nicolas Geoffray | 1dad3f6 | 2015-10-23 14:59:54 +0100 | [diff] [blame] | 44 | static constexpr int kJitCodeAlignment = 16; |
| 45 | using CodeCacheBitmap = gc::accounting::MemoryRangeBitmap<kJitCodeAlignment>; |
| 46 | |
Mathieu Chartier | e5f13e5 | 2015-02-24 09:37:21 -0800 | [diff] [blame] | 47 | class JitCodeCache { |
| 48 | public: |
Nicolas Geoffray | 0a3be16 | 2015-11-18 11:15:22 +0000 | [diff] [blame] | 49 | static constexpr size_t kMaxCapacity = 64 * MB; |
Nicolas Geoffray | 1dad3f6 | 2015-10-23 14:59:54 +0100 | [diff] [blame] | 50 | // Put the default to a very low amount for debug builds to stress the code cache |
| 51 | // collection. |
Nicolas Geoffray | 7ca4b77 | 2016-02-23 13:52:01 +0000 | [diff] [blame] | 52 | static constexpr size_t kInitialCapacity = kIsDebugBuild ? 8 * KB : 64 * KB; |
Nicolas Geoffray | 65b83d8 | 2016-02-22 13:14:04 +0000 | [diff] [blame] | 53 | |
| 54 | // By default, do not GC until reaching 256KB. |
| 55 | static constexpr size_t kReservedCapacity = kInitialCapacity * 4; |
Mathieu Chartier | e5f13e5 | 2015-02-24 09:37:21 -0800 | [diff] [blame] | 56 | |
Mathieu Chartier | bce416f | 2015-03-23 12:37:35 -0700 | [diff] [blame] | 57 | // Create the code cache with a code + data capacity equal to "capacity", error message is passed |
| 58 | // in the out arg error_msg. |
Nicolas Geoffray | a25dce9 | 2016-01-12 16:41:10 +0000 | [diff] [blame] | 59 | static JitCodeCache* Create(size_t initial_capacity, |
| 60 | size_t max_capacity, |
| 61 | bool generate_debug_info, |
| 62 | std::string* error_msg); |
Mathieu Chartier | e5f13e5 | 2015-02-24 09:37:21 -0800 | [diff] [blame] | 63 | |
Nicolas Geoffray | 1dad3f6 | 2015-10-23 14:59:54 +0100 | [diff] [blame] | 64 | // Number of bytes allocated in the code cache. |
Nicolas Geoffray | 0c3c266 | 2015-10-15 13:53:04 +0100 | [diff] [blame] | 65 | size_t CodeCacheSize() REQUIRES(!lock_); |
| 66 | |
Nicolas Geoffray | 1dad3f6 | 2015-10-23 14:59:54 +0100 | [diff] [blame] | 67 | // Number of bytes allocated in the data cache. |
Nicolas Geoffray | 0c3c266 | 2015-10-15 13:53:04 +0100 | [diff] [blame] | 68 | size_t DataCacheSize() REQUIRES(!lock_); |
| 69 | |
Nicolas Geoffray | b331feb | 2016-02-05 16:51:53 +0000 | [diff] [blame] | 70 | bool NotifyCompilationOf(ArtMethod* method, Thread* self, bool osr) |
Nicolas Geoffray | 73be1e8 | 2015-09-17 15:22:56 +0100 | [diff] [blame] | 71 | SHARED_REQUIRES(Locks::mutator_lock_) |
| 72 | REQUIRES(!lock_); |
| 73 | |
Nicolas Geoffray | b6e20ae | 2016-03-07 14:29:04 +0000 | [diff] [blame^] | 74 | void NotifyInliningOf(ArtMethod* method, Thread* self) |
| 75 | SHARED_REQUIRES(Locks::mutator_lock_) |
| 76 | REQUIRES(!lock_); |
| 77 | |
Nicolas Geoffray | 73be1e8 | 2015-09-17 15:22:56 +0100 | [diff] [blame] | 78 | void DoneCompiling(ArtMethod* method, Thread* self) |
| 79 | SHARED_REQUIRES(Locks::mutator_lock_) |
| 80 | REQUIRES(!lock_); |
| 81 | |
Nicolas Geoffray | b6e20ae | 2016-03-07 14:29:04 +0000 | [diff] [blame^] | 82 | void DoneInlining(ArtMethod* method, Thread* self) |
| 83 | SHARED_REQUIRES(Locks::mutator_lock_) |
| 84 | REQUIRES(!lock_); |
| 85 | |
Nicolas Geoffray | 0c3c266 | 2015-10-15 13:53:04 +0100 | [diff] [blame] | 86 | // Allocate and write code and its metadata to the code cache. |
| 87 | uint8_t* CommitCode(Thread* self, |
Nicolas Geoffray | 1dad3f6 | 2015-10-23 14:59:54 +0100 | [diff] [blame] | 88 | ArtMethod* method, |
Nicolas Geoffray | 0c3c266 | 2015-10-15 13:53:04 +0100 | [diff] [blame] | 89 | const uint8_t* mapping_table, |
| 90 | const uint8_t* vmap_table, |
| 91 | const uint8_t* gc_map, |
| 92 | size_t frame_size_in_bytes, |
| 93 | size_t core_spill_mask, |
| 94 | size_t fp_spill_mask, |
| 95 | const uint8_t* code, |
Nicolas Geoffray | b331feb | 2016-02-05 16:51:53 +0000 | [diff] [blame] | 96 | size_t code_size, |
| 97 | bool osr) |
Nicolas Geoffray | 1dad3f6 | 2015-10-23 14:59:54 +0100 | [diff] [blame] | 98 | SHARED_REQUIRES(Locks::mutator_lock_) |
Nicolas Geoffray | 0c3c266 | 2015-10-15 13:53:04 +0100 | [diff] [blame] | 99 | REQUIRES(!lock_); |
| 100 | |
Nicolas Geoffray | 1dad3f6 | 2015-10-23 14:59:54 +0100 | [diff] [blame] | 101 | // Return true if the code cache contains this pc. |
| 102 | bool ContainsPc(const void* pc) const; |
Mathieu Chartier | e5f13e5 | 2015-02-24 09:37:21 -0800 | [diff] [blame] | 103 | |
Nicolas Geoffray | a5891e8 | 2015-11-06 14:18:27 +0000 | [diff] [blame] | 104 | // Return true if the code cache contains this method. |
| 105 | bool ContainsMethod(ArtMethod* method) REQUIRES(!lock_); |
| 106 | |
Nicolas Geoffray | 5550ca8 | 2015-08-21 18:38:30 +0100 | [diff] [blame] | 107 | // Reserve a region of data of size at least "size". Returns null if there is no more room. |
Nicolas Geoffray | 1dad3f6 | 2015-10-23 14:59:54 +0100 | [diff] [blame] | 108 | uint8_t* ReserveData(Thread* self, size_t size) |
| 109 | SHARED_REQUIRES(Locks::mutator_lock_) |
| 110 | REQUIRES(!lock_); |
Nicolas Geoffray | 5550ca8 | 2015-08-21 18:38:30 +0100 | [diff] [blame] | 111 | |
Nicolas Geoffray | d28b969 | 2015-11-04 14:36:55 +0000 | [diff] [blame] | 112 | // Clear data from the data portion of the code cache. |
| 113 | void ClearData(Thread* self, void* data) |
| 114 | SHARED_REQUIRES(Locks::mutator_lock_) |
| 115 | REQUIRES(!lock_); |
| 116 | |
Mathieu Chartier | 2cebb24 | 2015-04-21 16:50:40 -0700 | [diff] [blame] | 117 | // Add a data array of size (end - begin) with the associated contents, returns null if there |
Mathieu Chartier | bce416f | 2015-03-23 12:37:35 -0700 | [diff] [blame] | 118 | // is no more room. |
Mathieu Chartier | e5f13e5 | 2015-02-24 09:37:21 -0800 | [diff] [blame] | 119 | uint8_t* AddDataArray(Thread* self, const uint8_t* begin, const uint8_t* end) |
Nicolas Geoffray | 1dad3f6 | 2015-10-23 14:59:54 +0100 | [diff] [blame] | 120 | SHARED_REQUIRES(Locks::mutator_lock_) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 121 | REQUIRES(!lock_); |
Mathieu Chartier | e5f13e5 | 2015-02-24 09:37:21 -0800 | [diff] [blame] | 122 | |
Nicolas Geoffray | 1dad3f6 | 2015-10-23 14:59:54 +0100 | [diff] [blame] | 123 | CodeCacheBitmap* GetLiveBitmap() const { |
| 124 | return live_bitmap_.get(); |
| 125 | } |
Mathieu Chartier | e5f13e5 | 2015-02-24 09:37:21 -0800 | [diff] [blame] | 126 | |
Nicolas Geoffray | 3512244 | 2016-03-02 12:05:30 +0000 | [diff] [blame] | 127 | // Return whether we should do a full collection given the current state of the cache. |
| 128 | bool ShouldDoFullCollection() |
| 129 | REQUIRES(lock_) |
| 130 | SHARED_REQUIRES(Locks::mutator_lock_); |
| 131 | |
Nicolas Geoffray | 1dad3f6 | 2015-10-23 14:59:54 +0100 | [diff] [blame] | 132 | // Perform a collection on the code cache. |
| 133 | void GarbageCollectCache(Thread* self) |
| 134 | REQUIRES(!lock_) |
| 135 | SHARED_REQUIRES(Locks::mutator_lock_); |
| 136 | |
| 137 | // Given the 'pc', try to find the JIT compiled code associated with it. |
| 138 | // Return null if 'pc' is not in the code cache. 'method' is passed for |
| 139 | // sanity check. |
| 140 | OatQuickMethodHeader* LookupMethodHeader(uintptr_t pc, ArtMethod* method) |
| 141 | REQUIRES(!lock_) |
| 142 | SHARED_REQUIRES(Locks::mutator_lock_); |
| 143 | |
Nicolas Geoffray | b331feb | 2016-02-05 16:51:53 +0000 | [diff] [blame] | 144 | OatQuickMethodHeader* LookupOsrMethodHeader(ArtMethod* method) |
| 145 | REQUIRES(!lock_) |
| 146 | SHARED_REQUIRES(Locks::mutator_lock_); |
| 147 | |
Nicolas Geoffray | 26705e2 | 2015-10-28 12:50:11 +0000 | [diff] [blame] | 148 | // Remove all methods in our cache that were allocated by 'alloc'. |
Nicolas Geoffray | 1dad3f6 | 2015-10-23 14:59:54 +0100 | [diff] [blame] | 149 | void RemoveMethodsIn(Thread* self, const LinearAlloc& alloc) |
| 150 | REQUIRES(!lock_) |
| 151 | REQUIRES(Locks::classlinker_classes_lock_) |
| 152 | SHARED_REQUIRES(Locks::mutator_lock_); |
Mathieu Chartier | e5f13e5 | 2015-02-24 09:37:21 -0800 | [diff] [blame] | 153 | |
Nicolas Geoffray | b6e20ae | 2016-03-07 14:29:04 +0000 | [diff] [blame^] | 154 | void ClearGcRootsInInlineCaches(Thread* self) REQUIRES(!lock_); |
| 155 | |
Nicolas Geoffray | 26705e2 | 2015-10-28 12:50:11 +0000 | [diff] [blame] | 156 | // Create a 'ProfileInfo' for 'method'. If 'retry_allocation' is true, |
| 157 | // will collect and retry if the first allocation is unsuccessful. |
| 158 | ProfilingInfo* AddProfilingInfo(Thread* self, |
| 159 | ArtMethod* method, |
| 160 | const std::vector<uint32_t>& entries, |
| 161 | bool retry_allocation) |
| 162 | REQUIRES(!lock_) |
| 163 | SHARED_REQUIRES(Locks::mutator_lock_); |
| 164 | |
Nicolas Geoffray | 0a3be16 | 2015-11-18 11:15:22 +0000 | [diff] [blame] | 165 | bool OwnsSpace(const void* mspace) const NO_THREAD_SAFETY_ANALYSIS { |
| 166 | return mspace == code_mspace_ || mspace == data_mspace_; |
| 167 | } |
| 168 | |
| 169 | void* MoreCore(const void* mspace, intptr_t increment); |
| 170 | |
Calin Juravle | 66f5523 | 2015-12-08 15:09:10 +0000 | [diff] [blame] | 171 | // Adds to `methods` all the compiled ArtMethods which are part of any of the given dex locations. |
Calin Juravle | b4eddd2 | 2016-01-13 15:52:33 -0800 | [diff] [blame] | 172 | void GetCompiledArtMethods(const std::set<std::string>& dex_base_locations, |
Calin Juravle | 4d77b6a | 2015-12-01 18:38:09 +0000 | [diff] [blame] | 173 | std::vector<ArtMethod*>& methods) |
Calin Juravle | 31f2c15 | 2015-10-23 17:56:15 +0100 | [diff] [blame] | 174 | REQUIRES(!lock_) |
| 175 | SHARED_REQUIRES(Locks::mutator_lock_); |
| 176 | |
Calin Juravle | 4d77b6a | 2015-12-01 18:38:09 +0000 | [diff] [blame] | 177 | uint64_t GetLastUpdateTimeNs() const; |
Calin Juravle | 31f2c15 | 2015-10-23 17:56:15 +0100 | [diff] [blame] | 178 | |
Nicolas Geoffray | aee2156 | 2015-12-15 16:39:44 +0000 | [diff] [blame] | 179 | size_t GetCurrentCapacity() REQUIRES(!lock_) { |
| 180 | MutexLock lock(Thread::Current(), lock_); |
| 181 | return current_capacity_; |
| 182 | } |
| 183 | |
Nicolas Geoffray | a25dce9 | 2016-01-12 16:41:10 +0000 | [diff] [blame] | 184 | size_t GetMemorySizeOfCodePointer(const void* ptr) REQUIRES(!lock_); |
| 185 | |
Nicolas Geoffray | b88d59e | 2016-02-17 11:31:49 +0000 | [diff] [blame] | 186 | void InvalidateCompiledCodeFor(ArtMethod* method, const OatQuickMethodHeader* code) |
| 187 | REQUIRES(!lock_) |
| 188 | SHARED_REQUIRES(Locks::mutator_lock_); |
| 189 | |
Nicolas Geoffray | bcd94c8 | 2016-03-03 13:23:33 +0000 | [diff] [blame] | 190 | void Dump(std::ostream& os) REQUIRES(!lock_); |
| 191 | |
Mathieu Chartier | e5f13e5 | 2015-02-24 09:37:21 -0800 | [diff] [blame] | 192 | private: |
Nicolas Geoffray | 0a3be16 | 2015-11-18 11:15:22 +0000 | [diff] [blame] | 193 | // Take ownership of maps. |
| 194 | JitCodeCache(MemMap* code_map, |
| 195 | MemMap* data_map, |
| 196 | size_t initial_code_capacity, |
| 197 | size_t initial_data_capacity, |
Nicolas Geoffray | a25dce9 | 2016-01-12 16:41:10 +0000 | [diff] [blame] | 198 | size_t max_capacity, |
| 199 | bool garbage_collect_code); |
Mathieu Chartier | e5f13e5 | 2015-02-24 09:37:21 -0800 | [diff] [blame] | 200 | |
Nicolas Geoffray | 1dad3f6 | 2015-10-23 14:59:54 +0100 | [diff] [blame] | 201 | // Internal version of 'CommitCode' that will not retry if the |
| 202 | // allocation fails. Return null if the allocation fails. |
| 203 | uint8_t* CommitCodeInternal(Thread* self, |
| 204 | ArtMethod* method, |
| 205 | const uint8_t* mapping_table, |
| 206 | const uint8_t* vmap_table, |
| 207 | const uint8_t* gc_map, |
| 208 | size_t frame_size_in_bytes, |
| 209 | size_t core_spill_mask, |
| 210 | size_t fp_spill_mask, |
| 211 | const uint8_t* code, |
Nicolas Geoffray | b331feb | 2016-02-05 16:51:53 +0000 | [diff] [blame] | 212 | size_t code_size, |
| 213 | bool osr) |
Nicolas Geoffray | 1dad3f6 | 2015-10-23 14:59:54 +0100 | [diff] [blame] | 214 | REQUIRES(!lock_) |
| 215 | SHARED_REQUIRES(Locks::mutator_lock_); |
| 216 | |
Nicolas Geoffray | 26705e2 | 2015-10-28 12:50:11 +0000 | [diff] [blame] | 217 | ProfilingInfo* AddProfilingInfoInternal(Thread* self, |
| 218 | ArtMethod* method, |
| 219 | const std::vector<uint32_t>& entries) |
Nicolas Geoffray | 1e7da9b | 2016-03-01 14:11:40 +0000 | [diff] [blame] | 220 | REQUIRES(lock_) |
Nicolas Geoffray | 26705e2 | 2015-10-28 12:50:11 +0000 | [diff] [blame] | 221 | SHARED_REQUIRES(Locks::mutator_lock_); |
| 222 | |
Nicolas Geoffray | 1dad3f6 | 2015-10-23 14:59:54 +0100 | [diff] [blame] | 223 | // If a collection is in progress, wait for it to finish. Return |
| 224 | // whether the thread actually waited. |
| 225 | bool WaitForPotentialCollectionToComplete(Thread* self) |
| 226 | REQUIRES(lock_) REQUIRES(!Locks::mutator_lock_); |
| 227 | |
| 228 | // Free in the mspace allocations taken by 'method'. |
| 229 | void FreeCode(const void* code_ptr, ArtMethod* method) REQUIRES(lock_); |
| 230 | |
Nicolas Geoffray | a5891e8 | 2015-11-06 14:18:27 +0000 | [diff] [blame] | 231 | // Number of bytes allocated in the code cache. |
| 232 | size_t CodeCacheSizeLocked() REQUIRES(lock_); |
| 233 | |
| 234 | // Number of bytes allocated in the data cache. |
| 235 | size_t DataCacheSizeLocked() REQUIRES(lock_); |
| 236 | |
Nicolas Geoffray | 0a3be16 | 2015-11-18 11:15:22 +0000 | [diff] [blame] | 237 | // Notify all waiting threads that a collection is done. |
| 238 | void NotifyCollectionDone(Thread* self) REQUIRES(lock_); |
| 239 | |
| 240 | // Try to increase the current capacity of the code cache. Return whether we |
| 241 | // succeeded at doing so. |
| 242 | bool IncreaseCodeCacheCapacity() REQUIRES(lock_); |
| 243 | |
| 244 | // Set the footprint limit of the code cache. |
| 245 | void SetFootprintLimit(size_t new_footprint) REQUIRES(lock_); |
| 246 | |
Nicolas Geoffray | 3512244 | 2016-03-02 12:05:30 +0000 | [diff] [blame] | 247 | void DoCollection(Thread* self, bool collect_profiling_info) |
Nicolas Geoffray | 8d37250 | 2016-02-23 13:56:43 +0000 | [diff] [blame] | 248 | REQUIRES(!lock_) |
| 249 | SHARED_REQUIRES(Locks::mutator_lock_); |
| 250 | |
Nicolas Geoffray | 9abb297 | 2016-03-04 14:32:59 +0000 | [diff] [blame] | 251 | void RemoveUnmarkedCode(Thread* self) |
Nicolas Geoffray | 8d37250 | 2016-02-23 13:56:43 +0000 | [diff] [blame] | 252 | REQUIRES(!lock_) |
| 253 | SHARED_REQUIRES(Locks::mutator_lock_); |
| 254 | |
| 255 | void MarkCompiledCodeOnThreadStacks(Thread* self) |
| 256 | REQUIRES(!lock_) |
| 257 | SHARED_REQUIRES(Locks::mutator_lock_); |
| 258 | |
Nicolas Geoffray | 3512244 | 2016-03-02 12:05:30 +0000 | [diff] [blame] | 259 | bool CheckLiveCompiledCodeHasProfilingInfo() |
| 260 | REQUIRES(lock_) |
| 261 | SHARED_REQUIRES(Locks::mutator_lock_); |
| 262 | |
Nicolas Geoffray | bcd94c8 | 2016-03-03 13:23:33 +0000 | [diff] [blame] | 263 | void FreeCode(uint8_t* code) REQUIRES(lock_); |
| 264 | uint8_t* AllocateCode(size_t code_size) REQUIRES(lock_); |
| 265 | void FreeData(uint8_t* data) REQUIRES(lock_); |
| 266 | uint8_t* AllocateData(size_t data_size) REQUIRES(lock_); |
| 267 | |
Nicolas Geoffray | 1dad3f6 | 2015-10-23 14:59:54 +0100 | [diff] [blame] | 268 | // Lock for guarding allocations, collections, and the method_code_map_. |
Mathieu Chartier | e5f13e5 | 2015-02-24 09:37:21 -0800 | [diff] [blame] | 269 | Mutex lock_; |
Nicolas Geoffray | 1dad3f6 | 2015-10-23 14:59:54 +0100 | [diff] [blame] | 270 | // Condition to wait on during collection. |
| 271 | ConditionVariable lock_cond_ GUARDED_BY(lock_); |
| 272 | // Whether there is a code cache collection in progress. |
| 273 | bool collection_in_progress_ GUARDED_BY(lock_); |
Nicolas Geoffray | 0c3c266 | 2015-10-15 13:53:04 +0100 | [diff] [blame] | 274 | // Mem map which holds code. |
| 275 | std::unique_ptr<MemMap> code_map_; |
| 276 | // Mem map which holds data (stack maps and profiling info). |
| 277 | std::unique_ptr<MemMap> data_map_; |
| 278 | // The opaque mspace for allocating code. |
Nicolas Geoffray | 1dad3f6 | 2015-10-23 14:59:54 +0100 | [diff] [blame] | 279 | void* code_mspace_ GUARDED_BY(lock_); |
Nicolas Geoffray | 0c3c266 | 2015-10-15 13:53:04 +0100 | [diff] [blame] | 280 | // The opaque mspace for allocating data. |
Nicolas Geoffray | 1dad3f6 | 2015-10-23 14:59:54 +0100 | [diff] [blame] | 281 | void* data_mspace_ GUARDED_BY(lock_); |
| 282 | // Bitmap for collecting code and data. |
| 283 | std::unique_ptr<CodeCacheBitmap> live_bitmap_; |
Nicolas Geoffray | b331feb | 2016-02-05 16:51:53 +0000 | [diff] [blame] | 284 | // Holds compiled code associated to the ArtMethod. |
Nicolas Geoffray | 1dad3f6 | 2015-10-23 14:59:54 +0100 | [diff] [blame] | 285 | SafeMap<const void*, ArtMethod*> method_code_map_ GUARDED_BY(lock_); |
Nicolas Geoffray | b331feb | 2016-02-05 16:51:53 +0000 | [diff] [blame] | 286 | // Holds osr compiled code associated to the ArtMethod. |
| 287 | SafeMap<ArtMethod*, const void*> osr_code_map_ GUARDED_BY(lock_); |
Nicolas Geoffray | 26705e2 | 2015-10-28 12:50:11 +0000 | [diff] [blame] | 288 | // ProfilingInfo objects we have allocated. |
| 289 | std::vector<ProfilingInfo*> profiling_infos_ GUARDED_BY(lock_); |
Mathieu Chartier | e5f13e5 | 2015-02-24 09:37:21 -0800 | [diff] [blame] | 290 | |
Nicolas Geoffray | 0a3be16 | 2015-11-18 11:15:22 +0000 | [diff] [blame] | 291 | // The maximum capacity in bytes this code cache can go to. |
| 292 | size_t max_capacity_ GUARDED_BY(lock_); |
| 293 | |
| 294 | // The current capacity in bytes of the code cache. |
| 295 | size_t current_capacity_ GUARDED_BY(lock_); |
| 296 | |
| 297 | // The current footprint in bytes of the code portion of the code cache. |
| 298 | size_t code_end_ GUARDED_BY(lock_); |
| 299 | |
| 300 | // The current footprint in bytes of the data portion of the code cache. |
| 301 | size_t data_end_ GUARDED_BY(lock_); |
| 302 | |
Nicolas Geoffray | 3512244 | 2016-03-02 12:05:30 +0000 | [diff] [blame] | 303 | // Whether the last collection round increased the code cache. |
| 304 | bool last_collection_increased_code_cache_ GUARDED_BY(lock_); |
Nicolas Geoffray | 0a3be16 | 2015-11-18 11:15:22 +0000 | [diff] [blame] | 305 | |
Calin Juravle | 31f2c15 | 2015-10-23 17:56:15 +0100 | [diff] [blame] | 306 | // Last time the the code_cache was updated. |
Calin Juravle | 4d77b6a | 2015-12-01 18:38:09 +0000 | [diff] [blame] | 307 | // It is atomic to avoid locking when reading it. |
| 308 | Atomic<uint64_t> last_update_time_ns_; |
Calin Juravle | 31f2c15 | 2015-10-23 17:56:15 +0100 | [diff] [blame] | 309 | |
Nicolas Geoffray | a25dce9 | 2016-01-12 16:41:10 +0000 | [diff] [blame] | 310 | // Whether we can do garbage collection. |
| 311 | const bool garbage_collect_code_; |
| 312 | |
Nicolas Geoffray | 38ea9bd | 2016-02-19 16:25:57 +0000 | [diff] [blame] | 313 | // The size in bytes of used memory for the data portion of the code cache. |
| 314 | size_t used_memory_for_data_ GUARDED_BY(lock_); |
| 315 | |
| 316 | // The size in bytes of used memory for the code portion of the code cache. |
| 317 | size_t used_memory_for_code_ GUARDED_BY(lock_); |
| 318 | |
Nicolas Geoffray | 0a52223 | 2016-01-19 09:34:58 +0000 | [diff] [blame] | 319 | // Number of compilations done throughout the lifetime of the JIT. |
| 320 | size_t number_of_compilations_ GUARDED_BY(lock_); |
Nicolas Geoffray | bcd94c8 | 2016-03-03 13:23:33 +0000 | [diff] [blame] | 321 | |
| 322 | // Number of compilations for on-stack-replacement done throughout the lifetime of the JIT. |
Nicolas Geoffray | fcdd729 | 2016-02-25 13:27:47 +0000 | [diff] [blame] | 323 | size_t number_of_osr_compilations_ GUARDED_BY(lock_); |
Nicolas Geoffray | 0a52223 | 2016-01-19 09:34:58 +0000 | [diff] [blame] | 324 | |
Nicolas Geoffray | bcd94c8 | 2016-03-03 13:23:33 +0000 | [diff] [blame] | 325 | // Number of deoptimizations done throughout the lifetime of the JIT. |
| 326 | size_t number_of_deoptimizations_ GUARDED_BY(lock_); |
| 327 | |
| 328 | // Number of code cache collections done throughout the lifetime of the JIT. |
| 329 | size_t number_of_collections_ GUARDED_BY(lock_); |
| 330 | |
Mathieu Chartier | 3130cdf | 2015-05-03 15:20:23 -0700 | [diff] [blame] | 331 | DISALLOW_IMPLICIT_CONSTRUCTORS(JitCodeCache); |
Mathieu Chartier | e5f13e5 | 2015-02-24 09:37:21 -0800 | [diff] [blame] | 332 | }; |
| 333 | |
Mathieu Chartier | e5f13e5 | 2015-02-24 09:37:21 -0800 | [diff] [blame] | 334 | } // namespace jit |
| 335 | } // namespace art |
| 336 | |
| 337 | #endif // ART_RUNTIME_JIT_JIT_CODE_CACHE_H_ |