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

Side by Side Diff: src/elements.cc

Issue 335553004: Keep maps when resetting elements. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: simplified as suggested Created 6 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 unified diff | Download patch | Annotate | Revision Log
« 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/v8.h" 5 #include "src/v8.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/elements.h" 9 #include "src/elements.h"
10 #include "src/objects.h" 10 #include "src/objects.h"
(...skipping 1418 matching lines...) Expand 10 before | Expand all | Expand 10 after
1429 if (details.IsDontDelete()) new_length = number + 1; 1429 if (details.IsDontDelete()) new_length = number + 1;
1430 } 1430 }
1431 } 1431 }
1432 } 1432 }
1433 if (new_length != length) { 1433 if (new_length != length) {
1434 length_object = isolate->factory()->NewNumberFromUint(new_length); 1434 length_object = isolate->factory()->NewNumberFromUint(new_length);
1435 } 1435 }
1436 } 1436 }
1437 1437
1438 if (new_length == 0) { 1438 if (new_length == 0) {
1439 // If the length of a slow array is reset to zero, we clear 1439 // Flush the backing store.
1440 // the array and flush backing storage. This has the added
1441 // benefit that the array returns to fast mode.
1442 JSObject::ResetElements(array); 1440 JSObject::ResetElements(array);
1443 } else { 1441 } else {
1444 DisallowHeapAllocation no_gc; 1442 DisallowHeapAllocation no_gc;
1445 // Remove elements that should be deleted. 1443 // Remove elements that should be deleted.
1446 int removed_entries = 0; 1444 int removed_entries = 0;
1447 Handle<Object> the_hole_value = isolate->factory()->the_hole_value(); 1445 Handle<Object> the_hole_value = isolate->factory()->the_hole_value();
1448 for (int i = 0; i < capacity; i++) { 1446 for (int i = 0; i < capacity; i++) {
1449 Object* key = dict->KeyAt(i); 1447 Object* key = dict->KeyAt(i);
1450 if (key->IsNumber()) { 1448 if (key->IsNumber()) {
1451 uint32_t number = static_cast<uint32_t>(key->Number()); 1449 uint32_t number = static_cast<uint32_t>(key->Number());
(...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after
1992 UNREACHABLE(); 1990 UNREACHABLE();
1993 break; 1991 break;
1994 } 1992 }
1995 1993
1996 array->set_elements(*elms); 1994 array->set_elements(*elms);
1997 array->set_length(Smi::FromInt(number_of_elements)); 1995 array->set_length(Smi::FromInt(number_of_elements));
1998 return array; 1996 return array;
1999 } 1997 }
2000 1998
2001 } } // namespace v8::internal 1999 } } // namespace v8::internal
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