buzbee | 862a760 | 2013-04-05 10:58:54 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2013 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 | |
Brian Carlstrom | fc0e321 | 2013-07-17 14:40:12 -0700 | [diff] [blame] | 17 | #ifndef ART_COMPILER_DEX_ARENA_BIT_VECTOR_H_ |
| 18 | #define ART_COMPILER_DEX_ARENA_BIT_VECTOR_H_ |
buzbee | 862a760 | 2013-04-05 10:58:54 -0700 | [diff] [blame] | 19 | |
buzbee | 862a760 | 2013-04-05 10:58:54 -0700 | [diff] [blame] | 20 | #include "arena_allocator.h" |
Brian Carlstrom | ba150c3 | 2013-08-27 17:31:03 -0700 | [diff] [blame] | 21 | #include "base/bit_vector.h" |
Brian Carlstrom | 413e89f | 2013-10-21 23:53:49 -0700 | [diff] [blame] | 22 | #include "compiler_enums.h" |
buzbee | 862a760 | 2013-04-05 10:58:54 -0700 | [diff] [blame] | 23 | |
| 24 | namespace art { |
| 25 | |
buzbee | 862a760 | 2013-04-05 10:58:54 -0700 | [diff] [blame] | 26 | /* |
Brian Carlstrom | 413e89f | 2013-10-21 23:53:49 -0700 | [diff] [blame] | 27 | * A BitVector implementation that uses Arena allocation. |
buzbee | 862a760 | 2013-04-05 10:58:54 -0700 | [diff] [blame] | 28 | */ |
Brian Carlstrom | 413e89f | 2013-10-21 23:53:49 -0700 | [diff] [blame] | 29 | class ArenaBitVector : public BitVector { |
buzbee | 862a760 | 2013-04-05 10:58:54 -0700 | [diff] [blame] | 30 | public: |
buzbee | 0d82948 | 2013-10-11 15:24:55 -0700 | [diff] [blame] | 31 | ArenaBitVector(ArenaAllocator* arena, uint32_t start_bits, bool expandable, |
buzbee | 862a760 | 2013-04-05 10:58:54 -0700 | [diff] [blame] | 32 | OatBitMapKind kind = kBitMapMisc); |
Brian Carlstrom | 9b7085a | 2013-07-18 15:15:21 -0700 | [diff] [blame] | 33 | ~ArenaBitVector() {} |
buzbee | 862a760 | 2013-04-05 10:58:54 -0700 | [diff] [blame] | 34 | |
Brian Carlstrom | 413e89f | 2013-10-21 23:53:49 -0700 | [diff] [blame] | 35 | static void* operator new(size_t size, ArenaAllocator* arena) { |
| 36 | return arena->Alloc(sizeof(ArenaBitVector), ArenaAllocator::kAllocGrowableBitMap); |
| 37 | } |
| 38 | static void operator delete(void* p) {} // Nop. |
buzbee | 862a760 | 2013-04-05 10:58:54 -0700 | [diff] [blame] | 39 | |
| 40 | private: |
Brian Carlstrom | 413e89f | 2013-10-21 23:53:49 -0700 | [diff] [blame] | 41 | const OatBitMapKind kind_; // for memory use tuning. TODO: currently unused. |
buzbee | 862a760 | 2013-04-05 10:58:54 -0700 | [diff] [blame] | 42 | }; |
| 43 | |
| 44 | |
| 45 | } // namespace art |
| 46 | |
Brian Carlstrom | fc0e321 | 2013-07-17 14:40:12 -0700 | [diff] [blame] | 47 | #endif // ART_COMPILER_DEX_ARENA_BIT_VECTOR_H_ |