Avoid register pool allocations on the heap.
Create a helper template class ArrayRef and use it instead
of std::vector<> for register pools in target_<arch>.cc to
avoid these heap allocations during program startup.
Change-Id: I4ab0205af9c1d28a239c0a105fcdc60ba800a70a
diff --git a/compiler/dex/quick/mir_to_lir.h b/compiler/dex/quick/mir_to_lir.h
index 1281d45..ed94a8d 100644
--- a/compiler/dex/quick/mir_to_lir.h
+++ b/compiler/dex/quick/mir_to_lir.h
@@ -26,6 +26,7 @@
#include "driver/compiler_driver.h"
#include "leb128.h"
#include "safe_map.h"
+#include "utils/array_ref.h"
#include "utils/arena_allocator.h"
#include "utils/growable_array.h"
@@ -429,16 +430,16 @@
class RegisterPool {
public:
RegisterPool(Mir2Lir* m2l, ArenaAllocator* arena,
- const std::vector<RegStorage>& core_regs,
- const std::vector<RegStorage>& core64_regs,
- const std::vector<RegStorage>& sp_regs,
- const std::vector<RegStorage>& dp_regs,
- const std::vector<RegStorage>& reserved_regs,
- const std::vector<RegStorage>& reserved64_regs,
- const std::vector<RegStorage>& core_temps,
- const std::vector<RegStorage>& core64_temps,
- const std::vector<RegStorage>& sp_temps,
- const std::vector<RegStorage>& dp_temps);
+ const ArrayRef<const RegStorage>& core_regs,
+ const ArrayRef<const RegStorage>& core64_regs,
+ const ArrayRef<const RegStorage>& sp_regs,
+ const ArrayRef<const RegStorage>& dp_regs,
+ const ArrayRef<const RegStorage>& reserved_regs,
+ const ArrayRef<const RegStorage>& reserved64_regs,
+ const ArrayRef<const RegStorage>& core_temps,
+ const ArrayRef<const RegStorage>& core64_temps,
+ const ArrayRef<const RegStorage>& sp_temps,
+ const ArrayRef<const RegStorage>& dp_temps);
~RegisterPool() {}
static void* operator new(size_t size, ArenaAllocator* arena) {
return arena->Alloc(size, kArenaAllocRegAlloc);