Index: src/interpreter/constant-array-builder.cc |
diff --git a/src/interpreter/constant-array-builder.cc b/src/interpreter/constant-array-builder.cc |
index eeae0dae71dadabd2aa826b67a384f7e35c0dd76..6fd141e9119cb1d2eb228533ce30d7072eb4a45f 100644 |
--- a/src/interpreter/constant-array-builder.cc |
+++ b/src/interpreter/constant-array-builder.cc |
@@ -132,13 +132,10 @@ Handle<FixedArray> ConstantArrayBuilder::ToFixedArray(Isolate* isolate) { |
handle(reserved_smi.first, isolate)); |
} |
- Handle<FixedArray> fixed_array = isolate->factory()->NewFixedArray( |
+ Handle<FixedArray> fixed_array = isolate->factory()->NewFixedArrayWithHoles( |
static_cast<int>(size()), PretenureFlag::TENURED); |
int array_index = 0; |
for (const ConstantArraySlice* slice : idx_slice_) { |
- if (array_index == fixed_array->length()) { |
- break; |
- } |
DCHECK(array_index == 0 || |
base::bits::IsPowerOfTwo32(static_cast<uint32_t>(array_index))); |
#if DEBUG |
@@ -151,15 +148,14 @@ Handle<FixedArray> ConstantArrayBuilder::ToFixedArray(Isolate* isolate) { |
for (size_t i = 0; i < slice->size(); ++i) { |
fixed_array->set(array_index++, *slice->At(slice->start_index() + i)); |
} |
- // Insert holes where reservations led to unused slots. |
- size_t padding = |
- std::min(static_cast<size_t>(fixed_array->length() - array_index), |
- slice->capacity() - slice->size()); |
- for (size_t i = 0; i < padding; i++) { |
- fixed_array->set(array_index++, *the_hole_value()); |
+ // Leave holes where reservations led to unused slots. |
+ size_t padding = slice->capacity() - slice->size(); |
+ if (static_cast<size_t>(fixed_array->length() - array_index) <= padding) { |
+ break; |
} |
+ array_index += padding; |
} |
- DCHECK_EQ(array_index, fixed_array->length()); |
+ DCHECK_GE(array_index, fixed_array->length()); |
return fixed_array; |
} |