Move arena_bit_vector.h/cc to compiler/utils.

Also move MIR's BasicBlock related code from arena_bit_vector.h to
bit_vector_block_iterator.cc.

Change-Id: I85c224b387d31cf57a1ef1f1a36eaadf22f1c85d
diff --git a/compiler/dex/arena_bit_vector.cc b/compiler/dex/arena_bit_vector.cc
deleted file mode 100644
index 1b37b71..0000000
--- a/compiler/dex/arena_bit_vector.cc
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "compiler_internals.h"
-#include "dex_file-inl.h"
-
-namespace art {
-
-class ArenaBitVectorAllocator : public Allocator {
- public:
-  explicit ArenaBitVectorAllocator(ArenaAllocator* arena) : arena_(arena) {}
-  ~ArenaBitVectorAllocator() {}
-
-  virtual void* Alloc(size_t size) {
-    return arena_->Alloc(size, ArenaAllocator::kAllocGrowableBitMap);
-  }
-
-  virtual void Free(void*) {}  // Nop.
-
-  static void* operator new(size_t size, ArenaAllocator* arena) {
-    return arena->Alloc(sizeof(ArenaBitVectorAllocator), ArenaAllocator::kAllocGrowableBitMap);
-  }
-  static void operator delete(void* p) {}  // Nop.
-
- private:
-  ArenaAllocator* arena_;
-  DISALLOW_COPY_AND_ASSIGN(ArenaBitVectorAllocator);
-};
-
-ArenaBitVector::ArenaBitVector(ArenaAllocator* arena, unsigned int start_bits,
-                               bool expandable, OatBitMapKind kind)
-  :  BitVector(start_bits, expandable, new (arena) ArenaBitVectorAllocator(arena)), kind_(kind) {}
-
-BasicBlock* ArenaBitVector::BasicBlockIterator::Next() {
-    int idx = internal_iterator_.Next();
-
-    if (idx == -1) {
-      return nullptr;
-    }
-
-    return mir_graph_->GetBasicBlock(idx);
-}
-
-}  // namespace art
diff --git a/compiler/dex/arena_bit_vector.h b/compiler/dex/arena_bit_vector.h
deleted file mode 100644
index cdd5c68..0000000
--- a/compiler/dex/arena_bit_vector.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright (C) 2013 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ART_COMPILER_DEX_ARENA_BIT_VECTOR_H_
-#define ART_COMPILER_DEX_ARENA_BIT_VECTOR_H_
-
-#include "base/bit_vector.h"
-#include "compiler_enums.h"
-#include "utils/arena_allocator.h"
-#include "compiler_ir.h"
-
-namespace art {
-
-// Forward declaration
-class MIRGraph;
-
-/*
- * A BitVector implementation that uses Arena allocation.
- */
-class ArenaBitVector : public BitVector {
-  public:
-    /**
-     * @class BasicBlockIterator
-     * @brief Helper class to get the BasicBlocks when iterating through the ArenaBitVector.
-     */
-    class BasicBlockIterator {
-      public:
-        explicit BasicBlockIterator(ArenaBitVector* bv, MIRGraph* mir_graph)
-          : mir_graph_(mir_graph),
-            internal_iterator_(bv) {}
-
-        explicit BasicBlockIterator(ArenaBitVector* bv, CompilationUnit* c_unit)
-          : mir_graph_(c_unit->mir_graph.get()),
-            internal_iterator_(bv) {}
-
-        BasicBlock* Next();
-
-        static void* operator new(size_t size, ArenaAllocator* arena) {
-          return arena->Alloc(sizeof(ArenaBitVector::BasicBlockIterator),
-                              ArenaAllocator::kAllocGrowableArray);
-        };
-        static void operator delete(void* p) {}  // Nop.
-
-      private:
-        MIRGraph* const mir_graph_;
-        Iterator internal_iterator_;
-    };
-
-    ArenaBitVector(ArenaAllocator* arena, uint32_t start_bits, bool expandable,
-                   OatBitMapKind kind = kBitMapMisc);
-    ~ArenaBitVector() {}
-
-  static void* operator new(size_t size, ArenaAllocator* arena) {
-     return arena->Alloc(sizeof(ArenaBitVector), ArenaAllocator::kAllocGrowableBitMap);
-  }
-  static void operator delete(void* p) {}  // Nop.
-
-  private:
-    const OatBitMapKind kind_;      // for memory use tuning. TODO: currently unused.
-};
-
-
-}  // namespace art
-
-#endif  // ART_COMPILER_DEX_ARENA_BIT_VECTOR_H_
diff --git a/compiler/dex/bit_vector_block_iterator.cc b/compiler/dex/bit_vector_block_iterator.cc
new file mode 100644
index 0000000..32d7d71
--- /dev/null
+++ b/compiler/dex/bit_vector_block_iterator.cc
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "bit_vector_block_iterator.h"
+#include "mir_graph.h"
+
+namespace art {
+
+BasicBlock* BitVectorBlockIterator::Next() {
+  int idx = internal_iterator_.Next();
+
+  if (idx == -1) {
+    return nullptr;
+  }
+
+  return mir_graph_->GetBasicBlock(idx);
+}
+
+}  // namespace art
diff --git a/compiler/dex/bit_vector_block_iterator.h b/compiler/dex/bit_vector_block_iterator.h
new file mode 100644
index 0000000..0821e9e
--- /dev/null
+++ b/compiler/dex/bit_vector_block_iterator.h
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ART_COMPILER_DEX_BIT_VECTOR_BLOCK_ITERATOR_H_
+#define ART_COMPILER_DEX_BIT_VECTOR_BLOCK_ITERATOR_H_
+
+#include "base/bit_vector.h"
+#include "compiler_enums.h"
+#include "utils/arena_bit_vector.h"
+#include "utils/arena_allocator.h"
+#include "compiler_ir.h"
+
+namespace art {
+
+class MIRGraph;
+
+/**
+ * @class BasicBlockIterator
+ * @brief Helper class to get the BasicBlocks when iterating through the ArenaBitVector.
+ */
+class BitVectorBlockIterator {
+  public:
+    explicit BitVectorBlockIterator(BitVector* bv, MIRGraph* mir_graph)
+      : mir_graph_(mir_graph),
+        internal_iterator_(bv) {}
+
+    explicit BitVectorBlockIterator(BitVector* bv, CompilationUnit* c_unit)
+      : mir_graph_(c_unit->mir_graph.get()),
+        internal_iterator_(bv) {}
+
+    BasicBlock* Next();
+
+    void* operator new(size_t size, ArenaAllocator* arena) {
+      return arena->Alloc(size, ArenaAllocator::kAllocGrowableArray);
+    };
+    void operator delete(void* p) {}  // Nop.
+
+  private:
+    MIRGraph* const mir_graph_;
+    BitVector::Iterator internal_iterator_;
+};
+
+}  // namespace art
+
+#endif  // ART_COMPILER_DEX_BIT_VECTOR_BLOCK_ITERATOR_H_
diff --git a/compiler/dex/compiler_enums.h b/compiler/dex/compiler_enums.h
index 2bc36a5..0cd9ba3 100644
--- a/compiler/dex/compiler_enums.h
+++ b/compiler/dex/compiler_enums.h
@@ -402,29 +402,6 @@
 
 std::ostream& operator<<(std::ostream& os, const SelectInstructionKind& kind);
 
-// Type of growable bitmap for memory tuning.
-enum OatBitMapKind {
-  kBitMapMisc = 0,
-  kBitMapUse,
-  kBitMapDef,
-  kBitMapLiveIn,
-  kBitMapBMatrix,
-  kBitMapDominators,
-  kBitMapIDominated,
-  kBitMapDomFrontier,
-  kBitMapPhi,
-  kBitMapTmpBlocks,
-  kBitMapInputBlocks,
-  kBitMapRegisterV,
-  kBitMapTempSSARegisterV,
-  kBitMapNullCheck,
-  kBitMapTmpBlockV,
-  kBitMapPredecessors,
-  kNumBitMapKinds
-};
-
-std::ostream& operator<<(std::ostream& os, const OatBitMapKind& kind);
-
 // LIR fixup kinds for Arm
 enum FixupKind {
   kFixupNone,
diff --git a/compiler/dex/mir_graph.h b/compiler/dex/mir_graph.h
index 2174f67..d344055 100644
--- a/compiler/dex/mir_graph.h
+++ b/compiler/dex/mir_graph.h
@@ -20,7 +20,7 @@
 #include "dex_file.h"
 #include "dex_instruction.h"
 #include "compiler_ir.h"
-#include "arena_bit_vector.h"
+#include "utils/arena_bit_vector.h"
 #include "utils/growable_array.h"
 
 namespace art {
diff --git a/compiler/dex/ssa_transformation.cc b/compiler/dex/ssa_transformation.cc
index 0f79f41..4e258ef 100644
--- a/compiler/dex/ssa_transformation.cc
+++ b/compiler/dex/ssa_transformation.cc
@@ -14,6 +14,7 @@
  * limitations under the License.
  */
 
+#include "bit_vector_block_iterator.h"
 #include "compiler_internals.h"
 #include "dataflow_iterator-inl.h"
 
@@ -248,9 +249,9 @@
   }
 
   /* Calculate DF_up */
-  ArenaBitVector::BasicBlockIterator it(bb->i_dominated, cu_);
+  BitVectorBlockIterator it(bb->i_dominated, cu_);
   for (BasicBlock *dominated_bb = it.Next(); dominated_bb != nullptr; dominated_bb = it.Next()) {
-    ArenaBitVector::BasicBlockIterator inner_it(dominated_bb->dom_frontier, cu_);
+    BitVectorBlockIterator inner_it(dominated_bb->dom_frontier, cu_);
     for (BasicBlock *df_up_block = inner_it.Next(); df_up_block != nullptr;
          df_up_block = inner_it.Next()) {
       CheckForDominanceFrontier(bb, df_up_block);