diff --git a/src/objects-inl.h b/src/objects-inl.h index 59031d658c..d0f0f20660 100644 --- a/src/objects-inl.h +++ b/src/objects-inl.h @@ -8131,11 +8131,13 @@ void JSArray::set_length(Smi* length) { bool JSArray::SetLengthWouldNormalize(Heap* heap, uint32_t new_length) { + // This constant is somewhat arbitrary. Any large enough value would work. + const uint32_t kMaxFastArrayLength = 32 * 1024 * 1024; // 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. - uint32_t max_fast_array_size = + uint32_t heap_based_upper_bound = static_cast((heap->MaxOldGenerationSize() / kDoubleSize) / 4); - return new_length >= max_fast_array_size; + return new_length >= Min(kMaxFastArrayLength, heap_based_upper_bound); }