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

Unified Diff: src/interpreter/constant-array-builder.cc

Issue 2586513002: [ignition] Prefill the constant array with holes to avoid needing to write padding holes (Closed)
Patch Set: rebase Created 3 years, 11 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698