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/runtime/dex_file.h b/runtime/dex_file.h
index da9fa50..bd236f6 100644
--- a/runtime/dex_file.h
+++ b/runtime/dex_file.h
@@ -1010,6 +1010,11 @@
return oat_dex_file_;
}
+ // Used by oat writer.
+ void SetOatDexFile(OatDexFile* oat_dex_file) const {
+ oat_dex_file_ = oat_dex_file;
+ }
+
// Utility methods for reading integral values from a buffer.
static int32_t ReadSignedInt(const uint8_t* ptr, int zwidth);
static uint32_t ReadUnsignedInt(const uint8_t* ptr, int zwidth, bool fill_on_right);
@@ -1138,9 +1143,10 @@
// If this dex file was loaded from an oat file, oat_dex_file_ contains a
// pointer to the OatDexFile it was loaded from. Otherwise oat_dex_file_ is
// null.
- const OatDexFile* oat_dex_file_;
+ mutable const OatDexFile* oat_dex_file_;
friend class DexFileVerifierTest;
+ friend class OatWriter;
ART_FRIEND_TEST(ClassLinkerTest, RegisterDexFileName); // for constructor
};