blob: 0fb6bbf775d38192bb40aadd5a67ab6608cf1f4d [file] [log] [blame]
Nicolas Geoffray0e336432014-02-26 18:24:38 +00001/*
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 Sehr1ce2b3b2018-04-05 11:02:03 -070017#ifndef ART_LIBARTBASE_BASE_ARENA_BIT_VECTOR_H_
18#define ART_LIBARTBASE_BASE_ARENA_BIT_VECTOR_H_
Nicolas Geoffray0e336432014-02-26 18:24:38 +000019
David Sehr1979c642018-04-26 14:41:18 -070020#include "arena_object.h"
21#include "bit_vector.h"
Nicolas Geoffray0e336432014-02-26 18:24:38 +000022
23namespace art {
24
Ian Rogers6a3c1fc2014-10-31 00:33:20 -070025class ArenaAllocator;
26class ScopedArenaAllocator;
27
Nicolas Geoffray0e336432014-02-26 18:24:38 +000028/*
29 * A BitVector implementation that uses Arena allocation.
30 */
Ian Rogers6a3c1fc2014-10-31 00:33:20 -070031class ArenaBitVector : public BitVector, public ArenaObject<kArenaAllocGrowableBitMap> {
Ian Rogerse77493c2014-08-20 15:08:45 -070032 public:
Vladimir Markof6a35de2016-03-21 12:01:50 +000033 template <typename Allocator>
Vladimir Marko69d310e2017-10-09 14:12:23 +010034 static ArenaBitVector* Create(Allocator* allocator,
Vladimir Markof6a35de2016-03-21 12:01:50 +000035 uint32_t start_bits,
36 bool expandable,
37 ArenaAllocKind kind = kArenaAllocGrowableBitMap) {
Vladimir Marko69d310e2017-10-09 14:12:23 +010038 void* storage = allocator->template Alloc<ArenaBitVector>(kind);
39 return new (storage) ArenaBitVector(allocator, start_bits, expandable, kind);
Vladimir Markof6a35de2016-03-21 12:01:50 +000040 }
41
Vladimir Marko69d310e2017-10-09 14:12:23 +010042 ArenaBitVector(ArenaAllocator* allocator,
Vladimir Markof6a35de2016-03-21 12:01:50 +000043 uint32_t start_bits,
44 bool expandable,
45 ArenaAllocKind kind = kArenaAllocGrowableBitMap);
Vladimir Marko69d310e2017-10-09 14:12:23 +010046 ArenaBitVector(ScopedArenaAllocator* allocator,
Vladimir Markof6a35de2016-03-21 12:01:50 +000047 uint32_t start_bits,
48 bool expandable,
49 ArenaAllocKind kind = kArenaAllocGrowableBitMap);
Ian Rogerse77493c2014-08-20 15:08:45 -070050 ~ArenaBitVector() {}
Nicolas Geoffray0e336432014-02-26 18:24:38 +000051
Ian Rogerse77493c2014-08-20 15:08:45 -070052 private:
Ian Rogers6a3c1fc2014-10-31 00:33:20 -070053 DISALLOW_COPY_AND_ASSIGN(ArenaBitVector);
Nicolas Geoffray0e336432014-02-26 18:24:38 +000054};
55
Nicolas Geoffray0e336432014-02-26 18:24:38 +000056} // namespace art
57
David Sehr1ce2b3b2018-04-05 11:02:03 -070058#endif // ART_LIBARTBASE_BASE_ARENA_BIT_VECTOR_H_