Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(54)

Side by Side Diff: runtime/vm/bitmap.h

Issue 2481873005: clang-format runtime/vm (Closed)
Patch Set: Merge Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « runtime/vm/bitfield.h ('k') | runtime/vm/bitmap.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 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 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. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #ifndef RUNTIME_VM_BITMAP_H_ 5 #ifndef RUNTIME_VM_BITMAP_H_
6 #define RUNTIME_VM_BITMAP_H_ 6 #define RUNTIME_VM_BITMAP_H_
7 7
8 #include "vm/allocation.h" 8 #include "vm/allocation.h"
9 #include "vm/isolate.h" 9 #include "vm/isolate.h"
10 #include "vm/zone.h" 10 #include "vm/zone.h"
11 11
12 namespace dart { 12 namespace dart {
13 13
14 // Forward declarations. 14 // Forward declarations.
15 class RawStackmap; 15 class RawStackmap;
16 class Stackmap; 16 class Stackmap;
17 17
18 18
19 // BitmapBuilder is used to build a bitmap. The implementation is optimized 19 // BitmapBuilder is used to build a bitmap. The implementation is optimized
20 // for a dense set of small bit maps without a fixed upper bound (e.g: a 20 // for a dense set of small bit maps without a fixed upper bound (e.g: a
21 // pointer map description of a stack). 21 // pointer map description of a stack).
22 class BitmapBuilder : public ZoneAllocated { 22 class BitmapBuilder : public ZoneAllocated {
23 public: 23 public:
24 BitmapBuilder() 24 BitmapBuilder()
25 : length_(0), 25 : length_(0),
26 data_size_in_bytes_(kInitialSizeInBytes), 26 data_size_in_bytes_(kInitialSizeInBytes),
27 data_(Thread::Current()->zone()->Alloc<uint8_t>( 27 data_(Thread::Current()->zone()->Alloc<uint8_t>(kInitialSizeInBytes)) {
28 kInitialSizeInBytes)) {
29 memset(data_, 0, kInitialSizeInBytes); 28 memset(data_, 0, kInitialSizeInBytes);
30 } 29 }
31 30
32 intptr_t Length() const { return length_; } 31 intptr_t Length() const { return length_; }
33 void SetLength(intptr_t length); 32 void SetLength(intptr_t length);
34 33
35 // Get/Set individual bits in the bitmap, setting bits beyond the bitmap's 34 // Get/Set individual bits in the bitmap, setting bits beyond the bitmap's
36 // length increases the length and expands the underlying bitmap if 35 // length increases the length and expands the underlying bitmap if
37 // needed. 36 // needed.
38 bool Get(intptr_t bit_offset) const; 37 bool Get(intptr_t bit_offset) const;
39 void Set(intptr_t bit_offset, bool value); 38 void Set(intptr_t bit_offset, bool value);
40 39
41 // Return the bit offset of the highest bit set. 40 // Return the bit offset of the highest bit set.
42 intptr_t Maximum() const; 41 intptr_t Maximum() const;
43 42
44 // Return the bit offset of the lowest bit set. 43 // Return the bit offset of the lowest bit set.
45 intptr_t Minimum() const; 44 intptr_t Minimum() const;
46 45
47 // Sets min..max (inclusive) to value. 46 // Sets min..max (inclusive) to value.
48 void SetRange(intptr_t min, intptr_t max, bool value); 47 void SetRange(intptr_t min, intptr_t max, bool value);
49 48
50 void Print() const; 49 void Print() const;
51 50
52 private: 51 private:
53 static const intptr_t kInitialSizeInBytes = 16; 52 static const intptr_t kInitialSizeInBytes = 16;
54 static const intptr_t kIncrementSizeInBytes = 16; 53 static const intptr_t kIncrementSizeInBytes = 16;
55 54
56 bool InRange(intptr_t offset) const { 55 bool InRange(intptr_t offset) const {
57 if (offset < 0) { 56 if (offset < 0) {
58 FATAL1("Fatal error in BitmapBuilder::InRange :" 57 FATAL1(
59 " invalid bit_offset, %" Pd "\n", offset); 58 "Fatal error in BitmapBuilder::InRange :"
59 " invalid bit_offset, %" Pd "\n",
60 offset);
60 } 61 }
61 return (offset < length_); 62 return (offset < length_);
62 } 63 }
63 64
64 // Get/Set a bit that is known to be covered by the backing store. 65 // Get/Set a bit that is known to be covered by the backing store.
65 bool GetBit(intptr_t bit_offset) const; 66 bool GetBit(intptr_t bit_offset) const;
66 void SetBit(intptr_t bit_offset, bool value); 67 void SetBit(intptr_t bit_offset, bool value);
67 68
68 intptr_t length_; 69 intptr_t length_;
69 70
70 // Backing store for the bitmap. Reading bits beyond the backing store 71 // Backing store for the bitmap. Reading bits beyond the backing store
71 // (up to length_) is allowed and they are assumed to be false. 72 // (up to length_) is allowed and they are assumed to be false.
72 intptr_t data_size_in_bytes_; 73 intptr_t data_size_in_bytes_;
73 uint8_t* data_; 74 uint8_t* data_;
74 75
75 DISALLOW_COPY_AND_ASSIGN(BitmapBuilder); 76 DISALLOW_COPY_AND_ASSIGN(BitmapBuilder);
76 }; 77 };
77 78
78 } // namespace dart 79 } // namespace dart
79 80
80 #endif // RUNTIME_VM_BITMAP_H_ 81 #endif // RUNTIME_VM_BITMAP_H_
OLDNEW
« no previous file with comments | « runtime/vm/bitfield.h ('k') | runtime/vm/bitmap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698