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 | |
| 17 | #include "compiler_internals.h" |
| 18 | #include "dex_file-inl.h" |
| 19 | |
| 20 | namespace art { |
| 21 | |
Brian Carlstrom | 413e89f | 2013-10-21 23:53:49 -0700 | [diff] [blame] | 22 | class 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 | }; |
buzbee | 862a760 | 2013-04-05 10:58:54 -0700 | [diff] [blame] | 42 | |
| 43 | ArenaBitVector::ArenaBitVector(ArenaAllocator* arena, unsigned int start_bits, |
| 44 | bool expandable, OatBitMapKind kind) |
Brian Carlstrom | 413e89f | 2013-10-21 23:53:49 -0700 | [diff] [blame] | 45 | : BitVector(start_bits, expandable, new (arena) ArenaBitVectorAllocator(arena)), kind_(kind) {} |
buzbee | 862a760 | 2013-04-05 10:58:54 -0700 | [diff] [blame] | 46 | |
| 47 | } // namespace art |