Refactor MethodDebugInfo (input of DWARF writer).

Do not pass CompiledMethod pointer through since it is only available
during AOT compile but not during JIT compile or at runtime. Creating
mock CompiledMethod just pass data is proving increasingly tricky, so
copy the fields that we need to MethodDebugInfo instead.

Change-Id: I820297b41e769fcac488c0ff2d2ea0492bb13ed8
diff --git a/compiler/debug/elf_debug_line_writer.h b/compiler/debug/elf_debug_line_writer.h
index 11be4e9..ed26d96 100644
--- a/compiler/debug/elf_debug_line_writer.h
+++ b/compiler/debug/elf_debug_line_writer.h
@@ -53,7 +53,7 @@
   // Returns the number of bytes written.
   size_t WriteCompilationUnit(ElfCompilationUnit& compilation_unit) {
     const bool is64bit = Is64BitInstructionSet(builder_->GetIsa());
-    const Elf_Addr text_address = builder_->GetText()->Exists()
+    const Elf_Addr base_address = compilation_unit.is_code_address_text_relative
         ? builder_->GetText()->GetAddress()
         : 0;
 
@@ -90,37 +90,31 @@
       }
 
       uint32_t prologue_end = std::numeric_limits<uint32_t>::max();
-      ArrayRef<const SrcMapElem> pc2dex_map;
-      std::vector<SrcMapElem> pc2dex_map_from_stack_maps;
-      if (mi->IsFromOptimizingCompiler()) {
+      std::vector<SrcMapElem> pc2dex_map;
+      if (mi->code_info != nullptr) {
         // Use stack maps to create mapping table from pc to dex.
-        const CodeInfo code_info(mi->compiled_method->GetVmapTable().data());
+        const CodeInfo code_info(mi->code_info);
         const StackMapEncoding encoding = code_info.ExtractEncoding();
+        pc2dex_map.reserve(code_info.GetNumberOfStackMaps());
         for (uint32_t s = 0; s < code_info.GetNumberOfStackMaps(); s++) {
           StackMap stack_map = code_info.GetStackMapAt(s, encoding);
           DCHECK(stack_map.IsValid());
           const uint32_t pc = stack_map.GetNativePcOffset(encoding);
           const int32_t dex = stack_map.GetDexPc(encoding);
-          pc2dex_map_from_stack_maps.push_back({pc, dex});
+          pc2dex_map.push_back({pc, dex});
           if (stack_map.HasDexRegisterMap(encoding)) {
             // Guess that the first map with local variables is the end of prologue.
             prologue_end = std::min(prologue_end, pc);
           }
         }
-        std::sort(pc2dex_map_from_stack_maps.begin(),
-                  pc2dex_map_from_stack_maps.end());
-        pc2dex_map = ArrayRef<const SrcMapElem>(pc2dex_map_from_stack_maps);
-      } else {
-        // Use the mapping table provided by the quick compiler.
-        pc2dex_map = mi->compiled_method->GetSrcMappingTable();
-        prologue_end = 0;
+        std::sort(pc2dex_map.begin(), pc2dex_map.end());
       }
 
       if (pc2dex_map.empty()) {
         continue;
       }
 
-      Elf_Addr method_address = text_address + mi->low_pc;
+      Elf_Addr method_address = base_address + mi->code_address;
 
       PositionInfos dex2line_map;
       const DexFile* dex = mi->dex_file;
@@ -226,7 +220,7 @@
         opcodes.AddRow(method_address, 0);
       }
 
-      opcodes.AdvancePC(text_address + mi->high_pc);
+      opcodes.AdvancePC(method_address + mi->code_size);
       opcodes.EndSequence();
     }
     std::vector<uint8_t> buffer;