Index: src/interpreter/constant-array-builder.cc |
diff --git a/src/interpreter/constant-array-builder.cc b/src/interpreter/constant-array-builder.cc |
index d2b799562383dd87c5210509bff00061436d6573..ba79a5b00a12313b14e0aea48262c4b59dcdc0da 100644 |
--- a/src/interpreter/constant-array-builder.cc |
+++ b/src/interpreter/constant-array-builder.cc |
@@ -126,13 +126,12 @@ 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; |
- } |
+ if (array_index >= fixed_array->length()) break; |
+ |
DCHECK(array_index == 0 || |
base::bits::IsPowerOfTwo32(static_cast<uint32_t>(array_index))); |
// Different slices might contain the same element due to reservations, but |
@@ -143,15 +142,9 @@ 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. |
+ array_index += slice->capacity() - slice->size(); |
} |
- DCHECK_EQ(array_index, fixed_array->length()); |
Leszek Swirski
2016/12/16 16:50:54
I would keep this check, as a DCHECK_GE
|
return fixed_array; |
} |