blob: ddc0c818c289e2452216d58734c7a7eb8df22f16 [file] [log] [blame]
buzbee862a7602013-04-05 10:58:54 -07001/*
2 * Copyright (C) 2011 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
Nicolas Geoffray0e336432014-02-26 18:24:38 +000017#include "arena_bit_vector.h"
buzbee862a7602013-04-05 10:58:54 -070018
Mathieu Chartierb666f482015-02-18 14:33:14 -080019#include "base/arena_allocator.h"
20
buzbee862a7602013-04-05 10:58:54 -070021namespace art {
22
Vladimir Markobfea9c22014-01-17 17:49:33 +000023template <typename ArenaAlloc>
Ian Rogers6a3c1fc2014-10-31 00:33:20 -070024class ArenaBitVectorAllocator FINAL : public Allocator,
25 public ArenaObject<kArenaAllocGrowableBitMap> {
Brian Carlstrom413e89f2013-10-21 23:53:49 -070026 public:
Vladimir Markobfea9c22014-01-17 17:49:33 +000027 explicit ArenaBitVectorAllocator(ArenaAlloc* arena) : arena_(arena) {}
Brian Carlstrom413e89f2013-10-21 23:53:49 -070028 ~ArenaBitVectorAllocator() {}
29
30 virtual void* Alloc(size_t size) {
Vladimir Marko83cc7ae2014-02-12 18:02:05 +000031 return arena_->Alloc(size, kArenaAllocGrowableBitMap);
Brian Carlstrom413e89f2013-10-21 23:53:49 -070032 }
33
34 virtual void Free(void*) {} // Nop.
35
Brian Carlstrom413e89f2013-10-21 23:53:49 -070036 private:
Ian Rogerse77493c2014-08-20 15:08:45 -070037 ArenaAlloc* const arena_;
Brian Carlstrom413e89f2013-10-21 23:53:49 -070038 DISALLOW_COPY_AND_ASSIGN(ArenaBitVectorAllocator);
39};
buzbee862a7602013-04-05 10:58:54 -070040
41ArenaBitVector::ArenaBitVector(ArenaAllocator* arena, unsigned int start_bits,
42 bool expandable, OatBitMapKind kind)
Vladimir Markobfea9c22014-01-17 17:49:33 +000043 : BitVector(start_bits, expandable,
44 new (arena) ArenaBitVectorAllocator<ArenaAllocator>(arena)), kind_(kind) {
45 UNUSED(kind_);
46}
47
48ArenaBitVector::ArenaBitVector(ScopedArenaAllocator* arena, unsigned int start_bits,
49 bool expandable, OatBitMapKind kind)
50 : BitVector(start_bits, expandable,
51 new (arena) ArenaBitVectorAllocator<ScopedArenaAllocator>(arena)), kind_(kind) {
Ian Rogersb48b9eb2014-02-28 16:20:21 -080052 UNUSED(kind_);
53}
buzbee862a7602013-04-05 10:58:54 -070054
buzbee862a7602013-04-05 10:58:54 -070055} // namespace art