1// Copyright 2010 the V8 project authors. All rights reserved. 2// Use of this source code is governed by a BSD-style license that can be 3// found in the LICENSE file. 4 5#include "src/utils/bit-vector.h" 6 7#include "src/base/bits.h" 8#include "src/utils/utils.h" 9 10namespace v8 { 11namespace internal { 12 13#ifdef DEBUG 14void BitVector::Print() const { 15 bool first = true; 16 PrintF("{"); 17 for (int i = 0; i < length(); i++) { 18 if (Contains(i)) { 19 if (!first) PrintF(","); 20 first = false; 21 PrintF("%d", i); 22 } 23 } 24 PrintF("}\n"); 25} 26#endif 27 28int BitVector::Count() const { 29 if (is_inline()) return base::bits::CountPopulation(data_.inline_); 30 31 int count = 0; 32 for (int i = 0; i < data_length_; i++) { 33 count += base::bits::CountPopulation(data_.ptr_[i]); 34 } 35 return count; 36} 37 38} // namespace internal 39} // namespace v8 40