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

Unified Diff: src/objects-inl.h

Issue 409007: Some optimizations for packer.js. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 years, 1 month 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-inl.h
===================================================================
--- src/objects-inl.h (revision 3335)
+++ src/objects-inl.h (working copy)
@@ -3103,8 +3103,18 @@
void JSArray::EnsureSize(int required_size) {
ASSERT(HasFastElements());
- if (elements()->length() >= required_size) return;
- Expand(required_size);
+ Array* elts = elements();
+ if (elts->length() < required_size) {
+ // Doubling in size would be overkill, but leave some slack to avoid
+ // constantly growing.
+ Expand(required_size + (required_size >> 3));
+ } else if (!Heap::new_space()->Contains(elts)) {
+ // It's a performance benefit to keep a frequently used array in new-space.
+ const int kArraySizeThatFitsComfortablyInNewSpace = 128;
Søren Thygesen Gjesse 2009/11/19 21:42:57 This does not take the calculation required_size +
Erik Corry 2009/11/20 10:12:46 Since it's a number I pulled out of my backside I
+ if (required_size < kArraySizeThatFitsComfortablyInNewSpace) {
Søren Thygesen Gjesse 2009/11/19 21:42:57 Maybe combine these two if's into one if condition
Erik Corry 2009/11/20 10:12:46 Done.
+ Expand(required_size);
+ }
+ }
}

Powered by Google App Engine
This is Rietveld 408576698