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

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: 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..9f2df206d86e2bffb5893c17529187dbfe636371 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -8295,6 +8295,19 @@ Handle<WeakFixedArray> WeakFixedArray::Add(
}
+void WeakFixedArray::Compact() {
+ FixedArray* array = FixedArray::cast(this);
+ int w = 0;
ulan 2015/04/21 13:42:10 s/w/new_length/
+ for (int r = 0; r < array->length(); r++) {
+ Object* item = array->get(r);
+ if (item->IsSmi()) continue;
+ if (WeakCell::cast(item)->cleared()) continue;
+ array->set(w++, item);
+ }
+ array->Shrink(w);
+}
+
+
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