Remove CodeItem accessor functions

These are replaced by the accessor helpers.

Bug: 63756964
Test: test-art-host
Test: test/testrunner/testrunner.py --host -j30

Change-Id: Ic93d60b68b684eeb5f69be286b4e15b8f8f97542
diff --git a/compiler/dex/dex_to_dex_compiler.cc b/compiler/dex/dex_to_dex_compiler.cc
index ead909a..7e41c53 100644
--- a/compiler/dex/dex_to_dex_compiler.cc
+++ b/compiler/dex/dex_to_dex_compiler.cc
@@ -114,7 +114,8 @@
 
 void DexCompiler::Compile() {
   DCHECK_EQ(dex_to_dex_compilation_level_, DexToDexCompilationLevel::kOptimize);
-  IterationRange<DexInstructionIterator> instructions = unit_.GetCodeItem()->Instructions();
+  IterationRange<DexInstructionIterator> instructions(unit_.GetCodeItemAccessor().begin(),
+                                                      unit_.GetCodeItemAccessor().end());
   for (DexInstructionIterator it = instructions.begin(); it != instructions.end(); ++it) {
     const uint32_t dex_pc = it.DexPc();
     Instruction* inst = const_cast<Instruction*>(&it.Inst());
@@ -364,7 +365,7 @@
     if (kIsDebugBuild) {
       // Double check that the counts line up with the size of the quicken info.
       size_t quicken_count = 0;
-      for (const DexInstructionPcPair& pair : code_item->Instructions()) {
+      for (const DexInstructionPcPair& pair : unit.GetCodeItemAccessor()) {
         if (QuickenInfoTable::NeedsIndexForInstruction(&pair.Inst())) {
           ++quicken_count;
         }
@@ -376,7 +377,7 @@
       // Dex pc is not serialized, only used for checking the instructions. Since we access the
       // array based on the index of the quickened instruction, the indexes must line up perfectly.
       // The reader side uses the NeedsIndexForInstruction function too.
-      const Instruction& inst = code_item->InstructionAt(info.dex_pc);
+      const Instruction& inst = unit.GetCodeItemAccessor().InstructionAt(info.dex_pc);
       CHECK(QuickenInfoTable::NeedsIndexForInstruction(&inst)) << inst.Opcode();
       // Add the index.
       quicken_data.push_back(static_cast<uint8_t>(info.dex_member_index >> 0));
diff --git a/compiler/dex/dex_to_dex_decompiler_test.cc b/compiler/dex/dex_to_dex_decompiler_test.cc
index 979c4c4..89a63c0 100644
--- a/compiler/dex/dex_to_dex_decompiler_test.cc
+++ b/compiler/dex/dex_to_dex_decompiler_test.cc
@@ -99,8 +99,10 @@
         if (compiled_method != nullptr) {
           table = compiled_method->GetVmapTable();
         }
-        optimizer::ArtDecompileDEX(
-            *it.GetMethodCodeItem(), table, /* decompile_return_instruction */ true);
+        optimizer::ArtDecompileDEX(updated_dex_file,
+                                   *it.GetMethodCodeItem(),
+                                   table,
+                                   /* decompile_return_instruction */ true);
         it.Next();
       }
       DCHECK(!it.HasNext());
diff --git a/compiler/driver/compiler_driver.cc b/compiler/driver/compiler_driver.cc
index 68f963e..5d4ed46 100644
--- a/compiler/driver/compiler_driver.cc
+++ b/compiler/driver/compiler_driver.cc
@@ -702,6 +702,7 @@
 //       stable order.
 
 static void ResolveConstStrings(Handle<mirror::DexCache> dex_cache,
+                                const DexFile* dex_file,
                                 const DexFile::CodeItem* code_item)
       REQUIRES_SHARED(Locks::mutator_lock_) {
   if (code_item == nullptr) {
@@ -710,7 +711,7 @@
   }
 
   ClassLinker* const class_linker = Runtime::Current()->GetClassLinker();
-  for (const DexInstructionPcPair& inst : code_item->Instructions()) {
+  for (const DexInstructionPcPair& inst : CodeItemInstructionAccessor(dex_file, code_item)) {
     switch (inst->Opcode()) {
       case Instruction::CONST_STRING:
       case Instruction::CONST_STRING_JUMBO: {
@@ -772,7 +773,7 @@
           continue;
         }
         previous_method_idx = method_idx;
-        ResolveConstStrings(dex_cache, it.GetMethodCodeItem());
+        ResolveConstStrings(dex_cache, dex_file, it.GetMethodCodeItem());
         it.Next();
       }
       DCHECK(!it.HasNext());
@@ -2352,9 +2353,7 @@
     // Intern strings seen in <clinit>.
     ArtMethod* clinit = klass->FindClassInitializer(class_linker->GetImagePointerSize());
     if (clinit != nullptr) {
-      const DexFile::CodeItem* code_item = clinit->GetCodeItem();
-      DCHECK(code_item != nullptr);
-      for (const DexInstructionPcPair& inst : code_item->Instructions()) {
+      for (const DexInstructionPcPair& inst : clinit->DexInstructions()) {
         if (inst->Opcode() == Instruction::CONST_STRING) {
           ObjPtr<mirror::String> s = class_linker->ResolveString(
               dex::StringIndex(inst->VRegB_21c()), dex_cache);
diff --git a/compiler/driver/dex_compilation_unit.cc b/compiler/driver/dex_compilation_unit.cc
index 7e8e812..76e1299 100644
--- a/compiler/driver/dex_compilation_unit.cc
+++ b/compiler/driver/dex_compilation_unit.cc
@@ -16,6 +16,7 @@
 
 #include "dex_compilation_unit.h"
 
+#include "code_item_accessors-inl.h"
 #include "mirror/dex_cache.h"
 #include "utils.h"
 
@@ -38,7 +39,8 @@
       dex_method_idx_(method_idx),
       access_flags_(access_flags),
       verified_method_(verified_method),
-      dex_cache_(dex_cache) {
+      dex_cache_(dex_cache),
+      code_item_accessor_(&dex_file, code_item) {
 }
 
 const std::string& DexCompilationUnit::GetSymbol() {
diff --git a/compiler/driver/dex_compilation_unit.h b/compiler/driver/dex_compilation_unit.h
index 24a9a5b..cdc505f 100644
--- a/compiler/driver/dex_compilation_unit.h
+++ b/compiler/driver/dex_compilation_unit.h
@@ -20,6 +20,7 @@
 #include <stdint.h>
 
 #include "base/arena_object.h"
+#include "code_item_accessors.h"
 #include "dex_file.h"
 #include "handle.h"
 #include "jni.h"
@@ -112,6 +113,10 @@
     return dex_cache_;
   }
 
+  const CodeItemDataAccessor& GetCodeItemAccessor() const {
+    return code_item_accessor_;
+  }
+
  private:
   const Handle<mirror::ClassLoader> class_loader_;
 
@@ -127,6 +132,8 @@
 
   const Handle<mirror::DexCache> dex_cache_;
 
+  const CodeItemDataAccessor code_item_accessor_;
+
   std::string symbol_;
 };
 
diff --git a/compiler/optimizing/code_generator.cc b/compiler/optimizing/code_generator.cc
index dee74e9..729b08e 100644
--- a/compiler/optimizing/code_generator.cc
+++ b/compiler/optimizing/code_generator.cc
@@ -45,6 +45,7 @@
 #include "base/casts.h"
 #include "bytecode_utils.h"
 #include "class_linker.h"
+#include "code_item_accessors-inl.h"
 #include "compiled_method.h"
 #include "dex/verified_method.h"
 #include "driver/compiler_driver.h"
@@ -910,7 +911,8 @@
   }
   ArenaVector<size_t> covered(
       loop_headers.size(), 0, graph.GetAllocator()->Adapter(kArenaAllocMisc));
-  for (const DexInstructionPcPair& pair : code_item.Instructions()) {
+  for (const DexInstructionPcPair& pair : CodeItemInstructionAccessor(&graph.GetDexFile(),
+                                                                      &code_item)) {
     const uint32_t dex_pc = pair.DexPc();
     const Instruction& instruction = pair.Inst();
     if (instruction.IsBranch()) {