blob: b567ae8d8a01307d9e140caffa7c75c77c1e1cac [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
17#include "compiler_internals.h"
18#include "dex_file-inl.h"
19
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) {
28 return arena_->Alloc(size, ArenaAllocator::kAllocGrowableBitMap);
29 }
30
31 virtual void Free(void*) {} // Nop.
32
33 static void* operator new(size_t size, ArenaAllocator* arena) {
34 return arena->Alloc(sizeof(ArenaBitVectorAllocator), ArenaAllocator::kAllocGrowableBitMap);
35 }
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)
Brian Carlstrom413e89f2013-10-21 23:53:49 -070045 : BitVector(start_bits, expandable, new (arena) ArenaBitVectorAllocator(arena)), kind_(kind) {}
buzbee862a7602013-04-05 10:58:54 -070046
47} // namespace art