5#ifndef V8_UTILS_SPARSE_BIT_VECTOR_H_
6#define V8_UTILS_SPARSE_BIT_VECTOR_H_
34 return std::all_of(std::begin(
words), std::end(
words),
35 [](
auto segment) {
return segment == 0; });
54 if (segment->
words[word] == 0)
continue;
61 segment = segment->
next;
62 }
while (segment !=
nullptr);
86 uintptr_t remaining_bits =
88 (std::numeric_limits<uintptr_t>::max() << (1 + bit_in_word));
101 if (
segment_->words[word] == 0)
continue;
129 segment = segment->
next;
130 if (!segment)
return false;
132 if (segment->
offset >
i)
return false;
145 segment = segment->
next;
159 segment = segment->
next;
174 for (
const Segment* other_segment = &other.first_segment_; other_segment;
175 other_segment = other_segment->
next) {
177 while (segment && segment->
offset < other_segment->offset) {
179 segment = segment->
next;
183 if (segment && segment->
offset == other_segment->offset) {
184 std::transform(std::begin(segment->
words), std::end(segment->
words),
185 std::begin(other_segment->words),
186 std::begin(segment->
words), std::bit_or<uintptr_t>{});
187 }
else if (!other_segment->empty()) {
188 DCHECK_LT(last->offset, other_segment->offset);
190 new_segment->
offset = other_segment->offset;
191 std::copy(std::begin(other_segment->words),
192 std::end(other_segment->words),
193 std::begin(new_segment->
words));
208 int bit_in_segment =
i - segment->
offset;
230 return (segment->
words[word] >> bit) & 1;
235 return segment->
words[word] |= uintptr_t{1} << bit;
240 return segment->
words[word] &= ~(uintptr_t{1} << bit);
247 segment->
next = new_next;
bool operator!=(const Iterator &other) const
bool operator==(const Iterator &other) const
Iterator(const Segment *segment)
V8_NOINLINE void InsertBitAfter(Segment *segment, int i)
static void insert_after(Segment *segment, Segment *new_next)
V8_INLINE void Remove(int i)
SparseBitVector(Zone *zone)
V8_WARN_UNUSED_RESULT bool CheckConsistency(const Segment *segment)
void Union(const SparseBitVector &other)
static bool unset(Segment *segment, int i)
V8_INLINE bool Contains(int i) const
V8_INLINE void Add(int i)
static bool set(Segment *segment, int i)
MOVE_ONLY_NO_DEFAULT_CONSTRUCTOR(SparseBitVector)
static constexpr int kNumWordsPerSegment
static bool contains(const Segment *segment, int i)
static std::pair< int, int > GetWordAndBitInWord(const Segment *segment, int i)
V8_NOINLINE void InsertSegmentAfter(Segment *segment, Segment *new_segment)
static constexpr int kNumBitsPerSegment
static constexpr int kBitsPerWord
constexpr unsigned CountTrailingZeros(T value)
constexpr int kBitsPerByte
constexpr int kSystemPointerSize
#define DCHECK_LE(v1, v2)
#define DCHECK_NOT_NULL(val)
#define DCHECK_IMPLIES(v1, v2)
#define DCHECK(condition)
#define DCHECK_LT(v1, v2)
#define DCHECK_EQ(v1, v2)
#define DCHECK_GT(v1, v2)
uintptr_t words[kNumWordsPerSegment]
#define V8_WARN_UNUSED_RESULT
#define V8_UNLIKELY(condition)