31 #include "utilities/debug.hpp"
32
33 STATIC_ASSERT(sizeof(BitMap::bm_word_t) == BytesPerWord); // "Implementation assumption."
34
35 typedef BitMap::bm_word_t bm_word_t;
36 typedef BitMap::idx_t idx_t;
37
38 class ResourceBitMapAllocator : StackObj {
39 public:
40 bm_word_t* allocate(idx_t size_in_words) const {
41 return NEW_RESOURCE_ARRAY(bm_word_t, size_in_words);
42 }
43 void free(bm_word_t* map, idx_t size_in_words) const {
44 // Don't free resource allocated arrays.
45 }
46 };
47
48 class CHeapBitMapAllocator : StackObj {
49 public:
50 bm_word_t* allocate(size_t size_in_words) const {
51 return ArrayAllocator<bm_word_t, mtInternal>::allocate(size_in_words);
52 }
53 void free(bm_word_t* map, idx_t size_in_words) const {
54 ArrayAllocator<bm_word_t, mtInternal>::free(map, size_in_words);
55 }
56 };
57
58 class ArenaBitMapAllocator : StackObj {
59 Arena* _arena;
60
61 public:
62 ArenaBitMapAllocator(Arena* arena) : _arena(arena) {}
63 bm_word_t* allocate(idx_t size_in_words) const {
64 return (bm_word_t*)_arena->Amalloc(size_in_words * BytesPerWord);
65 }
66 void free(bm_word_t* map, idx_t size_in_words) const {
67 // ArenaBitMaps currently don't free memory.
68 }
69 };
70
71 template <class Allocator>
72 BitMap::bm_word_t* BitMap::reallocate(const Allocator& allocator, bm_word_t* old_map, idx_t old_size_in_bits, idx_t new_size_in_bits) {
73 size_t old_size_in_words = calc_size_in_words(old_size_in_bits);
74 size_t new_size_in_words = calc_size_in_words(new_size_in_bits);
|
31 #include "utilities/debug.hpp"
32
33 STATIC_ASSERT(sizeof(BitMap::bm_word_t) == BytesPerWord); // "Implementation assumption."
34
35 typedef BitMap::bm_word_t bm_word_t;
36 typedef BitMap::idx_t idx_t;
37
38 class ResourceBitMapAllocator : StackObj {
39 public:
40 bm_word_t* allocate(idx_t size_in_words) const {
41 return NEW_RESOURCE_ARRAY(bm_word_t, size_in_words);
42 }
43 void free(bm_word_t* map, idx_t size_in_words) const {
44 // Don't free resource allocated arrays.
45 }
46 };
47
48 class CHeapBitMapAllocator : StackObj {
49 public:
50 bm_word_t* allocate(size_t size_in_words) const {
51 return ArrayAllocator<bm_word_t>::allocate(size_in_words, mtInternal);
52 }
53 void free(bm_word_t* map, idx_t size_in_words) const {
54 ArrayAllocator<bm_word_t>::free(map, size_in_words);
55 }
56 };
57
58 class ArenaBitMapAllocator : StackObj {
59 Arena* _arena;
60
61 public:
62 ArenaBitMapAllocator(Arena* arena) : _arena(arena) {}
63 bm_word_t* allocate(idx_t size_in_words) const {
64 return (bm_word_t*)_arena->Amalloc(size_in_words * BytesPerWord);
65 }
66 void free(bm_word_t* map, idx_t size_in_words) const {
67 // ArenaBitMaps currently don't free memory.
68 }
69 };
70
71 template <class Allocator>
72 BitMap::bm_word_t* BitMap::reallocate(const Allocator& allocator, bm_word_t* old_map, idx_t old_size_in_bits, idx_t new_size_in_bits) {
73 size_t old_size_in_words = calc_size_in_words(old_size_in_bits);
74 size_t new_size_in_words = calc_size_in_words(new_size_in_bits);
|