Preallocate a HashMap buffer in LSE.
Add more HashSet<> constuctors with the allocator argument.
Inherit HashSet<> constructors in HashMap<>.
Use a pre-allocated buffer with size 16 to avoid allocating
a large one (kMinBuckets = 1000) on first use. With the
default max load factor 0.7, this pre-allocated buffer is
sufficient for all methods with up to 11 stores.
Test: m test-art-host-gtest
Test: testrunner.py --host --optimizing
Bug: 181943478
Change-Id: I7862b98ec9ec3ddb34693fd956fea75138d35e02
diff --git a/compiler/optimizing/load_store_elimination.cc b/compiler/optimizing/load_store_elimination.cc
index 17ce694..7495601 100644
--- a/compiler/optimizing/load_store_elimination.cc
+++ b/compiler/optimizing/load_store_elimination.cc
@@ -1249,6 +1249,8 @@
ValueRecord old_value_record;
HInstruction* stored_value;
};
+ // Small pre-allocated initial buffer avoids initializing a large one until it's really needed.
+ static constexpr size_t kStoreRecordsInitialBufferSize = 16;
ScopedArenaHashMap<HInstruction*, StoreRecord> store_records_;
// Replacements for Phi placeholders.
@@ -1439,7 +1441,10 @@
/*expandable=*/false,
kArenaAllocLSE),
loads_requiring_loop_phi_(allocator_.Adapter(kArenaAllocLSE)),
- store_records_(allocator_.Adapter(kArenaAllocLSE)),
+ store_records_(allocator_.AllocArray<std::pair<HInstruction*, StoreRecord>>(
+ kStoreRecordsInitialBufferSize, kArenaAllocLSE),
+ kStoreRecordsInitialBufferSize,
+ allocator_.Adapter(kArenaAllocLSE)),
phi_placeholder_replacements_(num_phi_placeholders_,
Value::Invalid(),
allocator_.Adapter(kArenaAllocLSE)),