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

Unified Diff: src/elements.cc

Issue 1209983002: Only try to delete dictionary elements if the length is actually reduced (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 | no next file » | 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 751a292cfa074e34cf2bda1bfd2666ac1215d1e6..1f1cd5696ab7153e6bd40cbee1f753df97d92ac8 100644
--- a/src/elements.cc
+++ b/src/elements.cc
@@ -1372,43 +1372,45 @@ class DictionaryElementsAccessor
int capacity = dict->Capacity();
uint32_t old_length = 0;
CHECK(array->length()->ToArrayLength(&old_length));
- if (dict->requires_slow_elements() && length < old_length) {
- // Find last non-deletable element in range of elements to be
- // deleted and adjust range accordingly.
- for (int i = 0; i < capacity; i++) {
- DisallowHeapAllocation no_gc;
- Object* key = dict->KeyAt(i);
- if (key->IsNumber()) {
- uint32_t number = static_cast<uint32_t>(key->Number());
- if (length <= number && number < old_length) {
- PropertyDetails details = dict->DetailsAt(i);
- if (!details.IsConfigurable()) length = number + 1;
+ if (length < old_length) {
+ if (dict->requires_slow_elements()) {
+ // Find last non-deletable element in range of elements to be
+ // deleted and adjust range accordingly.
+ for (int i = 0; i < capacity; i++) {
+ DisallowHeapAllocation no_gc;
+ Object* key = dict->KeyAt(i);
+ if (key->IsNumber()) {
+ uint32_t number = static_cast<uint32_t>(key->Number());
+ if (length <= number && number < old_length) {
+ PropertyDetails details = dict->DetailsAt(i);
+ if (!details.IsConfigurable()) length = number + 1;
+ }
}
}
}
- }
- if (length == 0) {
- // Flush the backing store.
- JSObject::ResetElements(array);
- } else {
- DisallowHeapAllocation no_gc;
- // Remove elements that should be deleted.
- int removed_entries = 0;
- Handle<Object> the_hole_value = isolate->factory()->the_hole_value();
- for (int i = 0; i < capacity; i++) {
- Object* key = dict->KeyAt(i);
- if (key->IsNumber()) {
- uint32_t number = static_cast<uint32_t>(key->Number());
- if (length <= number && number < old_length) {
- dict->SetEntry(i, the_hole_value, the_hole_value);
- removed_entries++;
+ if (length == 0) {
+ // Flush the backing store.
+ JSObject::ResetElements(array);
+ } else {
+ DisallowHeapAllocation no_gc;
+ // Remove elements that should be deleted.
+ int removed_entries = 0;
+ Handle<Object> the_hole_value = isolate->factory()->the_hole_value();
+ for (int i = 0; i < capacity; i++) {
+ Object* key = dict->KeyAt(i);
+ if (key->IsNumber()) {
+ uint32_t number = static_cast<uint32_t>(key->Number());
+ if (length <= number && number < old_length) {
+ dict->SetEntry(i, the_hole_value, the_hole_value);
+ removed_entries++;
+ }
}
}
- }
- // Update the number of elements.
- dict->ElementsRemoved(removed_entries);
+ // Update the number of elements.
+ dict->ElementsRemoved(removed_entries);
+ }
}
Handle<Object> length_obj = isolate->factory()->NewNumberFromUint(length);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698