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/dex2oat/dex2oat_test.cc b/dex2oat/dex2oat_test.cc
index 92dd932..fd454f0 100644
--- a/dex2oat/dex2oat_test.cc
+++ b/dex2oat/dex2oat_test.cc
@@ -1331,7 +1331,7 @@
// first.
std::vector<uint16_t> methods;
{
- const DexFile::TypeId* type_id = dex->FindTypeId("LManyMethods;");
+ const dex::TypeId* type_id = dex->FindTypeId("LManyMethods;");
dex::TypeIndex type_idx = dex->GetIndexForTypeId(*type_id);
ClassAccessor accessor(*dex, *dex->FindClassDef(type_idx));
std::set<size_t> code_item_offsets;
@@ -1431,10 +1431,10 @@
// we expect.
std::unique_ptr<const DexFile> dex_file(oat_dex->OpenDexFile(&error_msg));
ASSERT_TRUE(dex_file != nullptr) << error_msg;
- const DexFile::TypeId* type_id = dex_file->FindTypeId("LManyMethods;");
+ const dex::TypeId* type_id = dex_file->FindTypeId("LManyMethods;");
ASSERT_TRUE(type_id != nullptr);
dex::TypeIndex type_idx = dex_file->GetIndexForTypeId(*type_id);
- const DexFile::ClassDef* class_def = dex_file->FindClassDef(type_idx);
+ const dex::ClassDef* class_def = dex_file->FindClassDef(type_idx);
ASSERT_TRUE(class_def != nullptr);
// Count how many code items are for each category, there should be at least one per category.
diff --git a/dex2oat/linker/image_test.h b/dex2oat/linker/image_test.h
index fa0a3d4..70a22b5 100644
--- a/dex2oat/linker/image_test.h
+++ b/dex2oat/linker/image_test.h
@@ -492,7 +492,7 @@
CHECK_EQ(kRequestedImageBase, reinterpret_cast<uintptr_t>(image_begin));
}
for (size_t j = 0; j < dex->NumClassDefs(); ++j) {
- const DexFile::ClassDef& class_def = dex->GetClassDef(j);
+ const dex::ClassDef& class_def = dex->GetClassDef(j);
const char* descriptor = dex->GetClassDescriptor(class_def);
ObjPtr<mirror::Class> klass = class_linker_->FindSystemClass(soa.Self(), descriptor);
EXPECT_TRUE(klass != nullptr) << descriptor;
diff --git a/dex2oat/linker/image_writer.cc b/dex2oat/linker/image_writer.cc
index e4e4b13..1331fc3 100644
--- a/dex2oat/linker/image_writer.cc
+++ b/dex2oat/linker/image_writer.cc
@@ -1586,7 +1586,7 @@
// Check if the referenced class is in the image. Note that we want to check the referenced
// class rather than the declaring class to preserve the semantics, i.e. using a MethodId
// results in resolving the referenced class and that can for example throw OOME.
- const DexFile::MethodId& method_id = dex_file.GetMethodId(stored_index);
+ const dex::MethodId& method_id = dex_file.GetMethodId(stored_index);
if (method_id.class_idx_ != last_class_idx) {
last_class_idx = method_id.class_idx_;
last_class = class_linker->LookupResolvedType(last_class_idx, dex_cache, class_loader);
@@ -1612,7 +1612,7 @@
// Check if the referenced class is in the image. Note that we want to check the referenced
// class rather than the declaring class to preserve the semantics, i.e. using a FieldId
// results in resolving the referenced class and that can for example throw OOME.
- const DexFile::FieldId& field_id = dex_file.GetFieldId(stored_index);
+ const dex::FieldId& field_id = dex_file.GetFieldId(stored_index);
if (field_id.class_idx_ != last_class_idx) {
last_class_idx = field_id.class_idx_;
last_class = class_linker->LookupResolvedType(last_class_idx, dex_cache, class_loader);
@@ -1663,7 +1663,7 @@
// Check if the referenced class is in the image. Note that we want to check the referenced
// class rather than the declaring class to preserve the semantics, i.e. using a MethodId
// results in resolving the referenced class and that can for example throw OOME.
- const DexFile::MethodId& method_id = dex_file.GetMethodId(i);
+ const dex::MethodId& method_id = dex_file.GetMethodId(i);
if (method_id.class_idx_ != last_class_idx) {
last_class_idx = method_id.class_idx_;
last_class = class_linker->LookupResolvedType(last_class_idx, dex_cache, class_loader);
@@ -1695,7 +1695,7 @@
// Check if the referenced class is in the image. Note that we want to check the referenced
// class rather than the declaring class to preserve the semantics, i.e. using a FieldId
// results in resolving the referenced class and that can for example throw OOME.
- const DexFile::FieldId& field_id = dex_file.GetFieldId(i);
+ const dex::FieldId& field_id = dex_file.GetFieldId(i);
if (field_id.class_idx_ != last_class_idx) {
last_class_idx = field_id.class_idx_;
last_class = class_linker->LookupResolvedType(last_class_idx, dex_cache, class_loader);
diff --git a/dex2oat/linker/oat_writer.cc b/dex2oat/linker/oat_writer.cc
index e2a9ac2..be9a0cb 100644
--- a/dex2oat/linker/oat_writer.cc
+++ b/dex2oat/linker/oat_writer.cc
@@ -1011,7 +1011,7 @@
size_t class_def_index;
uint32_t access_flags;
- const DexFile::CodeItem* code_item;
+ const dex::CodeItem* code_item;
// A value of -1 denotes missing debug info
static constexpr size_t kDebugInfoIdxInvalid = static_cast<size_t>(-1);
@@ -1506,7 +1506,7 @@
return true;
}
ObjPtr<mirror::DexCache> dex_cache = class_linker_->FindDexCache(Thread::Current(), *dex_file);
- const DexFile::ClassDef& class_def = dex_file->GetClassDef(class_def_index);
+ const dex::ClassDef& class_def = dex_file->GetClassDef(class_def_index);
ObjPtr<mirror::Class> klass =
class_linker_->LookupResolvedType(class_def.class_idx_, dex_cache, class_loader_);
if (klass != nullptr) {
@@ -1585,7 +1585,7 @@
// Check whether current class is image class
bool IsImageClass() {
- const DexFile::TypeId& type_id =
+ const dex::TypeId& type_id =
dex_file_->GetTypeId(dex_file_->GetClassDef(class_def_index_).class_idx_);
const char* class_descriptor = dex_file_->GetTypeDescriptor(type_id);
return writer_->GetCompilerOptions().IsImageClass(class_descriptor);