| 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 1209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1220 for (i = entry + 1; i < length; i++) { | 1220 for (i = entry + 1; i < length; i++) { |
| 1221 if (!backing_store->is_the_hole(i)) break; | 1221 if (!backing_store->is_the_hole(i)) break; |
| 1222 } | 1222 } |
| 1223 if (i == length) { | 1223 if (i == length) { |
| 1224 DeleteAtEnd(obj, backing_store, entry); | 1224 DeleteAtEnd(obj, backing_store, entry); |
| 1225 return; | 1225 return; |
| 1226 } | 1226 } |
| 1227 } | 1227 } |
| 1228 int num_used = 0; | 1228 int num_used = 0; |
| 1229 for (int i = 0; i < backing_store->length(); ++i) { | 1229 for (int i = 0; i < backing_store->length(); ++i) { |
| 1230 if (!backing_store->is_the_hole(i)) ++num_used; | 1230 if (!backing_store->is_the_hole(i)) { |
| 1231 // Bail out early if more than 1/4 is used. | 1231 ++num_used; |
| 1232 if (4 * num_used > backing_store->length()) break; | 1232 // Bail out if a number dictionary wouldn't be able to save at least |
| 1233 // 75% space. |
| 1234 if (4 * SeededNumberDictionary::ComputeCapacity(num_used) * |
| 1235 SeededNumberDictionary::kEntrySize > |
| 1236 backing_store->length()) { |
| 1237 return; |
| 1238 } |
| 1239 } |
| 1233 } | 1240 } |
| 1234 if (4 * num_used <= backing_store->length()) { | 1241 JSObject::NormalizeElements(obj); |
| 1235 JSObject::NormalizeElements(obj); | |
| 1236 } | |
| 1237 } | 1242 } |
| 1238 } | 1243 } |
| 1239 | 1244 |
| 1240 static void ReconfigureImpl(Handle<JSObject> object, | 1245 static void ReconfigureImpl(Handle<JSObject> object, |
| 1241 Handle<FixedArrayBase> store, uint32_t entry, | 1246 Handle<FixedArrayBase> store, uint32_t entry, |
| 1242 Handle<Object> value, | 1247 Handle<Object> value, |
| 1243 PropertyAttributes attributes) { | 1248 PropertyAttributes attributes) { |
| 1244 Handle<SeededNumberDictionary> dictionary = | 1249 Handle<SeededNumberDictionary> dictionary = |
| 1245 JSObject::NormalizeElements(object); | 1250 JSObject::NormalizeElements(object); |
| 1246 entry = dictionary->FindEntry(entry); | 1251 entry = dictionary->FindEntry(entry); |
| (...skipping 1127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2374 } | 2379 } |
| 2375 } | 2380 } |
| 2376 | 2381 |
| 2377 DCHECK(j == result_len); | 2382 DCHECK(j == result_len); |
| 2378 return result_array; | 2383 return result_array; |
| 2379 } | 2384 } |
| 2380 | 2385 |
| 2381 ElementsAccessor** ElementsAccessor::elements_accessors_ = NULL; | 2386 ElementsAccessor** ElementsAccessor::elements_accessors_ = NULL; |
| 2382 } // namespace internal | 2387 } // namespace internal |
| 2383 } // namespace v8 | 2388 } // namespace v8 |
| OLD | NEW |