v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
bit-vector.cc
Go to the documentation of this file.
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
6
7#include <numeric>
8
9#include "src/base/bits.h"
10#include "src/utils/utils.h"
11
12namespace v8 {
13namespace internal {
14
15#ifdef DEBUG
16void BitVector::Print() const {
17 bool first = true;
18 PrintF("{");
19 for (int i = 0; i < length(); i++) {
20 if (Contains(i)) {
21 if (!first) PrintF(",");
22 first = false;
23 PrintF("%d", i);
24 }
25 }
26 PrintF("}\n");
27}
28#endif
29
30int BitVector::Count() const {
31 auto accumulate_popcnt = [](int cnt, uintptr_t word) -> int {
33 };
34 return std::accumulate(data_begin_, data_end_, 0, accumulate_popcnt);
35}
36
37} // namespace internal
38} // namespace v8
bool Contains(int i) const
Definition bit-vector.h:180
static V8_INLINE int word(int index)
Definition bit-vector.h:278
constexpr unsigned CountPopulation(T value)
Definition bits.h:26
void PrintF(const char *format,...)
Definition utils.cc:39