Index: src/objects.cc |
diff --git a/src/objects.cc b/src/objects.cc |
index 2e5262dabba705325091588e296f3af882736c5d..d6aab60ac4c81943d9a9bf0ca92d6706f1b349d2 100644 |
--- a/src/objects.cc |
+++ b/src/objects.cc |
@@ -11786,7 +11786,7 @@ static bool GetOldValue(Isolate* isolate, |
void JSArray::SetLength(Handle<JSArray> array, uint32_t new_length) { |
// We should never end in here with a pixel or external array. |
DCHECK(array->AllowsSetLength()); |
- if (JSArray::SetLengthWouldNormalize(array->GetHeap(), new_length)) { |
+ if (array->SetLengthWouldNormalize(new_length)) { |
JSObject::NormalizeElements(array); |
} |
array->GetElementsAccessor()->SetLength(array, new_length); |
@@ -12519,6 +12519,16 @@ MaybeHandle<Object> JSObject::AddDataElement(Handle<JSObject> object, |
} |
+bool JSArray::SetLengthWouldNormalize(uint32_t new_length) { |
+ if (!HasFastElements()) return false; |
+ uint32_t capacity = static_cast<uint32_t>(elements()->length()); |
+ uint32_t new_capacity; |
+ return JSArray::SetLengthWouldNormalize(GetHeap(), new_length) && |
+ ShouldConvertToSlowElements(this, capacity, new_length - 1, |
+ &new_capacity); |
+} |
+ |
+ |
const double AllocationSite::kPretenureRatio = 0.85; |