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

Unified Diff: src/objects.cc

Issue 1211833002: Back off normalizing on set length in sync with adding a property (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 | « src/objects.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
« no previous file with comments | « src/objects.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698