Index: src/small-pointer-list.h |
diff --git a/src/small-pointer-list.h b/src/small-pointer-list.h |
index 6291d9ee8628d08492dc53ce30628b25066dfead..6c5ce890d2cb64fe8c437bf99c96efb144786357 100644 |
--- a/src/small-pointer-list.h |
+++ b/src/small-pointer-list.h |
@@ -44,6 +44,31 @@ class SmallPointerList { |
public: |
SmallPointerList() : data_(kEmptyTag) {} |
+ explicit SmallPointerList(int capacity) : data_(kEmptyTag) { |
+ Reserve(capacity); |
+ } |
+ |
+ void Reserve(int capacity) { |
+ if (capacity < 2) return; |
+ if ((data_ & kTagMask) == kListTag) { |
+ if (list()->capacity() >= capacity) return; |
+ int old_length = list()->length(); |
+ list()->AddBlock(NULL, capacity - list()->capacity()); |
+ list()->Rewind(old_length); |
+ return; |
+ } |
+ PointerList* list = new PointerList(capacity); |
+ if ((data_ & kTagMask) == kSingletonTag) { |
+ list->Add(single_value()); |
+ } |
+ ASSERT(IsAligned(reinterpret_cast<intptr_t>(list), kPointerAlignment)); |
+ data_ = reinterpret_cast<intptr_t>(list) | kListTag; |
+ } |
+ |
+ void Clear() { |
+ data_ = kEmptyTag; |
+ } |
+ |
bool is_empty() const { return length() == 0; } |
int length() const { |