OLD | NEW |
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 VM_BIT_VECTOR_H_ | 5 #ifndef VM_BIT_VECTOR_H_ |
6 #define VM_BIT_VECTOR_H_ | 6 #define VM_BIT_VECTOR_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" |
(...skipping 29 matching lines...) Expand all Loading... |
40 intptr_t bit_index_; | 40 intptr_t bit_index_; |
41 intptr_t word_index_; | 41 intptr_t word_index_; |
42 uword current_word_; | 42 uword current_word_; |
43 | 43 |
44 friend class BitVector; | 44 friend class BitVector; |
45 }; | 45 }; |
46 | 46 |
47 explicit BitVector(intptr_t length) | 47 explicit BitVector(intptr_t length) |
48 : length_(length), | 48 : length_(length), |
49 data_length_(SizeFor(length)), | 49 data_length_(SizeFor(length)), |
50 data_(reinterpret_cast<uword*>( | 50 data_(Isolate::Current()->current_zone()->Alloc<uword>(data_length_)) { |
51 Isolate::Current()->current_zone()->Allocate( | |
52 data_length_ * sizeof(uword)))) { | |
53 ASSERT(length > 0); | 51 ASSERT(length > 0); |
54 Clear(); | 52 Clear(); |
55 } | 53 } |
56 | 54 |
57 static intptr_t SizeFor(intptr_t length) { | 55 static intptr_t SizeFor(intptr_t length) { |
58 return 1 + ((length - 1) / kBitsPerWord); | 56 return 1 + ((length - 1) / kBitsPerWord); |
59 } | 57 } |
60 | 58 |
61 void Add(intptr_t i) { | 59 void Add(intptr_t i) { |
62 ASSERT(i >= 0 && i < length()); | 60 ASSERT(i >= 0 && i < length()); |
(...skipping 30 matching lines...) Expand all Loading... |
93 intptr_t length_; | 91 intptr_t length_; |
94 intptr_t data_length_; | 92 intptr_t data_length_; |
95 uword* data_; | 93 uword* data_; |
96 | 94 |
97 DISALLOW_COPY_AND_ASSIGN(BitVector); | 95 DISALLOW_COPY_AND_ASSIGN(BitVector); |
98 }; | 96 }; |
99 | 97 |
100 } // namespace dart | 98 } // namespace dart |
101 | 99 |
102 #endif // VM_BIT_VECTOR_H_ | 100 #endif // VM_BIT_VECTOR_H_ |
OLD | NEW |