Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef V8_DATAFLOW_H_ | 5 #ifndef V8_DATAFLOW_H_ |
| 6 #define V8_DATAFLOW_H_ | 6 #define V8_DATAFLOW_H_ |
| 7 | 7 |
| 8 #include "src/v8.h" | 8 #include "src/v8.h" |
| 9 | 9 |
| 10 #include "src/allocation.h" | 10 #include "src/allocation.h" |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 96 DCHECK(i >= 0 && i < length()); | 96 DCHECK(i >= 0 && i < length()); |
| 97 uintptr_t block = data_[i / kDataBits]; | 97 uintptr_t block = data_[i / kDataBits]; |
| 98 return (block & (kOne << (i % kDataBits))) != 0; | 98 return (block & (kOne << (i % kDataBits))) != 0; |
| 99 } | 99 } |
| 100 | 100 |
| 101 void Add(int i) { | 101 void Add(int i) { |
| 102 DCHECK(i >= 0 && i < length()); | 102 DCHECK(i >= 0 && i < length()); |
| 103 data_[i / kDataBits] |= (kOne << (i % kDataBits)); | 103 data_[i / kDataBits] |= (kOne << (i % kDataBits)); |
| 104 } | 104 } |
| 105 | 105 |
| 106 void AddAll() { memset(data_, -1, sizeof(uintptr_t) * data_length_); } | |
| 107 | |
| 106 void Remove(int i) { | 108 void Remove(int i) { |
| 107 DCHECK(i >= 0 && i < length()); | 109 DCHECK(i >= 0 && i < length()); |
| 108 data_[i / kDataBits] &= ~(kOne << (i % kDataBits)); | 110 data_[i / kDataBits] &= ~(kOne << (i % kDataBits)); |
| 109 } | 111 } |
| 110 | 112 |
| 111 void Union(const BitVector& other) { | 113 void Union(const BitVector& other) { |
| 112 DCHECK(other.length() == length()); | 114 DCHECK(other.length() == length()); |
| 113 for (int i = 0; i < data_length_; i++) { | 115 for (int i = 0; i < data_length_; i++) { |
| 114 data_[i] |= other.data_[i]; | 116 data_[i] |= other.data_[i]; |
| 115 } | 117 } |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 145 } | 147 } |
| 146 | 148 |
| 147 void Subtract(const BitVector& other) { | 149 void Subtract(const BitVector& other) { |
| 148 DCHECK(other.length() == length()); | 150 DCHECK(other.length() == length()); |
| 149 for (int i = 0; i < data_length_; i++) { | 151 for (int i = 0; i < data_length_; i++) { |
| 150 data_[i] &= ~other.data_[i]; | 152 data_[i] &= ~other.data_[i]; |
| 151 } | 153 } |
| 152 } | 154 } |
| 153 | 155 |
| 154 void Clear() { | 156 void Clear() { |
| 155 for (int i = 0; i < data_length_; i++) { | 157 for (int i = 0; i < data_length_; i++) { |
|
Michael Starzinger
2015/02/06 14:59:32
Just out of curiosity, is there a reason Clear doe
titzer
2015/02/06 15:01:54
No idea. I can fix it, if you like. I did the mems
| |
| 156 data_[i] = 0; | 158 data_[i] = 0; |
| 157 } | 159 } |
| 158 } | 160 } |
| 159 | 161 |
| 160 bool IsEmpty() const { | 162 bool IsEmpty() const { |
| 161 for (int i = 0; i < data_length_; i++) { | 163 for (int i = 0; i < data_length_; i++) { |
| 162 if (data_[i] != 0) return false; | 164 if (data_[i] != 0) return false; |
| 163 } | 165 } |
| 164 return true; | 166 return true; |
| 165 } | 167 } |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 243 bits_ = new_bits; | 245 bits_ = new_bits; |
| 244 } | 246 } |
| 245 | 247 |
| 246 BitVector* bits_; | 248 BitVector* bits_; |
| 247 }; | 249 }; |
| 248 | 250 |
| 249 } // namespace internal | 251 } // namespace internal |
| 250 } // namespace v8 | 252 } // namespace v8 |
| 251 | 253 |
| 252 #endif // V8_DATAFLOW_H_ | 254 #endif // V8_DATAFLOW_H_ |
| OLD | NEW |