| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/elements.h" | 5 #include "src/elements.h" |
| 6 | 6 |
| 7 #include "src/arguments.h" | 7 #include "src/arguments.h" |
| 8 #include "src/conversions.h" | 8 #include "src/conversions.h" |
| 9 #include "src/factory.h" | 9 #include "src/factory.h" |
| 10 #include "src/messages.h" | 10 #include "src/messages.h" |
| (...skipping 1217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1228 for (i = entry + 1; i < length; i++) { | 1228 for (i = entry + 1; i < length; i++) { |
| 1229 if (!backing_store->is_the_hole(i)) break; | 1229 if (!backing_store->is_the_hole(i)) break; |
| 1230 } | 1230 } |
| 1231 if (i == length) { | 1231 if (i == length) { |
| 1232 DeleteAtEnd(obj, backing_store, entry); | 1232 DeleteAtEnd(obj, backing_store, entry); |
| 1233 return; | 1233 return; |
| 1234 } | 1234 } |
| 1235 } | 1235 } |
| 1236 int num_used = 0; | 1236 int num_used = 0; |
| 1237 for (int i = 0; i < backing_store->length(); ++i) { | 1237 for (int i = 0; i < backing_store->length(); ++i) { |
| 1238 if (!backing_store->is_the_hole(i)) ++num_used; | 1238 if (!backing_store->is_the_hole(i)) { |
| 1239 // Bail out early if more than 1/4 is used. | 1239 ++num_used; |
| 1240 if (4 * num_used > backing_store->length()) break; | 1240 // Bail out if a number dictionary wouldn't be able to save at least |
| 1241 // 75% space. |
| 1242 if (4 * SeededNumberDictionary::ComputeCapacity(num_used) * |
| 1243 SeededNumberDictionary::kEntrySize > |
| 1244 backing_store->length()) { |
| 1245 return; |
| 1246 } |
| 1247 } |
| 1241 } | 1248 } |
| 1242 if (4 * num_used <= backing_store->length()) { | 1249 JSObject::NormalizeElements(obj); |
| 1243 JSObject::NormalizeElements(obj); | |
| 1244 } | |
| 1245 } | 1250 } |
| 1246 } | 1251 } |
| 1247 | 1252 |
| 1248 static void ReconfigureImpl(Handle<JSObject> object, | 1253 static void ReconfigureImpl(Handle<JSObject> object, |
| 1249 Handle<FixedArrayBase> store, uint32_t entry, | 1254 Handle<FixedArrayBase> store, uint32_t entry, |
| 1250 Handle<Object> value, | 1255 Handle<Object> value, |
| 1251 PropertyAttributes attributes) { | 1256 PropertyAttributes attributes) { |
| 1252 Handle<SeededNumberDictionary> dictionary = | 1257 Handle<SeededNumberDictionary> dictionary = |
| 1253 JSObject::NormalizeElements(object); | 1258 JSObject::NormalizeElements(object); |
| 1254 entry = dictionary->FindEntry(entry); | 1259 entry = dictionary->FindEntry(entry); |
| (...skipping 1127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2382 } | 2387 } |
| 2383 } | 2388 } |
| 2384 | 2389 |
| 2385 DCHECK(j == result_len); | 2390 DCHECK(j == result_len); |
| 2386 return result_array; | 2391 return result_array; |
| 2387 } | 2392 } |
| 2388 | 2393 |
| 2389 ElementsAccessor** ElementsAccessor::elements_accessors_ = NULL; | 2394 ElementsAccessor** ElementsAccessor::elements_accessors_ = NULL; |
| 2390 } // namespace internal | 2395 } // namespace internal |
| 2391 } // namespace v8 | 2396 } // namespace v8 |
| OLD | NEW |