Add layout scheme to dexlayout for dex file reordering.
Currently takes startup classes from profile and groups them together
with the lowest class indexes. Moves the ClassDef, ClassData, and
CodeItem sections.
Results gathered from 5 second systrace of app startup (no other input):
Maps
base.vdex - 24.70MB -> 19.35MB (30.50MB file size)
base.odex - 13.22MB -> 12.82MB (13.22MB file size)
Running time of dex2oat: 27.5s -> 37.1s
Photos
base.vdex - 12.98MB -> 9.77MB (15.10MB file size)
base.odex - 6.84MB -> 6.24MB ( 6.84MB file size)
Running time of dex2oat: 15.6s -> 19.9s
Plus
base.vdex - 14.09MB -> 13.29MB (16.72MB file size)
base.odex - 2.47MB -> 2.47MB ( 2.47MB file size)
Running time of dex2oat: 14.1s -> 18.5s
Performance and memory tracking bug: b/33017139
Test: mm test-art-host-gtest-dexlayout_test
Bug: 29921113
Change-Id: Ib500ed353d71a606e2db0dd80378750c5f7b8e33
diff --git a/dexlayout/dexlayout.h b/dexlayout/dexlayout.h
index 179e90e..ac1a4a6 100644
--- a/dexlayout/dexlayout.h
+++ b/dexlayout/dexlayout.h
@@ -103,12 +103,15 @@
void DumpMethod(uint32_t idx, uint32_t flags, const dex_ir::CodeItem* code, int i);
void DumpPositionInfo(const dex_ir::CodeItem* code);
void DumpSField(uint32_t idx, uint32_t flags, int i, dex_ir::EncodedValue* init);
-
void DumpDexFile();
+
std::vector<dex_ir::ClassDef*> LayoutClassDefsAndClassData(const DexFile* dex_file);
int32_t LayoutCodeItems(std::vector<dex_ir::ClassDef*> new_class_def_order);
template<class T> void FixupSection(std::map<uint32_t, std::unique_ptr<T>>& map, uint32_t diff);
void FixupSections(uint32_t offset, uint32_t diff);
+
+ // Creates a new layout for the dex file based on profile info.
+ // Currently reorders ClassDefs, ClassDataItems, and CodeItems.
void LayoutOutputFile(const DexFile* dex_file);
void OutputDexFile(const std::string& dex_file_location);