Use factory pattern for dex_ir objects
In preparation for memory improvements, make dex_ir API more friendly to
pre-allocated or in-place type allocation.
Bug: 33017139
Test: make -j 50 test-art-host
Change-Id: I09b67e279a04535b175433287ce98ecbdc37f7a3
diff --git a/dexlayout/dex_ir_builder.cc b/dexlayout/dex_ir_builder.cc
index 4f9bcdd..9468f76 100644
--- a/dexlayout/dex_ir_builder.cc
+++ b/dexlayout/dex_ir_builder.cc
@@ -43,7 +43,13 @@
disk_header.link_off_,
disk_header.data_size_,
disk_header.data_off_,
- dex_file.SupportsDefaultMethods());
+ dex_file.SupportsDefaultMethods(),
+ dex_file.NumStringIds(),
+ dex_file.NumTypeIds(),
+ dex_file.NumProtoIds(),
+ dex_file.NumFieldIds(),
+ dex_file.NumMethodIds(),
+ dex_file.NumClassDefs());
Collections& collections = header->GetCollections();
collections.SetEagerlyAssignOffsets(eagerly_assign_offsets);
// Walk the rest of the header fields.
@@ -94,6 +100,7 @@
// Sort the vectors by the map order (same order as the file).
collections.SortVectorsByMapOrder();
+ collections.ClearMaps();
// Load the link data if it exists.
collections.SetLinkData(std::vector<uint8_t>(