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 
17 #ifndef ART_LIBARTBASE_BASE_ARENA_BIT_VECTOR_H_
18 #define ART_LIBARTBASE_BASE_ARENA_BIT_VECTOR_H_
19 
20 #include "arena_object.h"
21 #include "base/arena_allocator.h"
22 #include "bit_vector.h"
23 
24 namespace art {
25 
26 class ArenaAllocator;
27 class ScopedArenaAllocator;
28 
29 /*
30  * A BitVector implementation that uses Arena allocation. All constructors of ArenaBitVector start
31  * with an empty ArenaBitVector.
32  */
33 class ArenaBitVector : public BitVector, public ArenaObject<kArenaAllocGrowableBitMap> {
34  public:
35   template <typename Allocator>
36   static ArenaBitVector* Create(Allocator* allocator,
37                                 uint32_t start_bits,
38                                 bool expandable,
39                                 ArenaAllocKind kind = kArenaAllocGrowableBitMap) {
40     void* storage = allocator->template Alloc<ArenaBitVector>(kind);
41     return new (storage) ArenaBitVector(allocator, start_bits, expandable, kind);
42   }
43 
44   ArenaBitVector(ArenaAllocator* allocator,
45                  uint32_t start_bits,
46                  bool expandable,
47                  ArenaAllocKind kind = kArenaAllocGrowableBitMap);
48   ArenaBitVector(ScopedArenaAllocator* allocator,
49                  uint32_t start_bits,
50                  bool expandable,
51                  ArenaAllocKind kind = kArenaAllocGrowableBitMap);
~ArenaBitVector()52   ~ArenaBitVector() {}
53 
54   ArenaBitVector(ArenaBitVector&&) = default;
55   ArenaBitVector(const ArenaBitVector&) = delete;
56 };
57 
58 }  // namespace art
59 
60 #endif  // ART_LIBARTBASE_BASE_ARENA_BIT_VECTOR_H_
61