Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(279)

Unified Diff: src/small-pointer-list.h

Issue 7778013: NewGC: Merge bleeding edge up to 9009. (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/gc/
Patch Set: Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/serialize.cc ('k') | src/spaces.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/small-pointer-list.h
===================================================================
--- src/small-pointer-list.h (revision 9006)
+++ src/small-pointer-list.h (working copy)
@@ -44,6 +44,31 @@
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 {
« no previous file with comments | « src/serialize.cc ('k') | src/spaces.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698