Optimizing: Tag more arena allocations.

Replace GrowableArray with ArenaVector and tag arena
allocations with new allocation types.

As part of this, make the register allocator a bit more
efficient, doing bulk insert/erase. Some loops are now
O(n) instead of O(n^2).

Change-Id: Ifac0871ffb34b121cc0447801a2d07eefd308c14
diff --git a/compiler/optimizing/reference_type_propagation.cc b/compiler/optimizing/reference_type_propagation.cc
index a88c543..fe837e4 100644
--- a/compiler/optimizing/reference_type_propagation.cc
+++ b/compiler/optimizing/reference_type_propagation.cc
@@ -27,7 +27,7 @@
  public:
   RTPVisitor(HGraph* graph,
              StackHandleScopeCollection* handles,
-             GrowableArray<HInstruction*>* worklist,
+             ArenaVector<HInstruction*>* worklist,
              ReferenceTypeInfo::TypeHandle object_class_handle,
              ReferenceTypeInfo::TypeHandle class_class_handle,
              ReferenceTypeInfo::TypeHandle string_class_handle,
@@ -68,7 +68,7 @@
   ReferenceTypeInfo::TypeHandle class_class_handle_;
   ReferenceTypeInfo::TypeHandle string_class_handle_;
   ReferenceTypeInfo::TypeHandle throwable_class_handle_;
-  GrowableArray<HInstruction*>* worklist_;
+  ArenaVector<HInstruction*>* worklist_;
 
   static constexpr size_t kDefaultWorklistSize = 8;
 };
@@ -78,7 +78,8 @@
                                                    const char* name)
     : HOptimization(graph, name),
       handles_(handles),
-      worklist_(graph->GetArena(), kDefaultWorklistSize) {
+      worklist_(graph->GetArena()->Adapter(kArenaAllocReferenceTypePropagation)) {
+  worklist_.reserve(kDefaultWorklistSize);
   // Mutator lock is required for NewHandle, but annotalysis ignores constructors.
   ScopedObjectAccess soa(Thread::Current());
   ClassLinker* linker = Runtime::Current()->GetClassLinker();
@@ -649,7 +650,7 @@
   ScopedObjectAccess soa(Thread::Current());
   UpdateArrayGet(instr, handles_, object_class_handle_);
   if (!instr->GetReferenceTypeInfo().IsValid()) {
-    worklist_->Add(instr);
+    worklist_->push_back(instr);
   }
 }
 
@@ -718,8 +719,9 @@
 }
 
 void ReferenceTypePropagation::ProcessWorklist() {
-  while (!worklist_.IsEmpty()) {
-    HInstruction* instruction = worklist_.Pop();
+  while (!worklist_.empty()) {
+    HInstruction* instruction = worklist_.back();
+    worklist_.pop_back();
     if (UpdateNullability(instruction) || UpdateReferenceTypeInfo(instruction)) {
       AddDependentInstructionsToWorklist(instruction);
     }
@@ -729,7 +731,7 @@
 void ReferenceTypePropagation::AddToWorklist(HInstruction* instruction) {
   DCHECK_EQ(instruction->GetType(), Primitive::kPrimNot)
       << instruction->DebugName() << ":" << instruction->GetType();
-  worklist_.Add(instruction);
+  worklist_.push_back(instruction);
 }
 
 void ReferenceTypePropagation::AddDependentInstructionsToWorklist(HInstruction* instruction) {