Index: src/objects.cc |
diff --git a/src/objects.cc b/src/objects.cc |
index f57c569d09b36bf08bcdab3288dd552b85b960c6..c3fb054d6c6fe66155526cd5a87bdd9130a385fc 100644 |
--- a/src/objects.cc |
+++ b/src/objects.cc |
@@ -8295,6 +8295,20 @@ Handle<WeakFixedArray> WeakFixedArray::Add( |
} |
+void WeakFixedArray::Compact() { |
+ FixedArray* array = FixedArray::cast(this); |
+ int new_length = kFirstIndex; |
+ for (int i = kFirstIndex; i < array->length(); i++) { |
+ Object* element = array->get(i); |
+ if (element->IsSmi()) continue; |
+ if (WeakCell::cast(element)->cleared()) continue; |
+ array->set(new_length++, element); |
+ } |
+ array->Shrink(new_length); |
+ set_last_used_index(0); |
+} |
+ |
+ |
void WeakFixedArray::Remove(Handle<HeapObject> value) { |
// Optimize for the most recently added element to be removed again. |
int first_index = last_used_index(); |