OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | |
2 // for details. All rights reserved. Use of this source code is governed by a | |
3 // BSD-style license that can be found in the LICENSE file. | |
4 | |
5 #ifndef VM_BITMAP_H_ | |
6 #define VM_BITMAP_H_ | |
7 | |
8 #include "vm/allocation.h" | |
9 | |
10 namespace dart { | |
11 | |
12 // Forward declarations. | |
13 class Stackmap; | |
14 class RawStackmap; | |
srdjan
2012/03/14 23:03:25
Alphabetical order
siva
2012/03/15 00:17:38
Done.
| |
15 | |
16 | |
17 // BitmapBuilder is used to build a bitmap. The implementation is optimized for | |
18 // a dense set of small bit maps without an upper bound (e.g: a pointer map | |
19 // description of a stack). | |
20 class BitmapBuilder : public ZoneAllocated { | |
21 public: | |
22 BitmapBuilder() : size_in_bytes_(kInitialSizeInBytes), | |
23 bit_list_(bit_list_data_) { | |
24 memset(bit_list_data_, 0, kInitialSizeInBytes); | |
25 } | |
26 | |
27 intptr_t SizeInBits() const { return (size_in_bytes_ * kBitsPerByte); } | |
28 intptr_t SizeInBytes() const { return size_in_bytes_; } | |
29 | |
30 // Get/Set individual bits in the bitmap, set expands the underlying bitmap | |
31 // if needed. | |
32 bool Get(intptr_t bit_offset) const; | |
33 void Set(intptr_t bit_offset, bool value); | |
34 | |
35 // Return the bit offset of the highest bit set. | |
36 intptr_t Maximum() const; | |
37 | |
38 // Return the bit offset of the lowest bit set. | |
39 intptr_t Minimum() const; | |
40 | |
41 // Sets min..max (inclusive) to value. | |
42 void SetRange(intptr_t min, intptr_t max, bool value); | |
43 | |
44 // Replicates the bit map setting of the passed in Stackmap object. | |
45 void SetBits(const Stackmap& bitmap); | |
46 | |
47 private: | |
48 static const intptr_t kInitialSizeInBytes = 16; | |
49 static const intptr_t kIncrementSizeInBytes = 16; | |
50 | |
51 bool InRange(intptr_t offset) const { | |
52 return (offset >= 0) && (offset < SizeInBits()); | |
53 } | |
54 | |
55 bool GetBit(intptr_t bit_offset) const; | |
56 void SetBit(intptr_t bit_offset, bool value); | |
57 | |
58 intptr_t size_in_bytes_; | |
59 uint8_t bit_list_data_[kInitialSizeInBytes]; | |
60 uint8_t* bit_list_; | |
61 | |
62 DISALLOW_COPY_AND_ASSIGN(BitmapBuilder); | |
63 }; | |
64 | |
65 } // namespace dart | |
66 | |
67 #endif // VM_BITMAP_H_ | |
OLD | NEW |