Chromium Code Reviews| 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 59 void Add(intptr_t i) { | 59 void Add(intptr_t i) { |
| 60 ASSERT(i >= 0 && i < length()); | 60 ASSERT(i >= 0 && i < length()); |
| 61 data_[i / kBitsPerWord] |= (static_cast<uword>(1) << (i % kBitsPerWord)); | 61 data_[i / kBitsPerWord] |= (static_cast<uword>(1) << (i % kBitsPerWord)); |
| 62 } | 62 } |
| 63 | 63 |
| 64 void Remove(intptr_t i) { | 64 void Remove(intptr_t i) { |
| 65 ASSERT(i >= 0 && i < length()); | 65 ASSERT(i >= 0 && i < length()); |
| 66 data_[i / kBitsPerWord] &= ~(static_cast<uword>(1) << (i % kBitsPerWord)); | 66 data_[i / kBitsPerWord] &= ~(static_cast<uword>(1) << (i % kBitsPerWord)); |
| 67 } | 67 } |
| 68 | 68 |
| 69 bool Equals(const BitVector& other) const; | |
| 70 | |
| 69 // Add all elements that are in the bitvector from. | 71 // Add all elements that are in the bitvector from. |
| 70 bool AddAll(BitVector* from); | 72 bool AddAll(BitVector* from); |
| 71 | 73 |
| 72 // From the bitvector gen add those elements that are not in the | 74 // From the bitvector gen add those elements that are not in the |
| 73 // bitvector kill. | 75 // bitvector kill. |
| 74 bool KillAndAdd(BitVector* kill, BitVector* gen); | 76 bool KillAndAdd(BitVector* kill, BitVector* gen); |
| 75 | 77 |
| 78 bool Intersect(const BitVector& other); | |
| 79 | |
| 76 bool Contains(int i) const { | 80 bool Contains(int i) const { |
| 77 ASSERT(i >= 0 && i < length()); | 81 ASSERT(i >= 0 && i < length()); |
| 78 uword block = data_[i / kBitsPerWord]; | 82 uword block = data_[i / kBitsPerWord]; |
| 79 return (block & (static_cast<uword>(1) << (i % kBitsPerWord))) != 0; | 83 return (block & (static_cast<uword>(1) << (i % kBitsPerWord))) != 0; |
| 80 } | 84 } |
| 81 | 85 |
| 82 void Clear() { | 86 void Clear() { |
| 83 for (intptr_t i = 0; i < data_length_; i++) { | 87 for (intptr_t i = 0; i < data_length_; i++) { |
| 84 data_[i] = 0; | 88 data_[i] = 0; |
| 85 } | 89 } |
| 86 } | 90 } |
| 87 | 91 |
| 92 void SetAll() { | |
|
Kevin Millikin (Google)
2012/09/17 12:09:47
There's a subtle interaction between Clear(), SetA
Florian Schneider
2012/09/17 14:20:59
Thanks. I opted for (2) and changed Equals accordi
| |
| 93 for (intptr_t i = 0; i < data_length_; i++) { | |
| 94 data_[i] = static_cast<uword>(-1); | |
| 95 } | |
| 96 } | |
| 97 | |
| 88 intptr_t length() const { return length_; } | 98 intptr_t length() const { return length_; } |
| 89 | 99 |
| 100 void Print() const; | |
| 101 | |
| 90 private: | 102 private: |
| 91 intptr_t length_; | 103 intptr_t length_; |
| 92 intptr_t data_length_; | 104 intptr_t data_length_; |
| 93 uword* data_; | 105 uword* data_; |
| 94 | 106 |
| 95 DISALLOW_COPY_AND_ASSIGN(BitVector); | 107 DISALLOW_COPY_AND_ASSIGN(BitVector); |
| 96 }; | 108 }; |
| 97 | 109 |
| 98 } // namespace dart | 110 } // namespace dart |
| 99 | 111 |
| 100 #endif // VM_BIT_VECTOR_H_ | 112 #endif // VM_BIT_VECTOR_H_ |
| OLD | NEW |