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

Unified Diff: src/elements.cc

Issue 1196163005: Cleanup adding elements and in particular dictionary elements (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 6 months 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.h » ('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 59e5ab1dbc51beb83b1cc8157a447452f2b77ea9..ea368847e0eed25886e45da00376ad2c6f3d762d 100644
--- a/src/elements.cc
+++ b/src/elements.cc
@@ -989,11 +989,12 @@ class FastElementsAccessor
if (length == 0) return; // nothing to do!
DisallowHeapAllocation no_gc;
Handle<BackingStore> backing_store = Handle<BackingStore>::cast(elements);
- for (int i = 0; i < length; i++) {
- DCHECK((!IsFastSmiElementsKind(KindTraits::Kind) ||
- BackingStore::get(backing_store, i)->IsSmi()) ||
- (IsFastHoleyElementsKind(KindTraits::Kind) ==
- backing_store->is_the_hole(i)));
+ if (IsFastSmiElementsKind(KindTraits::Kind)) {
+ for (int i = 0; i < length; i++) {
+ DCHECK(BackingStore::get(backing_store, i)->IsSmi() ||
+ (IsFastHoleyElementsKind(KindTraits::Kind) &&
+ backing_store->is_the_hole(i)));
+ }
}
#endif
}
@@ -1345,12 +1346,8 @@ class DictionaryElementsAccessor
dict->ElementsRemoved(removed_entries);
}
- if (length <= Smi::kMaxValue) {
- array->set_length(Smi::FromInt(length));
- } else {
- Handle<Object> length_obj = isolate->factory()->NewNumberFromUint(length);
- array->set_length(*length_obj);
- }
+ Handle<Object> length_obj = isolate->factory()->NewNumberFromUint(length);
+ array->set_length(*length_obj);
}
static void DeleteCommon(Handle<JSObject> obj, uint32_t key,
« no previous file with comments | « no previous file | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698