Use ScopedArenaAllocator for register allocation.

Memory needed to compile the two most expensive methods for
aosp_angler-userdebug boot image:
  BatteryStats.dumpCheckinLocked() : 25.1MiB -> 21.1MiB
  BatteryStats.dumpLocked(): 49.6MiB -> 42.0MiB
This is because all the memory previously used by Scheduler
is reused by the register allocator; the register allocator
has a higher peak usage of the ArenaStack.

And continue the "arena"->"allocator" renaming.

Test: m test-art-host-gtest
Test: testrunner.py --host
Bug: 64312607
Change-Id: Idfd79a9901552b5147ec0bf591cb38120de86b01
diff --git a/runtime/base/arena_allocator_test.cc b/runtime/base/arena_allocator_test.cc
index e2c2e2f..6bf56c8 100644
--- a/runtime/base/arena_allocator_test.cc
+++ b/runtime/base/arena_allocator_test.cc
@@ -23,9 +23,9 @@
 
 class ArenaAllocatorTest : public testing::Test {
  protected:
-  size_t NumberOfArenas(ArenaAllocator* arena) {
+  size_t NumberOfArenas(ArenaAllocator* allocator) {
     size_t result = 0u;
-    for (Arena* a = arena->arena_head_; a != nullptr; a = a->next_) {
+    for (Arena* a = allocator->arena_head_; a != nullptr; a = a->next_) {
       ++result;
     }
     return result;
diff --git a/runtime/base/arena_containers.h b/runtime/base/arena_containers.h
index 62b974e..2e71156 100644
--- a/runtime/base/arena_containers.h
+++ b/runtime/base/arena_containers.h
@@ -137,22 +137,22 @@
     typedef ArenaAllocatorAdapter<U> other;
   };
 
-  explicit ArenaAllocatorAdapter(ArenaAllocator* arena_allocator,
+  explicit ArenaAllocatorAdapter(ArenaAllocator* allocator,
                                  ArenaAllocKind kind = kArenaAllocSTL)
       : ArenaAllocatorAdapterKind(kind),
-        arena_allocator_(arena_allocator) {
+        allocator_(allocator) {
   }
   template <typename U>
   ArenaAllocatorAdapter(const ArenaAllocatorAdapter<U>& other)  // NOLINT, implicit
       : ArenaAllocatorAdapterKind(other),
-        arena_allocator_(other.arena_allocator_) {
+        allocator_(other.allocator_) {
   }
   ArenaAllocatorAdapter(const ArenaAllocatorAdapter&) = default;
   ArenaAllocatorAdapter& operator=(const ArenaAllocatorAdapter&) = default;
   ~ArenaAllocatorAdapter() = default;
 
  private:
-  ArenaAllocator* arena_allocator_;
+  ArenaAllocator* allocator_;
 
   template <typename U>
   friend class ArenaAllocatorAdapter;
@@ -174,14 +174,14 @@
     typedef ArenaAllocatorAdapter<U> other;
   };
 
-  ArenaAllocatorAdapter(ArenaAllocator* arena_allocator, ArenaAllocKind kind)
+  ArenaAllocatorAdapter(ArenaAllocator* allocator, ArenaAllocKind kind)
       : ArenaAllocatorAdapterKind(kind),
-        arena_allocator_(arena_allocator) {
+        allocator_(allocator) {
   }
   template <typename U>
   ArenaAllocatorAdapter(const ArenaAllocatorAdapter<U>& other)  // NOLINT, implicit
       : ArenaAllocatorAdapterKind(other),
-        arena_allocator_(other.arena_allocator_) {
+        allocator_(other.allocator_) {
   }
   ArenaAllocatorAdapter(const ArenaAllocatorAdapter&) = default;
   ArenaAllocatorAdapter& operator=(const ArenaAllocatorAdapter&) = default;
@@ -197,10 +197,10 @@
   pointer allocate(size_type n,
                    ArenaAllocatorAdapter<void>::pointer hint ATTRIBUTE_UNUSED = nullptr) {
     DCHECK_LE(n, max_size());
-    return arena_allocator_->AllocArray<T>(n, ArenaAllocatorAdapterKind::Kind());
+    return allocator_->AllocArray<T>(n, ArenaAllocatorAdapterKind::Kind());
   }
   void deallocate(pointer p, size_type n) {
-    arena_allocator_->MakeInaccessible(p, sizeof(T) * n);
+    allocator_->MakeInaccessible(p, sizeof(T) * n);
   }
 
   template <typename U, typename... Args>
@@ -213,7 +213,7 @@
   }
 
  private:
-  ArenaAllocator* arena_allocator_;
+  ArenaAllocator* allocator_;
 
   template <typename U>
   friend class ArenaAllocatorAdapter;
@@ -226,7 +226,7 @@
 template <typename T>
 inline bool operator==(const ArenaAllocatorAdapter<T>& lhs,
                        const ArenaAllocatorAdapter<T>& rhs) {
-  return lhs.arena_allocator_ == rhs.arena_allocator_;
+  return lhs.allocator_ == rhs.allocator_;
 }
 
 template <typename T>
diff --git a/runtime/base/arena_object.h b/runtime/base/arena_object.h
index 2d8e7d8..ed00bab 100644
--- a/runtime/base/arena_object.h
+++ b/runtime/base/arena_object.h
@@ -32,8 +32,8 @@
     return allocator->Alloc(size, kAllocKind);
   }
 
-  static void* operator new(size_t size, ScopedArenaAllocator* arena) {
-    return arena->Alloc(size, kAllocKind);
+  static void* operator new(size_t size, ScopedArenaAllocator* allocator) {
+    return allocator->Alloc(size, kAllocKind);
   }
 
   void operator delete(void*, size_t) {
@@ -56,8 +56,8 @@
     return allocator->Alloc(size, kAllocKind);
   }
 
-  static void* operator new(size_t size, ScopedArenaAllocator* arena) {
-    return arena->Alloc(size, kAllocKind);
+  static void* operator new(size_t size, ScopedArenaAllocator* allocator) {
+    return allocator->Alloc(size, kAllocKind);
   }
 
   void operator delete(void*, size_t) {
diff --git a/runtime/base/scoped_arena_allocator.h b/runtime/base/scoped_arena_allocator.h
index 1a0eb5e..f156f52 100644
--- a/runtime/base/scoped_arena_allocator.h
+++ b/runtime/base/scoped_arena_allocator.h
@@ -145,6 +145,10 @@
   explicit ScopedArenaAllocator(ArenaStack* arena_stack);
   ~ScopedArenaAllocator();
 
+  ArenaStack* GetArenaStack() const {
+    return arena_stack_;
+  }
+
   void Reset();
 
   void* Alloc(size_t bytes, ArenaAllocKind kind = kArenaAllocMisc) ALWAYS_INLINE {
diff --git a/runtime/base/scoped_arena_containers.h b/runtime/base/scoped_arena_containers.h
index 632ba43..fccaaea 100644
--- a/runtime/base/scoped_arena_containers.h
+++ b/runtime/base/scoped_arena_containers.h
@@ -52,6 +52,12 @@
 using ScopedArenaVector = dchecked_vector<T, ScopedArenaAllocatorAdapter<T>>;
 
 template <typename T, typename Comparator = std::less<T>>
+using ScopedArenaPriorityQueue = std::priority_queue<T, ScopedArenaVector<T>, Comparator>;
+
+template <typename T>
+using ScopedArenaStdStack = std::stack<T, ScopedArenaDeque<T>>;
+
+template <typename T, typename Comparator = std::less<T>>
 using ScopedArenaSet = std::set<T, Comparator, ScopedArenaAllocatorAdapter<T>>;
 
 template <typename K, typename V, typename Comparator = std::less<K>>
@@ -96,12 +102,12 @@
     typedef ScopedArenaAllocatorAdapter<U> other;
   };
 
-  explicit ScopedArenaAllocatorAdapter(ScopedArenaAllocator* arena_allocator,
+  explicit ScopedArenaAllocatorAdapter(ScopedArenaAllocator* allocator,
                                        ArenaAllocKind kind = kArenaAllocSTL)
-      : DebugStackReference(arena_allocator),
-        DebugStackIndirectTopRef(arena_allocator),
+      : DebugStackReference(allocator),
+        DebugStackIndirectTopRef(allocator),
         ArenaAllocatorAdapterKind(kind),
-        arena_stack_(arena_allocator->arena_stack_) {
+        arena_stack_(allocator->arena_stack_) {
   }
   template <typename U>
   ScopedArenaAllocatorAdapter(const ScopedArenaAllocatorAdapter<U>& other)  // NOLINT, implicit
@@ -139,12 +145,12 @@
     typedef ScopedArenaAllocatorAdapter<U> other;
   };
 
-  explicit ScopedArenaAllocatorAdapter(ScopedArenaAllocator* arena_allocator,
+  explicit ScopedArenaAllocatorAdapter(ScopedArenaAllocator* allocator,
                                        ArenaAllocKind kind = kArenaAllocSTL)
-      : DebugStackReference(arena_allocator),
-        DebugStackIndirectTopRef(arena_allocator),
+      : DebugStackReference(allocator),
+        DebugStackIndirectTopRef(allocator),
         ArenaAllocatorAdapterKind(kind),
-        arena_stack_(arena_allocator->arena_stack_) {
+        arena_stack_(allocator->arena_stack_) {
   }
   template <typename U>
   ScopedArenaAllocatorAdapter(const ScopedArenaAllocatorAdapter<U>& other)  // NOLINT, implicit