blob: eff977861258f80a728aac7ebc3e31b7156a0734 [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
Brian Carlstrom413e89f2013-10-21 23:53:49 -070022class ArenaBitVectorAllocator : public Allocator {
23 public:
24 explicit ArenaBitVectorAllocator(ArenaAllocator* arena) : arena_(arena) {}
25 ~ArenaBitVectorAllocator() {}
26
27 virtual void* Alloc(size_t size) {
Vladimir Marko83cc7ae2014-02-12 18:02:05 +000028 return arena_->Alloc(size, kArenaAllocGrowableBitMap);
Brian Carlstrom413e89f2013-10-21 23:53:49 -070029 }
30
31 virtual void Free(void*) {} // Nop.
32
33 static void* operator new(size_t size, ArenaAllocator* arena) {
Vladimir Marko83cc7ae2014-02-12 18:02:05 +000034 return arena->Alloc(sizeof(ArenaBitVectorAllocator), kArenaAllocGrowableBitMap);
Brian Carlstrom413e89f2013-10-21 23:53:49 -070035 }
36 static void operator delete(void* p) {} // Nop.
37
38 private:
39 ArenaAllocator* arena_;
40 DISALLOW_COPY_AND_ASSIGN(ArenaBitVectorAllocator);
41};
buzbee862a7602013-04-05 10:58:54 -070042
43ArenaBitVector::ArenaBitVector(ArenaAllocator* arena, unsigned int start_bits,
44 bool expandable, OatBitMapKind kind)
Ian Rogersb48b9eb2014-02-28 16:20:21 -080045 : BitVector(start_bits, expandable, new (arena) ArenaBitVectorAllocator(arena)), kind_(kind) {
46 UNUSED(kind_);
47}
buzbee862a7602013-04-05 10:58:54 -070048
buzbee862a7602013-04-05 10:58:54 -070049} // namespace art