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

Unified Diff: src/objects.cc

Issue 43075: * Reapply revisions 1383, 1384, 1391, 1398, 1401, 1402,... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 years, 9 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
Index: src/objects.cc
===================================================================
--- src/objects.cc (revision 1489)
+++ src/objects.cc (working copy)
@@ -4888,6 +4888,22 @@
}
+void JSArray::EnsureSize(int required_size) {
+ Handle<JSArray> self(this);
+ ASSERT(HasFastElements());
+ if (elements()->length() >= required_size) return;
+ Handle<FixedArray> old_backing(elements());
+ int old_size = old_backing->length();
+ // Doubling in size would be overkill, but leave some slack to avoid
+ // constantly growing.
+ int new_size = required_size + (required_size >> 3);
+ Handle<FixedArray> new_backing = Factory::NewFixedArray(new_size);
+ // Can't use this any more now because we may have had a GC!
+ for (int i = 0; i < old_size; i++) new_backing->set(i, old_backing->get(i));
+ self->SetContent(*new_backing);
+}
+
+
// Computes the new capacity when expanding the elements of a JSObject.
static int NewElementsCapacity(int old_capacity) {
// (old_capacity + 50%) + 16

Powered by Google App Engine
This is Rietveld 408576698