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

Unified Diff: src/objects-inl.h

Issue 1086873003: Array() in optimized code can create with wrong ElementsKind in corner cases. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Address comments and test failure. Created 5 years, 8 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.cc ('k') | src/runtime/runtime-array.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/objects-inl.h
diff --git a/src/objects-inl.h b/src/objects-inl.h
index e5e8235c292a15049f7afffd4ca0d0b9b9eb85fb..f284f65d34efaa93b7efaedaf5d1c7d93cc84c9e 100644
--- a/src/objects-inl.h
+++ b/src/objects-inl.h
@@ -7201,6 +7201,17 @@ void JSArray::set_length(Smi* length) {
}
+bool JSArray::SetElementsLengthWouldNormalize(
+ Heap* heap, Handle<Object> new_length_handle) {
+ // If the new array won't fit in a some non-trivial fraction of the max old
+ // space size, then force it to go dictionary mode.
+ int max_fast_array_size =
+ static_cast<int>((heap->MaxOldGenerationSize() / kDoubleSize) / 4);
+ return new_length_handle->IsNumber() &&
+ NumberToInt32(*new_length_handle) >= max_fast_array_size;
+}
+
+
bool JSArray::AllowsSetElementsLength() {
bool result = elements()->IsFixedArray() || elements()->IsFixedDoubleArray();
DCHECK(result == !HasExternalArrayElements());
« no previous file with comments | « src/objects.cc ('k') | src/runtime/runtime-array.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698