Index: runtime/vm/bit_set.h |
diff --git a/runtime/vm/bit_set.h b/runtime/vm/bit_set.h |
index 7fba930d90300bb0ceff278dd699f9503c604eb9..98cc631bfc1eef268731fb96a784b1894b237844 100644 |
--- a/runtime/vm/bit_set.h |
+++ b/runtime/vm/bit_set.h |
@@ -5,6 +5,7 @@ |
#ifndef VM_BIT_SET_H_ |
#define VM_BIT_SET_H_ |
+#include "platform/utils.h" |
#include "vm/globals.h" |
namespace dart { |
@@ -36,6 +37,23 @@ class BitSet { |
return (data_[i / kBitsPerWord] & mask) != 0; |
} |
+ intptr_t Next(intptr_t i) { |
+ ASSERT(i >= 0); |
+ ASSERT(i < N); |
+ intptr_t w = i / kBitsPerWord; |
+ uword mask = ~static_cast<uword>(0) << i; |
+ if ((data_[w] & mask) != 0) { |
+ uword tz = Utils::CountTrailingZeros(data_[w] & mask); |
+ return kBitsPerWord*w + tz; |
+ } |
+ while (++w < (1 + ((N - 1) / kBitsPerWord))) { |
+ if (data_[w] != 0) { |
+ return kBitsPerWord*w + Utils::CountTrailingZeros(data_[w]); |
+ } |
+ } |
+ return -1; |
+ } |
+ |
void Reset() { |
memset(data_, 0, sizeof(data_)); |
} |