summaryrefslogtreecommitdiffstats
path: root/compiler/utils
diff options
context:
space:
mode:
authorNicolas Geoffray <ngeoffray@google.com>2014-02-27 11:00:35 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2014-02-27 11:00:36 +0000
commitb565506a63e75dac4a8bb9dd54dabf5259e5b95f (patch)
tree7ab5da3f29563c31898614a76132efd7d30959f6 /compiler/utils
parent3d86fbe5413142342554c2414b5b271163ad98fe (diff)
parent0e33643519b68a343a7466dcaba12b8567777cc3 (diff)
downloadart-b565506a63e75dac4a8bb9dd54dabf5259e5b95f.zip
art-b565506a63e75dac4a8bb9dd54dabf5259e5b95f.tar.gz
art-b565506a63e75dac4a8bb9dd54dabf5259e5b95f.tar.bz2
Merge "Move arena_bit_vector.h/cc to compiler/utils."
Diffstat (limited to 'compiler/utils')
-rw-r--r--compiler/utils/arena_allocator_test.cc2
-rw-r--r--compiler/utils/arena_bit_vector.cc47
-rw-r--r--compiler/utils/arena_bit_vector.h69
3 files changed, 117 insertions, 1 deletions
diff --git a/compiler/utils/arena_allocator_test.cc b/compiler/utils/arena_allocator_test.cc
index b76fe74..7156540 100644
--- a/compiler/utils/arena_allocator_test.cc
+++ b/compiler/utils/arena_allocator_test.cc
@@ -14,9 +14,9 @@
* limitations under the License.
*/
-#include "dex/arena_bit_vector.h"
#include "gtest/gtest.h"
#include "utils/arena_allocator.h"
+#include "utils/arena_bit_vector.h"
namespace art {
diff --git a/compiler/utils/arena_bit_vector.cc b/compiler/utils/arena_bit_vector.cc
new file mode 100644
index 0000000..6f03524
--- /dev/null
+++ b/compiler/utils/arena_bit_vector.cc
@@ -0,0 +1,47 @@
+/*
+ * 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 "arena_allocator.h"
+#include "arena_bit_vector.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) {}
+
+} // namespace art
diff --git a/compiler/utils/arena_bit_vector.h b/compiler/utils/arena_bit_vector.h
new file mode 100644
index 0000000..6c14617
--- /dev/null
+++ b/compiler/utils/arena_bit_vector.h
@@ -0,0 +1,69 @@
+/*
+ * 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_UTILS_ARENA_BIT_VECTOR_H_
+#define ART_COMPILER_UTILS_ARENA_BIT_VECTOR_H_
+
+#include "base/bit_vector.h"
+#include "utils/arena_allocator.h"
+
+namespace art {
+
+// 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);
+
+/*
+ * A BitVector implementation that uses Arena allocation.
+ */
+class ArenaBitVector : public BitVector {
+ public:
+ 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_UTILS_ARENA_BIT_VECTOR_H_