Nicolas Geoffray | 0e33643 | 2014-02-26 18:24:38 +0000 | [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 | |
David Sehr | 1ce2b3b | 2018-04-05 11:02:03 -0700 | [diff] [blame] | 17 | #ifndef ART_LIBARTBASE_BASE_ARENA_BIT_VECTOR_H_ |
| 18 | #define ART_LIBARTBASE_BASE_ARENA_BIT_VECTOR_H_ |
Nicolas Geoffray | 0e33643 | 2014-02-26 18:24:38 +0000 | [diff] [blame] | 19 | |
David Sehr | 1979c64 | 2018-04-26 14:41:18 -0700 | [diff] [blame] | 20 | #include "arena_object.h" |
| 21 | #include "bit_vector.h" |
Nicolas Geoffray | 0e33643 | 2014-02-26 18:24:38 +0000 | [diff] [blame] | 22 | |
| 23 | namespace art { |
| 24 | |
Ian Rogers | 6a3c1fc | 2014-10-31 00:33:20 -0700 | [diff] [blame] | 25 | class ArenaAllocator; |
| 26 | class ScopedArenaAllocator; |
| 27 | |
Nicolas Geoffray | 0e33643 | 2014-02-26 18:24:38 +0000 | [diff] [blame] | 28 | /* |
| 29 | * A BitVector implementation that uses Arena allocation. |
| 30 | */ |
Ian Rogers | 6a3c1fc | 2014-10-31 00:33:20 -0700 | [diff] [blame] | 31 | class ArenaBitVector : public BitVector, public ArenaObject<kArenaAllocGrowableBitMap> { |
Ian Rogers | e77493c | 2014-08-20 15:08:45 -0700 | [diff] [blame] | 32 | public: |
Vladimir Marko | f6a35de | 2016-03-21 12:01:50 +0000 | [diff] [blame] | 33 | template <typename Allocator> |
Vladimir Marko | 69d310e | 2017-10-09 14:12:23 +0100 | [diff] [blame] | 34 | static ArenaBitVector* Create(Allocator* allocator, |
Vladimir Marko | f6a35de | 2016-03-21 12:01:50 +0000 | [diff] [blame] | 35 | uint32_t start_bits, |
| 36 | bool expandable, |
| 37 | ArenaAllocKind kind = kArenaAllocGrowableBitMap) { |
Vladimir Marko | 69d310e | 2017-10-09 14:12:23 +0100 | [diff] [blame] | 38 | void* storage = allocator->template Alloc<ArenaBitVector>(kind); |
| 39 | return new (storage) ArenaBitVector(allocator, start_bits, expandable, kind); |
Vladimir Marko | f6a35de | 2016-03-21 12:01:50 +0000 | [diff] [blame] | 40 | } |
| 41 | |
Vladimir Marko | 69d310e | 2017-10-09 14:12:23 +0100 | [diff] [blame] | 42 | ArenaBitVector(ArenaAllocator* allocator, |
Vladimir Marko | f6a35de | 2016-03-21 12:01:50 +0000 | [diff] [blame] | 43 | uint32_t start_bits, |
| 44 | bool expandable, |
| 45 | ArenaAllocKind kind = kArenaAllocGrowableBitMap); |
Vladimir Marko | 69d310e | 2017-10-09 14:12:23 +0100 | [diff] [blame] | 46 | ArenaBitVector(ScopedArenaAllocator* allocator, |
Vladimir Marko | f6a35de | 2016-03-21 12:01:50 +0000 | [diff] [blame] | 47 | uint32_t start_bits, |
| 48 | bool expandable, |
| 49 | ArenaAllocKind kind = kArenaAllocGrowableBitMap); |
Ian Rogers | e77493c | 2014-08-20 15:08:45 -0700 | [diff] [blame] | 50 | ~ArenaBitVector() {} |
Nicolas Geoffray | 0e33643 | 2014-02-26 18:24:38 +0000 | [diff] [blame] | 51 | |
Ian Rogers | e77493c | 2014-08-20 15:08:45 -0700 | [diff] [blame] | 52 | private: |
Ian Rogers | 6a3c1fc | 2014-10-31 00:33:20 -0700 | [diff] [blame] | 53 | DISALLOW_COPY_AND_ASSIGN(ArenaBitVector); |
Nicolas Geoffray | 0e33643 | 2014-02-26 18:24:38 +0000 | [diff] [blame] | 54 | }; |
| 55 | |
Nicolas Geoffray | 0e33643 | 2014-02-26 18:24:38 +0000 | [diff] [blame] | 56 | } // namespace art |
| 57 | |
David Sehr | 1ce2b3b | 2018-04-05 11:02:03 -0700 | [diff] [blame] | 58 | #endif // ART_LIBARTBASE_BASE_ARENA_BIT_VECTOR_H_ |