buzbee | 862a760 | 2013-04-05 10:58:54 -0700 | [diff] [blame] | 1 | /* |
| 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 Geoffray | 0e33643 | 2014-02-26 18:24:38 +0000 | [diff] [blame] | 17 | #include "arena_allocator.h" |
| 18 | #include "arena_bit_vector.h" |
buzbee | 862a760 | 2013-04-05 10:58:54 -0700 | [diff] [blame] | 19 | |
| 20 | namespace art { |
| 21 | |
Vladimir Marko | bfea9c2 | 2014-01-17 17:49:33 +0000 | [diff] [blame] | 22 | template <typename ArenaAlloc> |
Ian Rogers | 6a3c1fc | 2014-10-31 00:33:20 -0700 | [diff] [blame] | 23 | class ArenaBitVectorAllocator FINAL : public Allocator, |
| 24 | public ArenaObject<kArenaAllocGrowableBitMap> { |
Brian Carlstrom | 413e89f | 2013-10-21 23:53:49 -0700 | [diff] [blame] | 25 | public: |
Vladimir Marko | bfea9c2 | 2014-01-17 17:49:33 +0000 | [diff] [blame] | 26 | explicit ArenaBitVectorAllocator(ArenaAlloc* arena) : arena_(arena) {} |
Brian Carlstrom | 413e89f | 2013-10-21 23:53:49 -0700 | [diff] [blame] | 27 | ~ArenaBitVectorAllocator() {} |
| 28 | |
| 29 | virtual void* Alloc(size_t size) { |
Vladimir Marko | 83cc7ae | 2014-02-12 18:02:05 +0000 | [diff] [blame] | 30 | return arena_->Alloc(size, kArenaAllocGrowableBitMap); |
Brian Carlstrom | 413e89f | 2013-10-21 23:53:49 -0700 | [diff] [blame] | 31 | } |
| 32 | |
| 33 | virtual void Free(void*) {} // Nop. |
| 34 | |
Brian Carlstrom | 413e89f | 2013-10-21 23:53:49 -0700 | [diff] [blame] | 35 | private: |
Ian Rogers | e77493c | 2014-08-20 15:08:45 -0700 | [diff] [blame] | 36 | ArenaAlloc* const arena_; |
Brian Carlstrom | 413e89f | 2013-10-21 23:53:49 -0700 | [diff] [blame] | 37 | DISALLOW_COPY_AND_ASSIGN(ArenaBitVectorAllocator); |
| 38 | }; |
buzbee | 862a760 | 2013-04-05 10:58:54 -0700 | [diff] [blame] | 39 | |
| 40 | ArenaBitVector::ArenaBitVector(ArenaAllocator* arena, unsigned int start_bits, |
| 41 | bool expandable, OatBitMapKind kind) |
Vladimir Marko | bfea9c2 | 2014-01-17 17:49:33 +0000 | [diff] [blame] | 42 | : BitVector(start_bits, expandable, |
| 43 | new (arena) ArenaBitVectorAllocator<ArenaAllocator>(arena)), kind_(kind) { |
| 44 | UNUSED(kind_); |
| 45 | } |
| 46 | |
| 47 | ArenaBitVector::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 Rogers | b48b9eb | 2014-02-28 16:20:21 -0800 | [diff] [blame] | 51 | UNUSED(kind_); |
| 52 | } |
buzbee | 862a760 | 2013-04-05 10:58:54 -0700 | [diff] [blame] | 53 | |
buzbee | 862a760 | 2013-04-05 10:58:54 -0700 | [diff] [blame] | 54 | } // namespace art |