ART: Move dex structs into own header
Separating out the structs from DexFile allows them to be forward-
declared, which reduces the need to include the dex_file header.
Bug: 119869270
Test: m
Change-Id: I32dde5a632884bca7435cd584b4a81883de2e7b4
diff --git a/compiler/dex/dex_to_dex_compiler.cc b/compiler/dex/dex_to_dex_compiler.cc
index cf52dd9..23ce37e 100644
--- a/compiler/dex/dex_to_dex_compiler.cc
+++ b/compiler/dex/dex_to_dex_compiler.cc
@@ -505,7 +505,7 @@
}
CompiledMethod* DexToDexCompiler::CompileMethod(
- const DexFile::CodeItem* code_item,
+ const dex::CodeItem* code_item,
uint32_t access_flags,
InvokeType invoke_type ATTRIBUTE_UNUSED,
uint16_t class_def_idx,
@@ -627,11 +627,11 @@
void DexToDexCompiler::SetDexFiles(const std::vector<const DexFile*>& dex_files) {
// Record what code items are already seen to detect when multiple methods have the same code
// item.
- std::unordered_set<const DexFile::CodeItem*> seen_code_items;
+ std::unordered_set<const dex::CodeItem*> seen_code_items;
for (const DexFile* dex_file : dex_files) {
for (ClassAccessor accessor : dex_file->GetClasses()) {
for (const ClassAccessor::Method& method : accessor.GetMethods()) {
- const DexFile::CodeItem* code_item = method.GetCodeItem();
+ const dex::CodeItem* code_item = method.GetCodeItem();
// Detect the shared code items.
if (!seen_code_items.insert(code_item).second) {
shared_code_items_.insert(code_item);
@@ -646,7 +646,7 @@
MutexLock mu(Thread::Current(), lock_);
size_t unquicken_count = 0;
for (const auto& pair : shared_code_item_quicken_info_) {
- const DexFile::CodeItem* code_item = pair.first;
+ const dex::CodeItem* code_item = pair.first;
const QuickenState& state = pair.second;
CHECK_GE(state.methods_.size(), 1u);
if (state.conflict_) {
diff --git a/compiler/dex/dex_to_dex_compiler.h b/compiler/dex/dex_to_dex_compiler.h
index 7253488..78309ae 100644
--- a/compiler/dex/dex_to_dex_compiler.h
+++ b/compiler/dex/dex_to_dex_compiler.h
@@ -23,7 +23,6 @@
#include "base/bit_vector.h"
#include "base/mutex.h"
-#include "dex/dex_file.h"
#include "dex/invoke_type.h"
#include "dex/method_reference.h"
#include "handle.h"
@@ -34,6 +33,11 @@
class CompiledMethod;
class CompilerDriver;
class DexCompilationUnit;
+class DexFile;
+
+namespace dex {
+struct CodeItem;
+} // namespace dex
namespace mirror {
class ClassLoader;
@@ -50,7 +54,7 @@
explicit DexToDexCompiler(CompilerDriver* driver);
- CompiledMethod* CompileMethod(const DexFile::CodeItem* code_item,
+ CompiledMethod* CompileMethod(const dex::CodeItem* code_item,
uint32_t access_flags,
InvokeType invoke_type,
uint16_t class_def_idx,
@@ -105,9 +109,9 @@
std::unordered_map<const DexFile*, BitVector> should_quicken_;
// Guarded by lock_ during writing, accessed without a lock during quickening.
// This is safe because no thread is adding to the shared code items during the quickening phase.
- std::unordered_set<const DexFile::CodeItem*> shared_code_items_;
+ std::unordered_set<const dex::CodeItem*> shared_code_items_;
// Blacklisted code items are unquickened in UnquickenConflictingMethods.
- std::unordered_map<const DexFile::CodeItem*, QuickenState> shared_code_item_quicken_info_
+ std::unordered_map<const dex::CodeItem*, QuickenState> shared_code_item_quicken_info_
GUARDED_BY(lock_);
// Number of added code items.
size_t num_code_items_ GUARDED_BY(lock_) = 0u;
diff --git a/compiler/dex/inline_method_analyser.cc b/compiler/dex/inline_method_analyser.cc
index ba2ebd9..b0f025d 100644
--- a/compiler/dex/inline_method_analyser.cc
+++ b/compiler/dex/inline_method_analyser.cc
@@ -511,7 +511,7 @@
}
bool InlineMethodAnalyser::IsSyntheticAccessor(MethodReference ref) {
- const DexFile::MethodId& method_id = ref.dex_file->GetMethodId(ref.index);
+ const dex::MethodId& method_id = ref.dex_file->GetMethodId(ref.index);
const char* method_name = ref.dex_file->GetMethodName(method_id);
// javac names synthetic accessors "access$nnn",
// jack names them "-getN", "-putN", "-wrapN".