Use type lookup tables in compiler

This recently regressed and stopped happening, the fix creates fake
OatDexFiles so that the compiler uses the type lookup tables instead
of slow FindClassDef and FindTypeId.

Perf on host compile Facebook:
Before:
2.49%: art::DexFile::FindClassDef(unsigned short) const
1.59%: art::DexFile::FindTypeId(char const*) const

After:
0.42%: art::OatDexFile::FindClassDef(art::DexFile const&, char const*, unsigned long)
0%: art::DexFile::FindTypeId(char const*) const
0%: art::DexFile::FindClassDef(unsigned short) const

Average install (N6P 960 mhz average of 40 samples): 38.2s -> 35.64s

Bug: 32641252

Test: test-art-host, adb install.

Change-Id: I34df21dc2c155bc2579c5cafdd91f9cb0fead1a9
diff --git a/compiler/oat_writer.cc b/compiler/oat_writer.cc
index f9173f5..bde00cf 100644
--- a/compiler/oat_writer.cc
+++ b/compiler/oat_writer.cc
@@ -260,16 +260,7 @@
   // Data to write to a separate section.
   dchecked_vector<uint32_t> class_offsets_;
 
-  void InitTypeLookupTable(const DexFile& dex_file, uint8_t* storage) const {
-    lookup_table_.reset(TypeLookupTable::Create(dex_file, storage));
-  }
-
-  TypeLookupTable* GetTypeLookupTable() const {
-    return lookup_table_.get();
-  }
-
  private:
-  mutable std::unique_ptr<TypeLookupTable> lookup_table_;
   size_t GetClassOffsetsRawSize() const {
     return class_offsets_.size() * sizeof(class_offsets_[0]);
   }
@@ -2481,8 +2472,15 @@
 
     // Create the lookup table. When `nullptr` is given as the storage buffer,
     // TypeLookupTable allocates its own and OatDexFile takes ownership.
-    oat_dex_file->InitTypeLookupTable(*opened_dex_files[i], /* storage */ nullptr);
-    TypeLookupTable* table = oat_dex_file->GetTypeLookupTable();
+    const DexFile& dex_file = *opened_dex_files[i];
+    {
+      std::unique_ptr<TypeLookupTable> type_lookup_table =
+          TypeLookupTable::Create(dex_file, /* storage */ nullptr);
+      type_lookup_table_oat_dex_files_.push_back(
+          std::make_unique<art::OatDexFile>(std::move(type_lookup_table)));
+      dex_file.SetOatDexFile(type_lookup_table_oat_dex_files_.back().get());
+    }
+    TypeLookupTable* const table = type_lookup_table_oat_dex_files_.back()->GetTypeLookupTable();
 
     // Type tables are required to be 4 byte aligned.
     size_t initial_offset = oat_size_;