blob: ea26d587674a3f316008280952499e9fe7279b53 [file] [log] [blame]
Mathieu Chartierf9c6fc62015-10-07 11:44:05 -07001/*
2 * Copyright (C) 2015 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 "oat_file_manager.h"
18
Mathieu Chartiera6e81ed2016-02-25 13:52:10 -080019#define ATRACE_TAG ATRACE_TAG_DALVIK
20#include <cutils/trace.h>
Mathieu Chartierf9c6fc62015-10-07 11:44:05 -070021#include <memory>
22#include <queue>
23#include <vector>
24
25#include "base/logging.h"
26#include "base/stl_util.h"
Mathieu Chartierfbc31082016-01-24 11:59:56 -080027#include "class_linker.h"
Mathieu Chartier80b37b72015-10-12 18:13:39 -070028#include "dex_file-inl.h"
Mathieu Chartier61d2b2d2016-02-04 13:31:46 -080029#include "gc/scoped_gc_critical_section.h"
Mathieu Chartierf9c6fc62015-10-07 11:44:05 -070030#include "gc/space/image_space.h"
Mathieu Chartierfbc31082016-01-24 11:59:56 -080031#include "handle_scope-inl.h"
32#include "mirror/class_loader.h"
Mathieu Chartierf9c6fc62015-10-07 11:44:05 -070033#include "oat_file_assistant.h"
Mathieu Chartierfbc31082016-01-24 11:59:56 -080034#include "scoped_thread_state_change.h"
Mathieu Chartierf9c6fc62015-10-07 11:44:05 -070035#include "thread-inl.h"
Mathieu Chartiera9d82fe2016-01-25 20:06:11 -080036#include "thread_list.h"
Mathieu Chartierf9c6fc62015-10-07 11:44:05 -070037
38namespace art {
39
40// For b/21333911.
Mathieu Chartier80b37b72015-10-12 18:13:39 -070041// Only enabled for debug builds to prevent bit rot. There are too many performance regressions for
42// normal builds.
43static constexpr bool kDuplicateClassesCheck = kIsDebugBuild;
Mathieu Chartierf9c6fc62015-10-07 11:44:05 -070044
Mathieu Chartierfbc31082016-01-24 11:59:56 -080045// If true, then we attempt to load the application image if it exists.
46static constexpr bool kEnableAppImage = true;
47
Mathieu Chartierf9c6fc62015-10-07 11:44:05 -070048const OatFile* OatFileManager::RegisterOatFile(std::unique_ptr<const OatFile> oat_file) {
Mathieu Chartiere58991b2015-10-13 07:59:34 -070049 WriterMutexLock mu(Thread::Current(), *Locks::oat_file_manager_lock_);
Mathieu Chartierf9c6fc62015-10-07 11:44:05 -070050 DCHECK(oat_file != nullptr);
51 if (kIsDebugBuild) {
Mathieu Chartiere58991b2015-10-13 07:59:34 -070052 CHECK(oat_files_.find(oat_file) == oat_files_.end());
Mathieu Chartierf9c6fc62015-10-07 11:44:05 -070053 for (const std::unique_ptr<const OatFile>& existing : oat_files_) {
54 CHECK_NE(oat_file.get(), existing.get()) << oat_file->GetLocation();
55 // Check that we don't have an oat file with the same address. Copies of the same oat file
56 // should be loaded at different addresses.
57 CHECK_NE(oat_file->Begin(), existing->Begin()) << "Oat file already mapped at that location";
58 }
59 }
60 have_non_pic_oat_file_ = have_non_pic_oat_file_ || !oat_file->IsPic();
Mathieu Chartiere58991b2015-10-13 07:59:34 -070061 const OatFile* ret = oat_file.get();
62 oat_files_.insert(std::move(oat_file));
63 return ret;
64}
65
66void OatFileManager::UnRegisterAndDeleteOatFile(const OatFile* oat_file) {
67 WriterMutexLock mu(Thread::Current(), *Locks::oat_file_manager_lock_);
68 DCHECK(oat_file != nullptr);
69 std::unique_ptr<const OatFile> compare(oat_file);
70 auto it = oat_files_.find(compare);
71 CHECK(it != oat_files_.end());
72 oat_files_.erase(it);
73 compare.release();
Mathieu Chartierf9c6fc62015-10-07 11:44:05 -070074}
75
76const OatFile* OatFileManager::FindOpenedOatFileFromOatLocation(const std::string& oat_location)
77 const {
78 ReaderMutexLock mu(Thread::Current(), *Locks::oat_file_manager_lock_);
Mathieu Chartiere58991b2015-10-13 07:59:34 -070079 return FindOpenedOatFileFromOatLocationLocked(oat_location);
80}
81
82const OatFile* OatFileManager::FindOpenedOatFileFromOatLocationLocked(
83 const std::string& oat_location) const {
Mathieu Chartierf9c6fc62015-10-07 11:44:05 -070084 for (const std::unique_ptr<const OatFile>& oat_file : oat_files_) {
85 if (oat_file->GetLocation() == oat_location) {
86 return oat_file.get();
87 }
88 }
89 return nullptr;
90}
91
Jeff Haodcdc85b2015-12-04 14:06:18 -080092std::vector<const OatFile*> OatFileManager::GetBootOatFiles() const {
93 std::vector<const OatFile*> oat_files;
94 std::vector<gc::space::ImageSpace*> image_spaces =
95 Runtime::Current()->GetHeap()->GetBootImageSpaces();
96 for (gc::space::ImageSpace* image_space : image_spaces) {
97 oat_files.push_back(image_space->GetOatFile());
98 }
99 return oat_files;
Mathieu Chartierf9c6fc62015-10-07 11:44:05 -0700100}
101
102const OatFile* OatFileManager::GetPrimaryOatFile() const {
103 ReaderMutexLock mu(Thread::Current(), *Locks::oat_file_manager_lock_);
Jeff Haodcdc85b2015-12-04 14:06:18 -0800104 std::vector<const OatFile*> boot_oat_files = GetBootOatFiles();
105 if (!boot_oat_files.empty()) {
Mathieu Chartierf9c6fc62015-10-07 11:44:05 -0700106 for (const std::unique_ptr<const OatFile>& oat_file : oat_files_) {
Jeff Haodcdc85b2015-12-04 14:06:18 -0800107 if (std::find(boot_oat_files.begin(), boot_oat_files.end(), oat_file.get()) ==
108 boot_oat_files.end()) {
Mathieu Chartierf9c6fc62015-10-07 11:44:05 -0700109 return oat_file.get();
110 }
111 }
112 }
113 return nullptr;
114}
115
116OatFileManager::~OatFileManager() {
Mathieu Chartiere58991b2015-10-13 07:59:34 -0700117 // Explicitly clear oat_files_ since the OatFile destructor calls back into OatFileManager for
118 // UnRegisterOatFileLocation.
119 oat_files_.clear();
Mathieu Chartierf9c6fc62015-10-07 11:44:05 -0700120}
121
Jeff Haodcdc85b2015-12-04 14:06:18 -0800122std::vector<const OatFile*> OatFileManager::RegisterImageOatFiles(
123 std::vector<gc::space::ImageSpace*> spaces) {
124 std::vector<const OatFile*> oat_files;
125 for (gc::space::ImageSpace* space : spaces) {
126 oat_files.push_back(RegisterOatFile(space->ReleaseOatFile()));
127 }
128 return oat_files;
Mathieu Chartierf9c6fc62015-10-07 11:44:05 -0700129}
130
131class DexFileAndClassPair : ValueObject {
132 public:
133 DexFileAndClassPair(const DexFile* dex_file, size_t current_class_index, bool from_loaded_oat)
134 : cached_descriptor_(GetClassDescriptor(dex_file, current_class_index)),
135 dex_file_(dex_file),
136 current_class_index_(current_class_index),
137 from_loaded_oat_(from_loaded_oat) {}
138
Mathieu Chartier80b37b72015-10-12 18:13:39 -0700139 DexFileAndClassPair(const DexFileAndClassPair& rhs) = default;
Mathieu Chartierf9c6fc62015-10-07 11:44:05 -0700140
Mathieu Chartier80b37b72015-10-12 18:13:39 -0700141 DexFileAndClassPair& operator=(const DexFileAndClassPair& rhs) = default;
Mathieu Chartierf9c6fc62015-10-07 11:44:05 -0700142
143 const char* GetCachedDescriptor() const {
144 return cached_descriptor_;
145 }
146
147 bool operator<(const DexFileAndClassPair& rhs) const {
148 const int cmp = strcmp(cached_descriptor_, rhs.cached_descriptor_);
149 if (cmp != 0) {
150 // Note that the order must be reversed. We want to iterate over the classes in dex files.
151 // They are sorted lexicographically. Thus, the priority-queue must be a min-queue.
152 return cmp > 0;
153 }
154 return dex_file_ < rhs.dex_file_;
155 }
156
157 bool DexFileHasMoreClasses() const {
158 return current_class_index_ + 1 < dex_file_->NumClassDefs();
159 }
160
161 void Next() {
162 ++current_class_index_;
Mathieu Chartier80b37b72015-10-12 18:13:39 -0700163 cached_descriptor_ = GetClassDescriptor(dex_file_.get(), current_class_index_);
Mathieu Chartierf9c6fc62015-10-07 11:44:05 -0700164 }
165
166 size_t GetCurrentClassIndex() const {
167 return current_class_index_;
168 }
169
170 bool FromLoadedOat() const {
171 return from_loaded_oat_;
172 }
173
174 const DexFile* GetDexFile() const {
175 return dex_file_.get();
176 }
177
178 private:
179 static const char* GetClassDescriptor(const DexFile* dex_file, size_t index) {
180 DCHECK(IsUint<16>(index));
181 const DexFile::ClassDef& class_def = dex_file->GetClassDef(static_cast<uint16_t>(index));
182 return dex_file->StringByTypeIdx(class_def.class_idx_);
183 }
184
185 const char* cached_descriptor_;
Mathieu Chartier80b37b72015-10-12 18:13:39 -0700186 std::shared_ptr<const DexFile> dex_file_;
Mathieu Chartierf9c6fc62015-10-07 11:44:05 -0700187 size_t current_class_index_;
188 bool from_loaded_oat_; // We only need to compare mismatches between what we load now
189 // and what was loaded before. Any old duplicates must have been
190 // OK, and any new "internal" duplicates are as well (they must
191 // be from multidex, which resolves correctly).
192};
193
194static void AddDexFilesFromOat(const OatFile* oat_file,
195 bool already_loaded,
196 /*out*/std::priority_queue<DexFileAndClassPair>* heap) {
197 for (const OatDexFile* oat_dex_file : oat_file->GetOatDexFiles()) {
198 std::string error;
199 std::unique_ptr<const DexFile> dex_file = oat_dex_file->OpenDexFile(&error);
200 if (dex_file == nullptr) {
201 LOG(WARNING) << "Could not create dex file from oat file: " << error;
202 } else if (dex_file->NumClassDefs() > 0U) {
203 heap->emplace(dex_file.release(), /*current_class_index*/0U, already_loaded);
204 }
205 }
206}
207
208static void AddNext(/*inout*/DexFileAndClassPair* original,
209 /*inout*/std::priority_queue<DexFileAndClassPair>* heap) {
210 if (original->DexFileHasMoreClasses()) {
211 original->Next();
212 heap->push(std::move(*original));
213 }
214}
215
216// Check for class-def collisions in dex files.
217//
218// This works by maintaining a heap with one class from each dex file, sorted by the class
219// descriptor. Then a dex-file/class pair is continually removed from the heap and compared
220// against the following top element. If the descriptor is the same, it is now checked whether
221// the two elements agree on whether their dex file was from an already-loaded oat-file or the
222// new oat file. Any disagreement indicates a collision.
223bool OatFileManager::HasCollisions(const OatFile* oat_file,
224 std::string* error_msg /*out*/) const {
225 DCHECK(oat_file != nullptr);
226 DCHECK(error_msg != nullptr);
227 if (!kDuplicateClassesCheck) {
228 return false;
229 }
230
231 // Dex files are registered late - once a class is actually being loaded. We have to compare
232 // against the open oat files. Take the oat_file_manager_lock_ that protects oat_files_ accesses.
233 ReaderMutexLock mu(Thread::Current(), *Locks::oat_file_manager_lock_);
234
235 std::priority_queue<DexFileAndClassPair> queue;
236
237 // Add dex files from already loaded oat files, but skip boot.
Jeff Haodcdc85b2015-12-04 14:06:18 -0800238 std::vector<const OatFile*> boot_oat_files = GetBootOatFiles();
Mathieu Chartier80b37b72015-10-12 18:13:39 -0700239 // The same OatFile can be loaded multiple times at different addresses. In this case, we don't
240 // need to check both against each other since they would have resolved the same way at compile
241 // time.
242 std::unordered_set<std::string> unique_locations;
Mathieu Chartierf9c6fc62015-10-07 11:44:05 -0700243 for (const std::unique_ptr<const OatFile>& loaded_oat_file : oat_files_) {
Mathieu Chartier80b37b72015-10-12 18:13:39 -0700244 DCHECK_NE(loaded_oat_file.get(), oat_file);
245 const std::string& location = loaded_oat_file->GetLocation();
Jeff Haodcdc85b2015-12-04 14:06:18 -0800246 if (std::find(boot_oat_files.begin(), boot_oat_files.end(), loaded_oat_file.get()) ==
247 boot_oat_files.end() && location != oat_file->GetLocation() &&
Mathieu Chartier80b37b72015-10-12 18:13:39 -0700248 unique_locations.find(location) == unique_locations.end()) {
249 unique_locations.insert(location);
Mathieu Chartierf9c6fc62015-10-07 11:44:05 -0700250 AddDexFilesFromOat(loaded_oat_file.get(), /*already_loaded*/true, &queue);
251 }
252 }
253
254 if (queue.empty()) {
255 // No other oat files, return early.
256 return false;
257 }
258
259 // Add dex files from the oat file to check.
260 AddDexFilesFromOat(oat_file, /*already_loaded*/false, &queue);
261
262 // Now drain the queue.
263 while (!queue.empty()) {
264 // Modifying the top element is only safe if we pop right after.
Mathieu Chartier80b37b72015-10-12 18:13:39 -0700265 DexFileAndClassPair compare_pop(queue.top());
Mathieu Chartierf9c6fc62015-10-07 11:44:05 -0700266 queue.pop();
267
268 // Compare against the following elements.
269 while (!queue.empty()) {
Mathieu Chartier80b37b72015-10-12 18:13:39 -0700270 DexFileAndClassPair top(queue.top());
Mathieu Chartierf9c6fc62015-10-07 11:44:05 -0700271
272 if (strcmp(compare_pop.GetCachedDescriptor(), top.GetCachedDescriptor()) == 0) {
273 // Same descriptor. Check whether it's crossing old-oat-files to new-oat-files.
274 if (compare_pop.FromLoadedOat() != top.FromLoadedOat()) {
275 *error_msg =
276 StringPrintf("Found duplicated class when checking oat files: '%s' in %s and %s",
277 compare_pop.GetCachedDescriptor(),
278 compare_pop.GetDexFile()->GetLocation().c_str(),
279 top.GetDexFile()->GetLocation().c_str());
280 return true;
281 }
Mathieu Chartierf9c6fc62015-10-07 11:44:05 -0700282 queue.pop();
283 AddNext(&top, &queue);
284 } else {
285 // Something else. Done here.
286 break;
287 }
288 }
289 AddNext(&compare_pop, &queue);
290 }
291
292 return false;
293}
294
295std::vector<std::unique_ptr<const DexFile>> OatFileManager::OpenDexFilesFromOat(
296 const char* dex_location,
297 const char* oat_location,
Mathieu Chartierfbc31082016-01-24 11:59:56 -0800298 jobject class_loader,
299 jobjectArray dex_elements,
Mathieu Chartiere58991b2015-10-13 07:59:34 -0700300 const OatFile** out_oat_file,
Mathieu Chartierf9c6fc62015-10-07 11:44:05 -0700301 std::vector<std::string>* error_msgs) {
302 CHECK(dex_location != nullptr);
303 CHECK(error_msgs != nullptr);
304
305 // Verify we aren't holding the mutator lock, which could starve GC if we
306 // have to generate or relocate an oat file.
Mathieu Chartierfbc31082016-01-24 11:59:56 -0800307 Thread* const self = Thread::Current();
308 Locks::mutator_lock_->AssertNotHeld(self);
309 Runtime* const runtime = Runtime::Current();
Mathieu Chartierf9c6fc62015-10-07 11:44:05 -0700310 OatFileAssistant oat_file_assistant(dex_location,
311 oat_location,
312 kRuntimeISA,
Mathieu Chartierfbc31082016-01-24 11:59:56 -0800313 !runtime->IsAotCompiler());
Mathieu Chartierf9c6fc62015-10-07 11:44:05 -0700314
315 // Lock the target oat location to avoid races generating and loading the
316 // oat file.
317 std::string error_msg;
318 if (!oat_file_assistant.Lock(/*out*/&error_msg)) {
319 // Don't worry too much if this fails. If it does fail, it's unlikely we
320 // can generate an oat file anyway.
321 VLOG(class_linker) << "OatFileAssistant::Lock: " << error_msg;
322 }
323
324 const OatFile* source_oat_file = nullptr;
325
Nicolas Geoffraye722d292015-12-15 11:51:37 +0000326 // Update the oat file on disk if we can. This may fail, but that's okay.
327 // Best effort is all that matters here.
328 if (!oat_file_assistant.MakeUpToDate(/*out*/&error_msg)) {
Nicolas Geoffraya28267f2015-12-16 12:34:50 +0000329 LOG(INFO) << error_msg;
Mathieu Chartierf9c6fc62015-10-07 11:44:05 -0700330 }
331
332 // Get the oat file on disk.
333 std::unique_ptr<const OatFile> oat_file(oat_file_assistant.GetBestOatFile().release());
Mathieu Chartierfbc31082016-01-24 11:59:56 -0800334
Mathieu Chartierf9c6fc62015-10-07 11:44:05 -0700335 if (oat_file != nullptr) {
336 // Take the file only if it has no collisions, or we must take it because of preopting.
337 bool accept_oat_file = !HasCollisions(oat_file.get(), /*out*/ &error_msg);
338 if (!accept_oat_file) {
339 // Failed the collision check. Print warning.
340 if (Runtime::Current()->IsDexFileFallbackEnabled()) {
341 LOG(WARNING) << "Found duplicate classes, falling back to interpreter mode for "
342 << dex_location;
343 } else {
344 LOG(WARNING) << "Found duplicate classes, dex-file-fallback disabled, will be failing to "
345 " load classes for " << dex_location;
346 }
347 LOG(WARNING) << error_msg;
348
349 // However, if the app was part of /system and preopted, there is no original dex file
350 // available. In that case grudgingly accept the oat file.
351 if (!DexFile::MaybeDex(dex_location)) {
352 accept_oat_file = true;
353 LOG(WARNING) << "Dex location " << dex_location << " does not seem to include dex file. "
354 << "Allow oat file use. This is potentially dangerous.";
355 }
356 }
357
358 if (accept_oat_file) {
359 VLOG(class_linker) << "Registering " << oat_file->GetLocation();
360 source_oat_file = RegisterOatFile(std::move(oat_file));
Mathieu Chartiere58991b2015-10-13 07:59:34 -0700361 *out_oat_file = source_oat_file;
Mathieu Chartierf9c6fc62015-10-07 11:44:05 -0700362 }
363 }
364
365 std::vector<std::unique_ptr<const DexFile>> dex_files;
366
367 // Load the dex files from the oat file.
368 if (source_oat_file != nullptr) {
Mathieu Chartierfbc31082016-01-24 11:59:56 -0800369 bool added_image_space = false;
370 if (source_oat_file->IsExecutable()) {
371 std::unique_ptr<gc::space::ImageSpace> image_space(
372 kEnableAppImage ? oat_file_assistant.OpenImageSpace(source_oat_file) : nullptr);
373 if (image_space != nullptr) {
374 ScopedObjectAccess soa(self);
375 StackHandleScope<1> hs(self);
376 Handle<mirror::ClassLoader> h_loader(
377 hs.NewHandle(soa.Decode<mirror::ClassLoader*>(class_loader)));
378 // Can not load app image without class loader.
379 if (h_loader.Get() != nullptr) {
380 std::string temp_error_msg;
381 // Add image space has a race condition since other threads could be reading from the
382 // spaces array.
Mathieu Chartiera9d82fe2016-01-25 20:06:11 -0800383 {
384 ScopedThreadSuspension sts(self, kSuspended);
Mathieu Chartier61d2b2d2016-02-04 13:31:46 -0800385 gc::ScopedGCCriticalSection gcs(self,
386 gc::kGcCauseAddRemoveAppImageSpace,
387 gc::kCollectorTypeAddRemoveAppImageSpace);
Mathieu Chartiera9d82fe2016-01-25 20:06:11 -0800388 ScopedSuspendAll ssa("Add image space");
389 runtime->GetHeap()->AddSpace(image_space.get());
390 }
Mathieu Chartiera6e81ed2016-02-25 13:52:10 -0800391 ATRACE_BEGIN(StringPrintf("Adding image space for location %s", dex_location).c_str());
392 added_image_space = runtime->GetClassLinker()->AddImageSpace(image_space.get(),
393 h_loader,
394 dex_elements,
395 dex_location,
396 /*out*/&dex_files,
397 /*out*/&temp_error_msg);
398 ATRACE_END();
399 if (added_image_space) {
Mathieu Chartierbd064ea2016-02-11 16:27:18 -0800400 // Successfully added image space to heap, release the map so that it does not get
401 // freed.
402 image_space.release();
403 } else {
Mathieu Chartierfbc31082016-01-24 11:59:56 -0800404 LOG(INFO) << "Failed to add image file " << temp_error_msg;
405 dex_files.clear();
Mathieu Chartiera9d82fe2016-01-25 20:06:11 -0800406 {
407 ScopedThreadSuspension sts(self, kSuspended);
Mathieu Chartier61d2b2d2016-02-04 13:31:46 -0800408 gc::ScopedGCCriticalSection gcs(self,
409 gc::kGcCauseAddRemoveAppImageSpace,
410 gc::kCollectorTypeAddRemoveAppImageSpace);
Mathieu Chartiera9d82fe2016-01-25 20:06:11 -0800411 ScopedSuspendAll ssa("Remove image space");
412 runtime->GetHeap()->RemoveSpace(image_space.get());
413 }
Mathieu Chartierfbc31082016-01-24 11:59:56 -0800414 // Non-fatal, don't update error_msg.
415 }
Mathieu Chartierfbc31082016-01-24 11:59:56 -0800416 }
417 }
418 }
419 if (!added_image_space) {
420 DCHECK(dex_files.empty());
421 dex_files = oat_file_assistant.LoadDexFiles(*source_oat_file, dex_location);
422 }
Mathieu Chartierf9c6fc62015-10-07 11:44:05 -0700423 if (dex_files.empty()) {
424 error_msgs->push_back("Failed to open dex files from " + source_oat_file->GetLocation());
425 }
426 }
427
428 // Fall back to running out of the original dex file if we couldn't load any
429 // dex_files from the oat file.
430 if (dex_files.empty()) {
431 if (oat_file_assistant.HasOriginalDexFiles()) {
432 if (Runtime::Current()->IsDexFileFallbackEnabled()) {
433 if (!DexFile::Open(dex_location, dex_location, /*out*/ &error_msg, &dex_files)) {
434 LOG(WARNING) << error_msg;
435 error_msgs->push_back("Failed to open dex files from " + std::string(dex_location));
436 }
437 } else {
438 error_msgs->push_back("Fallback mode disabled, skipping dex files.");
439 }
440 } else {
441 error_msgs->push_back("No original dex files found for dex location "
442 + std::string(dex_location));
443 }
444 }
445 return dex_files;
446}
447
Mathieu Chartiere58991b2015-10-13 07:59:34 -0700448bool OatFileManager::RegisterOatFileLocation(const std::string& oat_location) {
449 WriterMutexLock mu(Thread::Current(), *Locks::oat_file_count_lock_);
450 auto it = oat_file_count_.find(oat_location);
451 if (it != oat_file_count_.end()) {
452 ++it->second;
453 return false;
454 }
455 oat_file_count_.insert(std::pair<std::string, size_t>(oat_location, 1u));
456 return true;
457}
458
459void OatFileManager::UnRegisterOatFileLocation(const std::string& oat_location) {
460 WriterMutexLock mu(Thread::Current(), *Locks::oat_file_count_lock_);
461 auto it = oat_file_count_.find(oat_location);
462 if (it != oat_file_count_.end()) {
463 --it->second;
464 if (it->second == 0) {
465 oat_file_count_.erase(it);
466 }
467 }
468}
469
Mathieu Chartierf9c6fc62015-10-07 11:44:05 -0700470} // namespace art