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

Unified Diff: src/objects.cc

Issue 1099103003: Compact weak fixed arrays before serializing. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fi Created 5 years, 8 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/objects.h ('k') | src/snapshot/serialize.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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();
« no previous file with comments | « src/objects.h ('k') | src/snapshot/serialize.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698