Index: src/data-flow.h |
diff --git a/src/data-flow.h b/src/data-flow.h |
index 71f56e718b92861cfff2f3ad08814f2d39b7d39f..268f21e127e12629cec29aefafe73f91ee14b054 100644 |
--- a/src/data-flow.h |
+++ b/src/data-flow.h |
@@ -199,6 +199,40 @@ class BitVector: public ZoneObject { |
uint32_t* data_; |
}; |
+class GrowableBitVector BASE_EMBEDDED { |
+ public: |
+ GrowableBitVector() : bits_(NULL) { } |
+ |
+ bool Contains(int value) const { |
+ if (!InBitsRange(value)) return false; |
+ return bits_->Contains(value); |
+ } |
+ |
+ void Add(int value, Zone* zone) { |
+ EnsureCapacity(value, zone); |
+ bits_->Add(value); |
+ } |
+ |
+ private: |
+ static const int kInitialLength = 1024; |
+ |
+ bool InBitsRange(int value) const { |
+ return bits_ != NULL && bits_->length() > value; |
+ } |
+ |
+ void EnsureCapacity(int value, Zone* zone) { |
+ if (InBitsRange(value)) return; |
+ int new_length = bits_ == NULL ? kInitialLength : bits_->length(); |
+ while (new_length <= value) new_length *= 2; |
+ BitVector* new_bits = new(zone) BitVector(new_length, zone); |
+ if (bits_ != NULL) new_bits->CopyFrom(*bits_); |
+ bits_ = new_bits; |
+ } |
+ |
+ BitVector* bits_; |
+}; |
+ |
+ |
} } // namespace v8::internal |