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/common_compiler_test.cc b/compiler/common_compiler_test.cc
index 72afb98..07c73c9 100644
--- a/compiler/common_compiler_test.cc
+++ b/compiler/common_compiler_test.cc
@@ -264,7 +264,7 @@
     Handle<mirror::DexCache> dex_cache(hs.NewHandle(method->GetDexCache()));
     Handle<mirror::ClassLoader> h_class_loader = hs.NewHandle(
         self->DecodeJObject(class_loader)->AsClassLoader());
-    const DexFile::CodeItem* code_item = dex_file->GetCodeItem(method->GetCodeItemOffset());
+    const dex::CodeItem* code_item = dex_file->GetCodeItem(method->GetCodeItemOffset());
 
     std::vector<const DexFile*> dex_files;
     dex_files.push_back(dex_file);
diff --git a/compiler/compiler.cc b/compiler/compiler.cc
index 646040f..54da446 100644
--- a/compiler/compiler.cc
+++ b/compiler/compiler.cc
@@ -21,6 +21,7 @@
 #include "base/macros.h"
 #include "base/utils.h"
 #include "dex/code_item_accessors-inl.h"
+#include "dex/dex_file.h"
 #include "driver/compiler_driver.h"
 #include "optimizing/optimizing_compiler.h"
 
@@ -39,7 +40,7 @@
   }
 }
 
-bool Compiler::IsPathologicalCase(const DexFile::CodeItem& code_item,
+bool Compiler::IsPathologicalCase(const dex::CodeItem& code_item,
                                   uint32_t method_idx,
                                   const DexFile& dex_file) {
   /*
diff --git a/compiler/compiler.h b/compiler/compiler.h
index 8c07773..8a67724 100644
--- a/compiler/compiler.h
+++ b/compiler/compiler.h
@@ -19,10 +19,13 @@
 
 #include "base/mutex.h"
 #include "base/os.h"
-#include "dex/dex_file.h"
+#include "dex/invoke_type.h"
 
 namespace art {
 
+namespace dex {
+struct CodeItem;
+}  // namespace dex
 namespace jit {
 class JitCodeCache;
 class JitLogger;
@@ -35,6 +38,7 @@
 class ArtMethod;
 class CompilerDriver;
 class CompiledMethod;
+class DexFile;
 template<class T> class Handle;
 class OatWriter;
 class Thread;
@@ -54,7 +58,7 @@
 
   virtual bool CanCompileMethod(uint32_t method_idx, const DexFile& dex_file) const = 0;
 
-  virtual CompiledMethod* Compile(const DexFile::CodeItem* code_item,
+  virtual CompiledMethod* Compile(const dex::CodeItem* code_item,
                                   uint32_t access_flags,
                                   InvokeType invoke_type,
                                   uint16_t class_def_idx,
@@ -102,7 +106,7 @@
 
   // Returns whether the method to compile is such a pathological case that
   // it's not worth compiling.
-  static bool IsPathologicalCase(const DexFile::CodeItem& code_item,
+  static bool IsPathologicalCase(const dex::CodeItem& code_item,
                                  uint32_t method_idx,
                                  const DexFile& dex_file);
 
diff --git a/compiler/debug/elf_debug_info_writer.h b/compiler/debug/elf_debug_info_writer.h
index bb550b3..a63f241 100644
--- a/compiler/debug/elf_debug_info_writer.h
+++ b/compiler/debug/elf_debug_info_writer.h
@@ -152,9 +152,9 @@
       DCHECK(mi->dex_file != nullptr);
       const DexFile* dex = mi->dex_file;
       CodeItemDebugInfoAccessor accessor(*dex, mi->code_item, mi->dex_method_index);
-      const DexFile::MethodId& dex_method = dex->GetMethodId(mi->dex_method_index);
-      const DexFile::ProtoId& dex_proto = dex->GetMethodPrototype(dex_method);
-      const DexFile::TypeList* dex_params = dex->GetProtoParameters(dex_proto);
+      const dex::MethodId& dex_method = dex->GetMethodId(mi->dex_method_index);
+      const dex::ProtoId& dex_proto = dex->GetMethodPrototype(dex_method);
+      const dex::TypeList* dex_params = dex->GetProtoParameters(dex_proto);
       const char* dex_class_desc = dex->GetMethodDeclaringClassDescriptor(dex_method);
       const bool is_static = (mi->access_flags & kAccStatic) != 0;
 
diff --git a/compiler/debug/elf_debug_writer.cc b/compiler/debug/elf_debug_writer.cc
index 0f2d73e..16f163b 100644
--- a/compiler/debug/elf_debug_writer.cc
+++ b/compiler/debug/elf_debug_writer.cc
@@ -54,7 +54,7 @@
   WriteCFISection(builder, debug_info.compiled_methods, cfi_format, write_oat_patches);
 
   // Group the methods into compilation units based on class.
-  std::unordered_map<const DexFile::ClassDef*, ElfCompilationUnit> class_to_compilation_unit;
+  std::unordered_map<const dex::ClassDef*, ElfCompilationUnit> class_to_compilation_unit;
   for (const MethodDebugInfo& mi : debug_info.compiled_methods) {
     if (mi.dex_file != nullptr) {
       auto& dex_class_def = mi.dex_file->GetClassDef(mi.class_def_index);
diff --git a/compiler/debug/method_debug_info.h b/compiler/debug/method_debug_info.h
index 729c403..152db6e 100644
--- a/compiler/debug/method_debug_info.h
+++ b/compiler/debug/method_debug_info.h
@@ -32,7 +32,7 @@
   size_t class_def_index;
   uint32_t dex_method_index;
   uint32_t access_flags;
-  const DexFile::CodeItem* code_item;
+  const dex::CodeItem* code_item;
   InstructionSet isa;
   bool deduped;
   bool is_native_debuggable;
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".
diff --git a/compiler/driver/compiler_driver-inl.h b/compiler/driver/compiler_driver-inl.h
index 63dcb46..ec2e38b 100644
--- a/compiler/driver/compiler_driver-inl.h
+++ b/compiler/driver/compiler_driver-inl.h
@@ -57,7 +57,7 @@
     const DexCompilationUnit* mUnit) {
   DCHECK_EQ(dex_cache->GetDexFile(), mUnit->GetDexFile());
   DCHECK_EQ(class_loader.Get(), mUnit->GetClassLoader().Get());
-  const DexFile::MethodId& referrer_method_id =
+  const dex::MethodId& referrer_method_id =
       mUnit->GetDexFile()->GetMethodId(mUnit->GetDexMethodIndex());
   return ResolveClass(soa, dex_cache, class_loader, referrer_method_id.class_idx_, mUnit);
 }
diff --git a/compiler/driver/compiler_driver.cc b/compiler/driver/compiler_driver.cc
index 36beb59..e440eec 100644
--- a/compiler/driver/compiler_driver.cc
+++ b/compiler/driver/compiler_driver.cc
@@ -344,7 +344,7 @@
 
 static optimizer::DexToDexCompiler::CompilationLevel GetDexToDexCompilationLevel(
     Thread* self, const CompilerDriver& driver, Handle<mirror::ClassLoader> class_loader,
-    const DexFile& dex_file, const DexFile::ClassDef& class_def)
+    const DexFile& dex_file, const dex::ClassDef& class_def)
     REQUIRES_SHARED(Locks::mutator_lock_) {
   // When the dex file is uncompressed in the APK, we do not generate a copy in the .vdex
   // file. As a result, dex2oat will map the dex file read-only, and we only need to check
@@ -389,7 +389,7 @@
     const CompilerDriver& driver,
     jobject jclass_loader,
     const DexFile& dex_file,
-    const DexFile::ClassDef& class_def) {
+    const dex::ClassDef& class_def) {
   ScopedObjectAccess soa(self);
   StackHandleScope<1> hs(soa.Self());
   Handle<mirror::ClassLoader> class_loader(
@@ -416,7 +416,7 @@
 static void CompileMethodHarness(
     Thread* self,
     CompilerDriver* driver,
-    const DexFile::CodeItem* code_item,
+    const dex::CodeItem* code_item,
     uint32_t access_flags,
     InvokeType invoke_type,
     uint16_t class_def_idx,
@@ -465,7 +465,7 @@
 static void CompileMethodDex2Dex(
     Thread* self,
     CompilerDriver* driver,
-    const DexFile::CodeItem* code_item,
+    const dex::CodeItem* code_item,
     uint32_t access_flags,
     InvokeType invoke_type,
     uint16_t class_def_idx,
@@ -476,7 +476,7 @@
     Handle<mirror::DexCache> dex_cache) {
   auto dex_2_dex_fn = [](Thread* self ATTRIBUTE_UNUSED,
       CompilerDriver* driver,
-      const DexFile::CodeItem* code_item,
+      const dex::CodeItem* code_item,
       uint32_t access_flags,
       InvokeType invoke_type,
       uint16_t class_def_idx,
@@ -527,7 +527,7 @@
 static void CompileMethodQuick(
     Thread* self,
     CompilerDriver* driver,
-    const DexFile::CodeItem* code_item,
+    const dex::CodeItem* code_item,
     uint32_t access_flags,
     InvokeType invoke_type,
     uint16_t class_def_idx,
@@ -539,7 +539,7 @@
   auto quick_fn = [](
       Thread* self,
       CompilerDriver* driver,
-      const DexFile::CodeItem* code_item,
+      const dex::CodeItem* code_item,
       uint32_t access_flags,
       InvokeType invoke_type,
       uint16_t class_def_idx,
@@ -650,7 +650,7 @@
                                 uint32_t method_idx,
                                 uint32_t access_flags,
                                 InvokeType invoke_type,
-                                const DexFile::CodeItem* code_item,
+                                const dex::CodeItem* code_item,
                                 Handle<mirror::DexCache> dex_cache,
                                 Handle<mirror::ClassLoader> h_class_loader) {
   // Can we run DEX-to-DEX compiler on this class ?
@@ -1125,7 +1125,7 @@
                                           ScopedNullHandle<mirror::ClassLoader>())
               : nullptr;
       if (klass == nullptr) {
-        const DexFile::TypeId& type_id = dex_file->GetTypeId(exception_type_idx);
+        const dex::TypeId& type_id = dex_file->GetTypeId(exception_type_idx);
         const char* descriptor = dex_file->GetTypeDescriptor(type_id);
         LOG(FATAL) << "Failed to resolve class " << descriptor;
       }
@@ -1596,7 +1596,7 @@
     // needs it, here we try to resolve fields and methods used in class
     // definitions, since many of them many never be referenced by
     // generated code.
-    const DexFile::ClassDef& class_def = dex_file.GetClassDef(class_def_index);
+    const dex::ClassDef& class_def = dex_file.GetClassDef(class_def_index);
     ScopedObjectAccess soa(self);
     StackHandleScope<2> hs(soa.Self());
     Handle<mirror::ClassLoader> class_loader(
@@ -1898,7 +1898,7 @@
     ScopedTrace trace(__FUNCTION__);
     ScopedObjectAccess soa(Thread::Current());
     const DexFile& dex_file = *manager_->GetDexFile();
-    const DexFile::ClassDef& class_def = dex_file.GetClassDef(class_def_index);
+    const dex::ClassDef& class_def = dex_file.GetClassDef(class_def_index);
     const char* descriptor = dex_file.GetClassDescriptor(class_def);
     ClassLinker* class_linker = manager_->GetClassLinker();
     jobject jclass_loader = manager_->GetClassLoader();
@@ -2032,7 +2032,7 @@
     ScopedTrace trace(__FUNCTION__);
     ScopedObjectAccess soa(Thread::Current());
     const DexFile& dex_file = *manager_->GetDexFile();
-    const DexFile::ClassDef& class_def = dex_file.GetClassDef(class_def_index);
+    const dex::ClassDef& class_def = dex_file.GetClassDef(class_def_index);
     const char* descriptor = dex_file.GetClassDescriptor(class_def);
     ClassLinker* class_linker = manager_->GetClassLinker();
     jobject jclass_loader = manager_->GetClassLoader();
@@ -2097,8 +2097,8 @@
     ScopedTrace trace(__FUNCTION__);
     jobject jclass_loader = manager_->GetClassLoader();
     const DexFile& dex_file = *manager_->GetDexFile();
-    const DexFile::ClassDef& class_def = dex_file.GetClassDef(class_def_index);
-    const DexFile::TypeId& class_type_id = dex_file.GetTypeId(class_def.class_idx_);
+    const dex::ClassDef& class_def = dex_file.GetClassDef(class_def_index);
+    const dex::TypeId& class_type_id = dex_file.GetTypeId(class_def.class_idx_);
     const char* descriptor = dex_file.StringDataByIdx(class_type_id.descriptor_idx_);
 
     ScopedObjectAccess soa(Thread::Current());
@@ -2122,8 +2122,8 @@
   void TryInitializeClass(Handle<mirror::Class> klass, Handle<mirror::ClassLoader>& class_loader)
       REQUIRES_SHARED(Locks::mutator_lock_) {
     const DexFile& dex_file = klass->GetDexFile();
-    const DexFile::ClassDef* class_def = klass->GetClassDef();
-    const DexFile::TypeId& class_type_id = dex_file.GetTypeId(class_def->class_idx_);
+    const dex::ClassDef* class_def = klass->GetClassDef();
+    const dex::TypeId& class_type_id = dex_file.GetTypeId(class_def->class_idx_);
     const char* descriptor = dex_file.StringDataByIdx(class_type_id.descriptor_idx_);
     ScopedObjectAccessUnchecked soa(Thread::Current());
     StackHandleScope<3> hs(soa.Self());
@@ -2278,7 +2278,7 @@
 
     StackHandleScope<1> hs(Thread::Current());
     Handle<mirror::DexCache> dex_cache = hs.NewHandle(klass->GetDexCache());
-    const DexFile::ClassDef* class_def = klass->GetClassDef();
+    const dex::ClassDef* class_def = klass->GetClassDef();
     ClassLinker* class_linker = manager_->GetClassLinker();
 
     // Check encoded final field values for strings and intern.
@@ -2320,7 +2320,7 @@
       self->ClearException();
       return false;
     }
-    const DexFile::TypeList* types = m->GetParameterTypeList();
+    const dex::TypeList* types = m->GetParameterTypeList();
     if (types != nullptr) {
       for (uint32_t i = 0; i < types->Size(); ++i) {
         dex::TypeIndex param_type_idx = types->GetTypeItem(i).type_idx_;
@@ -2575,7 +2575,7 @@
     ClassLinker* class_linker = context.GetClassLinker();
     jobject jclass_loader = context.GetClassLoader();
     ClassReference ref(&dex_file, class_def_index);
-    const DexFile::ClassDef& class_def = dex_file.GetClassDef(class_def_index);
+    const dex::ClassDef& class_def = dex_file.GetClassDef(class_def_index);
     ClassAccessor accessor(dex_file, class_def_index);
     CompilerDriver* const driver = context.GetCompiler();
     // Skip compiling classes with generic verifier failures since they will still fail at runtime
diff --git a/compiler/driver/compiler_driver.h b/compiler/driver/compiler_driver.h
index 025a632..6f8ec12 100644
--- a/compiler/driver/compiler_driver.h
+++ b/compiler/driver/compiler_driver.h
@@ -36,7 +36,6 @@
 #include "class_status.h"
 #include "compiler.h"
 #include "dex/class_reference.h"
-#include "dex/dex_file.h"
 #include "dex/dex_file_types.h"
 #include "dex/dex_to_dex_compiler.h"
 #include "dex/method_reference.h"
@@ -47,6 +46,10 @@
 
 namespace art {
 
+namespace dex {
+struct CodeItem;
+}  // namespace dex
+
 namespace mirror {
 class Class;
 class DexCache;
@@ -62,6 +65,7 @@
 class CompiledMethod;
 class CompilerOptions;
 class DexCompilationUnit;
+class DexFile;
 template<class T> class Handle;
 struct InlineIGetIPutData;
 class InstructionSetFeatures;
@@ -127,7 +131,7 @@
                   uint32_t method_idx,
                   uint32_t access_flags,
                   InvokeType invoke_type,
-                  const DexFile::CodeItem* code_item,
+                  const dex::CodeItem* code_item,
                   Handle<mirror::DexCache> dex_cache,
                   Handle<mirror::ClassLoader> h_class_loader)
       REQUIRES(!Locks::mutator_lock_);
diff --git a/compiler/driver/compiler_driver_test.cc b/compiler/driver/compiler_driver_test.cc
index b924129..e73d072 100644
--- a/compiler/driver/compiler_driver_test.cc
+++ b/compiler/driver/compiler_driver_test.cc
@@ -80,7 +80,7 @@
   void MakeDexFileExecutable(jobject class_loader, const DexFile& dex_file) {
     ClassLinker* class_linker = Runtime::Current()->GetClassLinker();
     for (size_t i = 0; i < dex_file.NumClassDefs(); i++) {
-      const DexFile::ClassDef& class_def = dex_file.GetClassDef(i);
+      const dex::ClassDef& class_def = dex_file.GetClassDef(i);
       const char* descriptor = dex_file.GetClassDescriptor(class_def);
       ScopedObjectAccess soa(Thread::Current());
       StackHandleScope<1> hs(soa.Self());
diff --git a/compiler/driver/dex_compilation_unit.cc b/compiler/driver/dex_compilation_unit.cc
index e5a6f0e..0d0f074 100644
--- a/compiler/driver/dex_compilation_unit.cc
+++ b/compiler/driver/dex_compilation_unit.cc
@@ -30,7 +30,7 @@
 DexCompilationUnit::DexCompilationUnit(Handle<mirror::ClassLoader> class_loader,
                                        ClassLinker* class_linker,
                                        const DexFile& dex_file,
-                                       const DexFile::CodeItem* code_item,
+                                       const dex::CodeItem* code_item,
                                        uint16_t class_def_idx,
                                        uint32_t method_idx,
                                        uint32_t access_flags,
diff --git a/compiler/driver/dex_compilation_unit.h b/compiler/driver/dex_compilation_unit.h
index 757f0e7..f68d93f 100644
--- a/compiler/driver/dex_compilation_unit.h
+++ b/compiler/driver/dex_compilation_unit.h
@@ -39,7 +39,7 @@
   DexCompilationUnit(Handle<mirror::ClassLoader> class_loader,
                      ClassLinker* class_linker,
                      const DexFile& dex_file,
-                     const DexFile::CodeItem* code_item,
+                     const dex::CodeItem* code_item,
                      uint16_t class_def_idx,
                      uint32_t method_idx,
                      uint32_t access_flags,
@@ -67,17 +67,17 @@
     return dex_method_idx_;
   }
 
-  const DexFile::CodeItem* GetCodeItem() const {
+  const dex::CodeItem* GetCodeItem() const {
     return code_item_;
   }
 
   const char* GetShorty() const {
-    const DexFile::MethodId& method_id = dex_file_->GetMethodId(dex_method_idx_);
+    const dex::MethodId& method_id = dex_file_->GetMethodId(dex_method_idx_);
     return dex_file_->GetMethodShorty(method_id);
   }
 
   const char* GetShorty(uint32_t* shorty_len) const {
-    const DexFile::MethodId& method_id = dex_file_->GetMethodId(dex_method_idx_);
+    const dex::MethodId& method_id = dex_file_->GetMethodId(dex_method_idx_);
     return dex_file_->GetMethodShorty(method_id, shorty_len);
   }
 
@@ -165,7 +165,7 @@
 
   const DexFile* const dex_file_;
 
-  const DexFile::CodeItem* const code_item_;
+  const dex::CodeItem* const code_item_;
   const uint16_t class_def_idx_;
   const uint32_t dex_method_idx_;
   const uint32_t access_flags_;
diff --git a/compiler/exception_test.cc b/compiler/exception_test.cc
index f0f179c..d5ceafe 100644
--- a/compiler/exception_test.cc
+++ b/compiler/exception_test.cc
@@ -135,8 +135,8 @@
   ASSERT_EQ(2u, accessor.TriesSize());
   ASSERT_NE(0u, accessor.InsnsSizeInCodeUnits());
 
-  const DexFile::TryItem& t0 = accessor.TryItems().begin()[0];
-  const DexFile::TryItem& t1 = accessor.TryItems().begin()[1];
+  const dex::TryItem& t0 = accessor.TryItems().begin()[0];
+  const dex::TryItem& t1 = accessor.TryItems().begin()[1];
   EXPECT_LE(t0.start_addr_, t1.start_addr_);
   {
     CatchHandlerIterator iter(accessor, 4 /* Dex PC in the first try block */);
diff --git a/compiler/optimizing/block_builder.cc b/compiler/optimizing/block_builder.cc
index d1ccbee..3672cce 100644
--- a/compiler/optimizing/block_builder.cc
+++ b/compiler/optimizing/block_builder.cc
@@ -68,7 +68,7 @@
     // places where the program might fall through into/out of the a block and
     // where TryBoundary instructions will be inserted later. Other edges which
     // enter/exit the try blocks are a result of branches/switches.
-    for (const DexFile::TryItem& try_item : code_item_accessor_.TryItems()) {
+    for (const dex::TryItem& try_item : code_item_accessor_.TryItems()) {
       uint32_t dex_pc_start = try_item.start_addr_;
       uint32_t dex_pc_end = dex_pc_start + try_item.insn_count_;
       MaybeCreateBlockAt(dex_pc_start);
@@ -222,9 +222,9 @@
 }
 
 // Returns the TryItem stored for `block` or nullptr if there is no info for it.
-static const DexFile::TryItem* GetTryItem(
+static const dex::TryItem* GetTryItem(
     HBasicBlock* block,
-    const ScopedArenaSafeMap<uint32_t, const DexFile::TryItem*>& try_block_info) {
+    const ScopedArenaSafeMap<uint32_t, const dex::TryItem*>& try_block_info) {
   auto iterator = try_block_info.find(block->GetBlockId());
   return (iterator == try_block_info.end()) ? nullptr : iterator->second;
 }
@@ -235,7 +235,7 @@
 // for a handler.
 static void LinkToCatchBlocks(HTryBoundary* try_boundary,
                               const CodeItemDataAccessor& accessor,
-                              const DexFile::TryItem* try_item,
+                              const dex::TryItem* try_item,
                               const ScopedArenaSafeMap<uint32_t, HBasicBlock*>& catch_blocks) {
   for (CatchHandlerIterator it(accessor.GetCatchHandlerData(try_item->handler_off_));
       it.HasNext();
@@ -279,7 +279,7 @@
 
   // Keep a map of all try blocks and their respective TryItems. We do not use
   // the block's pointer but rather its id to ensure deterministic iteration.
-  ScopedArenaSafeMap<uint32_t, const DexFile::TryItem*> try_block_info(
+  ScopedArenaSafeMap<uint32_t, const dex::TryItem*> try_block_info(
       std::less<uint32_t>(), local_allocator_->Adapter(kArenaAllocGraphBuilder));
 
   // Obtain TryItem information for blocks with throwing instructions, and split
@@ -295,7 +295,7 @@
     // loop for synchronized blocks.
     if (ContainsElement(throwing_blocks_, block)) {
       // Try to find a TryItem covering the block.
-      const DexFile::TryItem* try_item = code_item_accessor_.FindTryItem(block->GetDexPc());
+      const dex::TryItem* try_item = code_item_accessor_.FindTryItem(block->GetDexPc());
       if (try_item != nullptr) {
         // Block throwing and in a TryItem. Store the try block information.
         try_block_info.Put(block->GetBlockId(), try_item);
@@ -348,7 +348,7 @@
   // that all predecessors are relinked to. This preserves loop headers (b/23895756).
   for (const auto& entry : try_block_info) {
     uint32_t block_id = entry.first;
-    const DexFile::TryItem* try_item = entry.second;
+    const dex::TryItem* try_item = entry.second;
     HBasicBlock* try_block = graph_->GetBlocks()[block_id];
     for (HBasicBlock* predecessor : try_block->GetPredecessors()) {
       if (GetTryItem(predecessor, try_block_info) != try_item) {
@@ -367,7 +367,7 @@
   // the successor is not in the same TryItem.
   for (const auto& entry : try_block_info) {
     uint32_t block_id = entry.first;
-    const DexFile::TryItem* try_item = entry.second;
+    const dex::TryItem* try_item = entry.second;
     HBasicBlock* try_block = graph_->GetBlocks()[block_id];
     // NOTE: Do not use iterators because SplitEdge would invalidate them.
     for (size_t i = 0, e = try_block->GetSuccessors().size(); i < e; ++i) {
diff --git a/compiler/optimizing/code_generator.cc b/compiler/optimizing/code_generator.cc
index 04e0cc4..9e2f5cd 100644
--- a/compiler/optimizing/code_generator.cc
+++ b/compiler/optimizing/code_generator.cc
@@ -987,7 +987,7 @@
 // dex branch instructions.
 static void CheckLoopEntriesCanBeUsedForOsr(const HGraph& graph,
                                             const CodeInfo& code_info,
-                                            const DexFile::CodeItem& code_item) {
+                                            const dex::CodeItem& code_item) {
   if (graph.HasTryCatch()) {
     // One can write loops through try/catch, which we do not support for OSR anyway.
     return;
@@ -1029,7 +1029,7 @@
   }
 }
 
-ScopedArenaVector<uint8_t> CodeGenerator::BuildStackMaps(const DexFile::CodeItem* code_item) {
+ScopedArenaVector<uint8_t> CodeGenerator::BuildStackMaps(const dex::CodeItem* code_item) {
   ScopedArenaVector<uint8_t> stack_map = GetStackMapStream()->Encode();
   if (kIsDebugBuild && code_item != nullptr) {
     CheckLoopEntriesCanBeUsedForOsr(*graph_, CodeInfo(stack_map.data()), *code_item);
diff --git a/compiler/optimizing/code_generator.h b/compiler/optimizing/code_generator.h
index 39966ff..f70ecb6 100644
--- a/compiler/optimizing/code_generator.h
+++ b/compiler/optimizing/code_generator.h
@@ -349,7 +349,7 @@
 
   void AddSlowPath(SlowPathCode* slow_path);
 
-  ScopedArenaVector<uint8_t> BuildStackMaps(const DexFile::CodeItem* code_item_for_osr_check);
+  ScopedArenaVector<uint8_t> BuildStackMaps(const dex::CodeItem* code_item_for_osr_check);
   size_t GetNumberOfJitRoots() const;
 
   // Fills the `literals` array with literals collected during code generation.
diff --git a/compiler/optimizing/graph_visualizer.cc b/compiler/optimizing/graph_visualizer.cc
index 0796620..2a7bbcb 100644
--- a/compiler/optimizing/graph_visualizer.cc
+++ b/compiler/optimizing/graph_visualizer.cc
@@ -393,7 +393,7 @@
   void VisitLoadMethodType(HLoadMethodType* load_method_type) override {
     StartAttributeStream("load_kind") << "RuntimeCall";
     const DexFile& dex_file = load_method_type->GetDexFile();
-    const DexFile::ProtoId& proto_id = dex_file.GetProtoId(load_method_type->GetProtoIndex());
+    const dex::ProtoId& proto_id = dex_file.GetProtoId(load_method_type->GetProtoIndex());
     StartAttributeStream("method_type") << dex_file.GetProtoSignature(proto_id);
   }
 
diff --git a/compiler/optimizing/inliner.cc b/compiler/optimizing/inliner.cc
index 854228b..8440e9a 100644
--- a/compiler/optimizing/inliner.cc
+++ b/compiler/optimizing/inliner.cc
@@ -1756,7 +1756,7 @@
                                        HInstruction** return_replacement) {
   DCHECK(!(resolved_method->IsStatic() && receiver_type.IsValid()));
   ScopedObjectAccess soa(Thread::Current());
-  const DexFile::CodeItem* code_item = resolved_method->GetCodeItem();
+  const dex::CodeItem* code_item = resolved_method->GetCodeItem();
   const DexFile& callee_dex_file = *resolved_method->GetDexFile();
   uint32_t method_index = resolved_method->GetDexMethodIndex();
   CodeItemDebugInfoAccessor code_item_accessor(resolved_method->DexInstructionDebugInfo());
@@ -2027,7 +2027,7 @@
 }
 
 void HInliner::RunOptimizations(HGraph* callee_graph,
-                                const DexFile::CodeItem* code_item,
+                                const dex::CodeItem* code_item,
                                 const DexCompilationUnit& dex_compilation_unit) {
   // Note: if the outermost_graph_ is being compiled OSR, we should not run any
   // optimization that could lead to a HDeoptimize. The following optimizations do not.
@@ -2112,7 +2112,7 @@
   // Iterate over the list of parameter types and test whether any of the
   // actual inputs has a more specific reference type than the type declared in
   // the signature.
-  const DexFile::TypeList* param_list = resolved_method->GetParameterTypeList();
+  const dex::TypeList* param_list = resolved_method->GetParameterTypeList();
   for (size_t param_idx = 0,
               input_idx = resolved_method->IsStatic() ? 0 : 1,
               e = (param_list == nullptr ? 0 : param_list->Size());
diff --git a/compiler/optimizing/inliner.h b/compiler/optimizing/inliner.h
index 8ac2163..efd4c74 100644
--- a/compiler/optimizing/inliner.h
+++ b/compiler/optimizing/inliner.h
@@ -99,7 +99,7 @@
 
   // Run simple optimizations on `callee_graph`.
   void RunOptimizations(HGraph* callee_graph,
-                        const DexFile::CodeItem* code_item,
+                        const dex::CodeItem* code_item,
                         const DexCompilationUnit& dex_compilation_unit)
     REQUIRES_SHARED(Locks::mutator_lock_);
 
diff --git a/compiler/optimizing/instruction_builder.cc b/compiler/optimizing/instruction_builder.cc
index b6ef2b6..5e7b575 100644
--- a/compiler/optimizing/instruction_builder.cc
+++ b/compiler/optimizing/instruction_builder.cc
@@ -559,7 +559,7 @@
   uint16_t locals_index = graph_->GetNumberOfLocalVRegs();
   uint16_t parameter_index = 0;
 
-  const DexFile::MethodId& referrer_method_id =
+  const dex::MethodId& referrer_method_id =
       dex_file_->GetMethodId(dex_compilation_unit_->GetDexMethodIndex());
   if (!dex_compilation_unit_->IsStatic()) {
     // Add the implicit 'this' argument, not expressed in the signature.
@@ -576,8 +576,8 @@
     DCHECK(current_this_parameter_ == nullptr);
   }
 
-  const DexFile::ProtoId& proto = dex_file_->GetMethodPrototype(referrer_method_id);
-  const DexFile::TypeList* arg_types = dex_file_->GetProtoParameters(proto);
+  const dex::ProtoId& proto = dex_file_->GetMethodPrototype(referrer_method_id);
+  const dex::TypeList* arg_types = dex_file_->GetProtoParameters(proto);
   for (int i = 0, shorty_pos = 1; i < number_of_parameters; i++) {
     HParameterValue* parameter = new (allocator_) HParameterValue(
         *dex_file_,
@@ -1515,7 +1515,7 @@
 }
 
 static DataType::Type GetFieldAccessType(const DexFile& dex_file, uint16_t field_index) {
-  const DexFile::FieldId& field_id = dex_file.GetFieldId(field_index);
+  const dex::FieldId& field_id = dex_file.GetFieldId(field_index);
   const char* type = dex_file.GetFieldTypeDescriptor(field_id);
   return DataType::FromShorty(type[0]);
 }
@@ -3143,7 +3143,7 @@
 
 ObjPtr<mirror::Class> HInstructionBuilder::LookupReferrerClass() const {
   // TODO: Cache the result in a Handle<mirror::Class>.
-  const DexFile::MethodId& method_id =
+  const dex::MethodId& method_id =
       dex_compilation_unit_->GetDexFile()->GetMethodId(dex_compilation_unit_->GetDexMethodIndex());
   return LookupResolvedType(method_id.class_idx_, *dex_compilation_unit_);
 }
diff --git a/compiler/optimizing/nodes.cc b/compiler/optimizing/nodes.cc
index e9a2f96..f7c16d1 100644
--- a/compiler/optimizing/nodes.cc
+++ b/compiler/optimizing/nodes.cc
@@ -689,7 +689,7 @@
 }
 
 const char* HGraph::GetMethodName() const {
-  const DexFile::MethodId& method_id = dex_file_.GetMethodId(method_idx_);
+  const dex::MethodId& method_id = dex_file_.GetMethodId(method_idx_);
   return dex_file_.GetMethodName(method_id);
 }
 
diff --git a/compiler/optimizing/optimizing_compiler.cc b/compiler/optimizing/optimizing_compiler.cc
index a8fa370..3b34e8d 100644
--- a/compiler/optimizing/optimizing_compiler.cc
+++ b/compiler/optimizing/optimizing_compiler.cc
@@ -272,7 +272,7 @@
 
   bool CanCompileMethod(uint32_t method_idx, const DexFile& dex_file) const override;
 
-  CompiledMethod* Compile(const DexFile::CodeItem* code_item,
+  CompiledMethod* Compile(const dex::CodeItem* code_item,
                           uint32_t access_flags,
                           InvokeType invoke_type,
                           uint16_t class_def_idx,
@@ -370,7 +370,7 @@
   CompiledMethod* Emit(ArenaAllocator* allocator,
                        CodeVectorAllocator* code_allocator,
                        CodeGenerator* codegen,
-                       const DexFile::CodeItem* item) const;
+                       const dex::CodeItem* item) const;
 
   // Try compiling a method and return the code generator used for
   // compiling it.
@@ -760,7 +760,7 @@
 CompiledMethod* OptimizingCompiler::Emit(ArenaAllocator* allocator,
                                          CodeVectorAllocator* code_allocator,
                                          CodeGenerator* codegen,
-                                         const DexFile::CodeItem* code_item_for_osr_check) const {
+                                         const dex::CodeItem* code_item_for_osr_check) const {
   ArenaVector<linker::LinkerPatch> linker_patches = EmitAndSortLinkerPatches(codegen);
   ScopedArenaVector<uint8_t> stack_map = codegen->BuildStackMaps(code_item_for_osr_check);
 
@@ -799,7 +799,7 @@
   InstructionSet instruction_set = compiler_options.GetInstructionSet();
   const DexFile& dex_file = *dex_compilation_unit.GetDexFile();
   uint32_t method_idx = dex_compilation_unit.GetDexMethodIndex();
-  const DexFile::CodeItem* code_item = dex_compilation_unit.GetCodeItem();
+  const dex::CodeItem* code_item = dex_compilation_unit.GetCodeItem();
 
   // Always use the Thumb-2 assembler: some runtime functionality
   // (like implicit stack overflow checks) assume Thumb-2.
@@ -1033,7 +1033,7 @@
   return codegen.release();
 }
 
-CompiledMethod* OptimizingCompiler::Compile(const DexFile::CodeItem* code_item,
+CompiledMethod* OptimizingCompiler::Compile(const dex::CodeItem* code_item,
                                             uint32_t access_flags,
                                             InvokeType invoke_type,
                                             uint16_t class_def_idx,
@@ -1254,7 +1254,7 @@
 
   const DexFile* dex_file = method->GetDexFile();
   const uint16_t class_def_idx = method->GetClassDefIndex();
-  const DexFile::CodeItem* code_item = dex_file->GetCodeItem(method->GetCodeItemOffset());
+  const dex::CodeItem* code_item = dex_file->GetCodeItem(method->GetCodeItemOffset());
   const uint32_t method_idx = method->GetDexMethodIndex();
   const uint32_t access_flags = method->GetAccessFlags();
 
diff --git a/compiler/optimizing/optimizing_unit_test.h b/compiler/optimizing/optimizing_unit_test.h
index 4e376b1..e5f6941 100644
--- a/compiler/optimizing/optimizing_unit_test.h
+++ b/compiler/optimizing/optimizing_unit_test.h
@@ -155,7 +155,7 @@
     void* aligned_data = GetAllocator()->Alloc(code_item_size);
     memcpy(aligned_data, &data[0], code_item_size);
     CHECK_ALIGNED(aligned_data, StandardDexFile::CodeItem::kAlignment);
-    const DexFile::CodeItem* code_item = reinterpret_cast<const DexFile::CodeItem*>(aligned_data);
+    const dex::CodeItem* code_item = reinterpret_cast<const dex::CodeItem*>(aligned_data);
 
     {
       ScopedObjectAccess soa(Thread::Current());
diff --git a/compiler/verifier_deps_test.cc b/compiler/verifier_deps_test.cc
index c00f848..092e931 100644
--- a/compiler/verifier_deps_test.cc
+++ b/compiler/verifier_deps_test.cc
@@ -147,7 +147,7 @@
         hs.NewHandle(soa.Decode<mirror::ClassLoader>(class_loader_)));
     Handle<mirror::DexCache> dex_cache_handle(hs.NewHandle(klass_Main_->GetDexCache()));
 
-    const DexFile::ClassDef* class_def = klass_Main_->GetClassDef();
+    const dex::ClassDef* class_def = klass_Main_->GetClassDef();
     ClassAccessor accessor(*primary_dex_file_, *class_def);
 
     bool has_failures = true;
@@ -228,7 +228,7 @@
     for (const DexFile* dex_file : dex_files_) {
       const std::set<dex::TypeIndex>& unverified_classes = deps.GetUnverifiedClasses(*dex_file);
       for (uint32_t i = 0; i < dex_file->NumClassDefs(); ++i) {
-        const DexFile::ClassDef& class_def = dex_file->GetClassDef(i);
+        const dex::ClassDef& class_def = dex_file->GetClassDef(i);
         const char* descriptor = dex_file->GetClassDescriptor(class_def);
         cls.Assign(class_linker_->FindClass(soa.Self(), descriptor, class_loader_handle));
         if (cls == nullptr) {
@@ -250,7 +250,7 @@
   }
 
   bool HasUnverifiedClass(const std::string& cls, const DexFile& dex_file) {
-    const DexFile::TypeId* type_id = dex_file.FindTypeId(cls.c_str());
+    const dex::TypeId* type_id = dex_file.FindTypeId(cls.c_str());
     DCHECK(type_id != nullptr);
     dex::TypeIndex index = dex_file.GetIndexForTypeId(*type_id);
     for (const auto& dex_dep : verifier_deps_->dex_deps_) {
@@ -329,7 +329,7 @@
           continue;
         }
 
-        const DexFile::FieldId& field_id = dex_dep.first->GetFieldId(entry.GetDexFieldIndex());
+        const dex::FieldId& field_id = dex_dep.first->GetFieldId(entry.GetDexFieldIndex());
 
         std::string actual_klass = dex_dep.first->StringByTypeIdx(field_id.class_idx_);
         if (expected_klass != actual_klass) {
@@ -381,7 +381,7 @@
           continue;
         }
 
-        const DexFile::MethodId& method_id = dex_dep.first->GetMethodId(entry.GetDexMethodIndex());
+        const dex::MethodId& method_id = dex_dep.first->GetMethodId(entry.GetDexMethodIndex());
 
         std::string actual_klass = dex_dep.first->StringByTypeIdx(method_id.class_idx_);
         if (expected_klass != actual_klass) {