Generalize atomic_method_ref_map to support dex references
Generalize atomic method ref map to support dex references instead
of only method references.
The goal is to use this in a future CL to replace compiled_classes_.
Test: test-art-host
Change-Id: Ic6d1e619584f790eea68f5160fa0fcd664524cd7
diff --git a/compiler/driver/compiler_driver.cc b/compiler/driver/compiler_driver.cc
index ff92ac4..49a42de 100644
--- a/compiler/driver/compiler_driver.cc
+++ b/compiler/driver/compiler_driver.cc
@@ -71,7 +71,7 @@
#include "thread_pool.h"
#include "trampolines/trampoline_compiler.h"
#include "transaction.h"
-#include "utils/atomic_method_ref_map-inl.h"
+#include "utils/atomic_dex_ref_map-inl.h"
#include "utils/dex_cache_arrays_layout-inl.h"
#include "utils/swap_space.h"
#include "vdex_file.h"
@@ -321,7 +321,7 @@
}
CompilerDriver::~CompilerDriver() {
- compiled_methods_.Visit([this](const MethodReference& ref ATTRIBUTE_UNUSED,
+ compiled_methods_.Visit([this](const DexFileReference& ref ATTRIBUTE_UNUSED,
CompiledMethod* method) {
if (method != nullptr) {
CompiledMethod::ReleaseSwapAllocatedCompiledMethod(this, method);
@@ -899,7 +899,7 @@
for (const DexFile* dex_file : dex_files) {
// Can be already inserted if the caller is CompileOne. This happens for gtests.
if (!compiled_methods_.HaveDexFile(dex_file)) {
- compiled_methods_.AddDexFile(dex_file);
+ compiled_methods_.AddDexFile(dex_file, dex_file->NumMethodIds());
}
}
// Resolve eagerly to prepare for compilation.
@@ -2847,9 +2847,10 @@
size_t non_relative_linker_patch_count) {
DCHECK(GetCompiledMethod(method_ref) == nullptr)
<< method_ref.dex_file->PrettyMethod(method_ref.dex_method_index);
- MethodTable::InsertResult result = compiled_methods_.Insert(method_ref,
- /*expected*/ nullptr,
- compiled_method);
+ MethodTable::InsertResult result = compiled_methods_.Insert(
+ DexFileReference(method_ref.dex_file, method_ref.dex_method_index),
+ /*expected*/ nullptr,
+ compiled_method);
CHECK(result == MethodTable::kInsertResultSuccess);
non_relative_linker_patch_count_.FetchAndAddRelaxed(non_relative_linker_patch_count);
DCHECK(GetCompiledMethod(method_ref) != nullptr)
@@ -2897,7 +2898,7 @@
CompiledMethod* CompilerDriver::GetCompiledMethod(MethodReference ref) const {
CompiledMethod* compiled_method = nullptr;
- compiled_methods_.Get(ref, &compiled_method);
+ compiled_methods_.Get(DexFileReference(ref.dex_file, ref.dex_method_index), &compiled_method);
return compiled_method;
}
diff --git a/compiler/driver/compiler_driver.h b/compiler/driver/compiler_driver.h
index e9e7378..a3272d3 100644
--- a/compiler/driver/compiler_driver.h
+++ b/compiler/driver/compiler_driver.h
@@ -39,7 +39,7 @@
#include "os.h"
#include "safe_map.h"
#include "thread_pool.h"
-#include "utils/atomic_method_ref_map.h"
+#include "utils/atomic_dex_ref_map.h"
#include "utils/dex_cache_arrays_layout.h"
namespace art {
@@ -489,7 +489,7 @@
mutable Mutex compiled_classes_lock_ DEFAULT_MUTEX_ACQUIRED_AFTER;
ClassStateTable compiled_classes_ GUARDED_BY(compiled_classes_lock_);
- typedef AtomicMethodRefMap<CompiledMethod*> MethodTable;
+ typedef AtomicDexRefMap<CompiledMethod*> MethodTable;
private:
// All method references that this compiler has compiled.