Add ELF index to art::CompiledMethod.

(cherry picked from commit fd9514dbab8eaca357b6d712bb7e1b635617f92e)

Change-Id: I79bff6bf9d05ce6ffc25c3cef41d1acefc4d8d2a
diff --git a/src/compiled_method.h b/src/compiled_method.h
index 6dc5128..d2c28a7 100644
--- a/src/compiled_method.h
+++ b/src/compiled_method.h
@@ -30,11 +30,6 @@
 
 class CompiledMethod {
  public:
-#if defined(ART_USE_LLVM_COMPILER)
-  // Constructs a CompiledMethod for the LLVM compiler.
-  CompiledMethod(InstructionSet instruction_set, llvm::Function* func);
-#endif
-
   // Constructs a CompiledMethod for the non-LLVM compilers.
   CompiledMethod(InstructionSet instruction_set,
                  const std::vector<uint8_t>& code,
@@ -54,6 +49,9 @@
                  const uint32_t core_spill_mask,
                  const uint32_t fp_spill_mask);
 
+  // Constructs a CompiledMethod for the LLVM compiler.
+  CompiledMethod(InstructionSet instruction_set, size_t elf_idx);
+
   ~CompiledMethod();
 
   InstructionSet GetInstructionSet() const;
@@ -81,11 +79,17 @@
   static const void* CodePointer(const void* code_pointer,
                                  InstructionSet instruction_set);
 
+  size_t GetElfIndex() const {
+    return elf_idx_;
+  }
+
+  bool IsExecutableInElf() const {
+    return (elf_idx_ != static_cast<size_t>(-1));
+  }
+
  private:
+  // For non-LLVM
   const InstructionSet instruction_set_;
-#if defined(ART_USE_LLVM_COMPILER)
-  llvm::Function* func_;
-#endif
   std::vector<uint8_t> code_;
   const size_t frame_size_in_bytes_;
   const uint32_t core_spill_mask_;
@@ -93,23 +97,31 @@
   std::vector<uint32_t> mapping_table_;
   std::vector<uint16_t> vmap_table_;
   std::vector<uint8_t> gc_map_;
+  // For LLVM
+  size_t elf_idx_;
 };
 
 class CompiledInvokeStub {
  public:
-#if defined(ART_USE_LLVM_COMPILER)
-  explicit CompiledInvokeStub(llvm::Function* func);
-#endif
   explicit CompiledInvokeStub(std::vector<uint8_t>& code);
-  ~CompiledInvokeStub();
-  const std::vector<uint8_t>& GetCode() const;
- private:
 #if defined(ART_USE_LLVM_COMPILER)
-  llvm::Function* func_;
+  explicit CompiledInvokeStub(size_t elf_idx);
 #endif
-  // TODO: Change the line above from #endif to #else, after oat_writer is
-  // changed.
+  ~CompiledInvokeStub();
+
+  const std::vector<uint8_t>& GetCode() const;
+
+  size_t GetElfIndex() const {
+    return elf_idx_;
+  }
+
+  bool IsExecutableInElf() const {
+    return (elf_idx_ != static_cast<size_t>(-1));
+  }
+
+ private:
   std::vector<uint8_t> code_;
+  size_t elf_idx_;
 };
 
 }  // namespace art