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

Side by Side 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 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 unified diff | Download patch
« no previous file with comments | « no previous file | src/objects.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« 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