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

Unified Diff: src/elements.cc

Issue 1472293002: Make sure that NormalizeElements and ShouldConvertToFastElements are based on the same values (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 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
« no previous file with comments | « no previous file | src/objects.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/elements.cc
diff --git a/src/elements.cc b/src/elements.cc
index 4494583aa43c0c58b7214467ceab7b981bb8fcb5..951df7983cf0d6f8fdf109d6b184700d36e864ca 100644
--- a/src/elements.cc
+++ b/src/elements.cc
@@ -1227,13 +1227,18 @@ class FastElementsAccessor
}
int num_used = 0;
for (int i = 0; i < backing_store->length(); ++i) {
- if (!backing_store->is_the_hole(i)) ++num_used;
- // Bail out early if more than 1/4 is used.
- if (4 * num_used > backing_store->length()) break;
- }
- if (4 * num_used <= backing_store->length()) {
- JSObject::NormalizeElements(obj);
+ if (!backing_store->is_the_hole(i)) {
+ ++num_used;
+ // Bail out if a number dictionary wouldn't be able to save at least
+ // 75% space.
+ if (4 * SeededNumberDictionary::ComputeCapacity(num_used) *
+ SeededNumberDictionary::kEntrySize >
+ backing_store->length()) {
+ return;
+ }
+ }
}
+ JSObject::NormalizeElements(obj);
}
}
« no previous file with comments | « no previous file | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698