| 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 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 return true; | 157 return true; |
| 158 } | 158 } |
| 159 | 159 |
| 160 bool Equals(const BitVector& other) { | 160 bool Equals(const BitVector& other) { |
| 161 for (int i = 0; i < data_length_; i++) { | 161 for (int i = 0; i < data_length_; i++) { |
| 162 if (data_[i] != other.data_[i]) return false; | 162 if (data_[i] != other.data_[i]) return false; |
| 163 } | 163 } |
| 164 return true; | 164 return true; |
| 165 } | 165 } |
| 166 | 166 |
| 167 int Count() const { | 167 int Count() const; |
| 168 int count = 0; | |
| 169 for (int i = 0; i < data_length_; i++) { | |
| 170 int data = data_[i]; | |
| 171 if (data != 0) count += CompilerIntrinsics::CountSetBits(data); | |
| 172 } | |
| 173 return count; | |
| 174 } | |
| 175 | 168 |
| 176 int length() const { return length_; } | 169 int length() const { return length_; } |
| 177 | 170 |
| 178 #ifdef DEBUG | 171 #ifdef DEBUG |
| 179 void Print(); | 172 void Print(); |
| 180 #endif | 173 #endif |
| 181 | 174 |
| 182 private: | 175 private: |
| 183 int length_; | 176 int length_; |
| 184 int data_length_; | 177 int data_length_; |
| 185 uint32_t* data_; | 178 uint32_t* data_; |
| 186 }; | 179 }; |
| 187 | 180 |
| 181 |
| 188 class GrowableBitVector BASE_EMBEDDED { | 182 class GrowableBitVector BASE_EMBEDDED { |
| 189 public: | 183 public: |
| 190 class Iterator BASE_EMBEDDED { | 184 class Iterator BASE_EMBEDDED { |
| 191 public: | 185 public: |
| 192 Iterator(const GrowableBitVector* target, Zone* zone) | 186 Iterator(const GrowableBitVector* target, Zone* zone) |
| 193 : it_(target->bits_ == NULL | 187 : it_(target->bits_ == NULL |
| 194 ? new(zone) BitVector(1, zone) | 188 ? new(zone) BitVector(1, zone) |
| 195 : target->bits_) { } | 189 : target->bits_) { } |
| 196 bool Done() const { return it_.Done(); } | 190 bool Done() const { return it_.Done(); } |
| 197 void Advance() { it_.Advance(); } | 191 void Advance() { it_.Advance(); } |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 int new_length = bits_ == NULL ? kInitialLength : bits_->length(); | 228 int new_length = bits_ == NULL ? kInitialLength : bits_->length(); |
| 235 while (new_length <= value) new_length *= 2; | 229 while (new_length <= value) new_length *= 2; |
| 236 BitVector* new_bits = new(zone) BitVector(new_length, zone); | 230 BitVector* new_bits = new(zone) BitVector(new_length, zone); |
| 237 if (bits_ != NULL) new_bits->CopyFrom(*bits_); | 231 if (bits_ != NULL) new_bits->CopyFrom(*bits_); |
| 238 bits_ = new_bits; | 232 bits_ = new_bits; |
| 239 } | 233 } |
| 240 | 234 |
| 241 BitVector* bits_; | 235 BitVector* bits_; |
| 242 }; | 236 }; |
| 243 | 237 |
| 244 | 238 } // namespace internal |
| 245 } } // namespace v8::internal | 239 } // namespace v8 |
| 246 | |
| 247 | 240 |
| 248 #endif // V8_DATAFLOW_H_ | 241 #endif // V8_DATAFLOW_H_ |
| OLD | NEW |