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

Unified Diff: src/elements.cc

Issue 417953004: Revert 22595: "Keep new arrays allocated with 'new Array(N)' in fast mode" (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 5 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.cc » ('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 fc0f3b8f43ebfdb243d2dc58e2f093680a6ebbec..3ef6bfd0e1130920d885831d50a00b838173a13d 100644
--- a/src/elements.cc
+++ b/src/elements.cc
@@ -897,7 +897,8 @@ class FastElementsAccessor
typedef typename KindTraits::BackingStore BackingStore;
- // Adjusts the length of the fast backing store..
+ // Adjusts the length of the fast backing store or returns the new length or
+ // undefined in case conversion to a slow backing store should be performed.
static Handle<Object> SetLengthWithoutNormalize(
Handle<FixedArrayBase> backing_store,
Handle<JSArray> array,
@@ -949,10 +950,15 @@ class FastElementsAccessor
// Check whether the backing store should be expanded.
uint32_t min = JSObject::NewElementsCapacity(old_capacity);
uint32_t new_capacity = length > min ? length : min;
- FastElementsAccessorSubclass::SetFastElementsCapacityAndLength(
- array, new_capacity, length);
- JSObject::ValidateElements(array);
- return length_object;
+ if (!array->ShouldConvertToSlowElements(new_capacity)) {
+ FastElementsAccessorSubclass::SetFastElementsCapacityAndLength(
+ array, new_capacity, length);
+ JSObject::ValidateElements(array);
+ return length_object;
+ }
+
+ // Request conversion to slow elements.
+ return isolate->factory()->undefined_value();
}
static Handle<Object> DeleteCommon(Handle<JSObject> obj,
« 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