ART: Use ScopedArenaAllocator for pass-local data.

Passes using local ArenaAllocator were hiding their memory
usage from the allocation counting, making it difficult to
track down where memory was used. Using ScopedArenaAllocator
reveals the memory usage.

This changes the HGraph constructor which requires a lot of
changes in tests. Refactor these tests to limit the amount
of work needed the next time we change that constructor.

Test: m test-art-host-gtest
Test: testrunner.py --host
Test: Build with kArenaAllocatorCountAllocations = true.
Bug: 64312607
Change-Id: I34939e4086b500d6e827ff3ef2211d1a421ac91a
diff --git a/compiler/optimizing/scheduler.cc b/compiler/optimizing/scheduler.cc
index 5212e86..9acf6d2 100644
--- a/compiler/optimizing/scheduler.cc
+++ b/compiler/optimizing/scheduler.cc
@@ -18,6 +18,8 @@
 
 #include "scheduler.h"
 
+#include "base/scoped_arena_allocator.h"
+#include "base/scoped_arena_containers.h"
 #include "data_type-inl.h"
 #include "prepare_for_register_allocation.h"
 
@@ -442,7 +444,7 @@
 }
 
 void SchedulingGraph::DumpAsDotGraph(const std::string& description,
-                                     const ArenaVector<SchedulingNode*>& initial_candidates) {
+                                     const ScopedArenaVector<SchedulingNode*>& initial_candidates) {
   // TODO(xueliang): ideally we should move scheduling information into HInstruction, after that
   // we should move this dotty graph dump feature to visualizer, and have a compiler option for it.
   std::ofstream output("scheduling_graphs.dot", std::ofstream::out | std::ofstream::app);
@@ -451,7 +453,7 @@
   // Start the dot graph. Use an increasing index for easier differentiation.
   output << "digraph G {\n";
   for (const auto& entry : nodes_map_) {
-    SchedulingNode* node = entry.second;
+    SchedulingNode* node = entry.second.get();
     DumpAsDotNode(output, node);
   }
   // Create a fake 'end_of_scheduling' node to help visualization of critical_paths.
@@ -466,7 +468,7 @@
 }
 
 SchedulingNode* CriticalPathSchedulingNodeSelector::SelectMaterializedCondition(
-    ArenaVector<SchedulingNode*>* nodes, const SchedulingGraph& graph) const {
+    ScopedArenaVector<SchedulingNode*>* nodes, const SchedulingGraph& graph) const {
   // Schedule condition inputs that can be materialized immediately before their use.
   // In following example, after we've scheduled HSelect, we want LessThan to be scheduled
   // immediately, because it is a materialized condition, and will be emitted right before HSelect
@@ -506,7 +508,7 @@
 }
 
 SchedulingNode* CriticalPathSchedulingNodeSelector::PopHighestPriorityNode(
-    ArenaVector<SchedulingNode*>* nodes, const SchedulingGraph& graph) {
+    ScopedArenaVector<SchedulingNode*>* nodes, const SchedulingGraph& graph) {
   DCHECK(!nodes->empty());
   SchedulingNode* select_node = nullptr;
 
@@ -562,7 +564,7 @@
 }
 
 void HScheduler::Schedule(HBasicBlock* block) {
-  ArenaVector<SchedulingNode*> scheduling_nodes(arena_->Adapter(kArenaAllocScheduler));
+  ScopedArenaVector<SchedulingNode*> scheduling_nodes(arena_->Adapter(kArenaAllocScheduler));
 
   // Build the scheduling graph.
   scheduling_graph_.Clear();
@@ -593,7 +595,7 @@
     }
   }
 
-  ArenaVector<SchedulingNode*> initial_candidates(arena_->Adapter(kArenaAllocScheduler));
+  ScopedArenaVector<SchedulingNode*> initial_candidates(arena_->Adapter(kArenaAllocScheduler));
   if (kDumpDotSchedulingGraphs) {
     // Remember the list of initial candidates for debug output purposes.
     initial_candidates.assign(candidates_.begin(), candidates_.end());
@@ -779,7 +781,7 @@
 #if defined(ART_ENABLE_CODEGEN_arm64) || defined(ART_ENABLE_CODEGEN_arm)
   // Phase-local allocator that allocates scheduler internal data structures like
   // scheduling nodes, internel nodes map, dependencies, etc.
-  ArenaAllocator arena_allocator(graph_->GetArena()->GetArenaPool());
+  ScopedArenaAllocator arena_allocator(graph_->GetArenaStack());
   CriticalPathSchedulingNodeSelector critical_path_selector;
   RandomSchedulingNodeSelector random_selector;
   SchedulingNodeSelector* selector = schedule_randomly