| 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);
|
| }
|
| }
|
|
|
|
|