blob: f17e5a92a49c743a63561e3c2f7f8fe96150a0ce [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_allocator.h"
18#include "arena_bit_vector.h"
buzbee862a7602013-04-05 10:58:54 -070019
20namespace art {
21
Vladimir Markobfea9c22014-01-17 17:49:33 +000022template <typename ArenaAlloc>
Ian Rogers6a3c1fc2014-10-31 00:33:20 -070023class ArenaBitVectorAllocator FINAL : public Allocator,
24 public ArenaObject<kArenaAllocGrowableBitMap> {
Brian Carlstrom413e89f2013-10-21 23:53:49 -070025 public:
Vladimir Markobfea9c22014-01-17 17:49:33 +000026 explicit ArenaBitVectorAllocator(ArenaAlloc* arena) : arena_(arena) {}
Brian Carlstrom413e89f2013-10-21 23:53:49 -070027 ~ArenaBitVectorAllocator() {}
28
29 virtual void* Alloc(size_t size) {
Vladimir Marko83cc7ae2014-02-12 18:02:05 +000030 return arena_->Alloc(size, kArenaAllocGrowableBitMap);
Brian Carlstrom413e89f2013-10-21 23:53:49 -070031 }
32
33 virtual void Free(void*) {} // Nop.
34
Brian Carlstrom413e89f2013-10-21 23:53:49 -070035 private:
Ian Rogerse77493c2014-08-20 15:08:45 -070036 ArenaAlloc* const arena_;
Brian Carlstrom413e89f2013-10-21 23:53:49 -070037 DISALLOW_COPY_AND_ASSIGN(ArenaBitVectorAllocator);
38};
buzbee862a7602013-04-05 10:58:54 -070039
40ArenaBitVector::ArenaBitVector(ArenaAllocator* arena, unsigned int start_bits,
41 bool expandable, OatBitMapKind kind)
Vladimir Markobfea9c22014-01-17 17:49:33 +000042 : BitVector(start_bits, expandable,
43 new (arena) ArenaBitVectorAllocator<ArenaAllocator>(arena)), kind_(kind) {
44 UNUSED(kind_);
45}
46
47ArenaBitVector::ArenaBitVector(ScopedArenaAllocator* arena, unsigned int start_bits,
48 bool expandable, OatBitMapKind kind)
49 : BitVector(start_bits, expandable,
50 new (arena) ArenaBitVectorAllocator<ScopedArenaAllocator>(arena)), kind_(kind) {
Ian Rogersb48b9eb2014-02-28 16:20:21 -080051 UNUSED(kind_);
52}
buzbee862a7602013-04-05 10:58:54 -070053
buzbee862a7602013-04-05 10:58:54 -070054} // namespace art