Index: src/interpreter/constant-array-builder.cc |
diff --git a/src/interpreter/constant-array-builder.cc b/src/interpreter/constant-array-builder.cc |
index 7ce50b580e998e0f170f6c8bd29eb237627f1ffd..1643e4c6a8171dc90905e56a5d67d586bfe6709f 100644 |
--- a/src/interpreter/constant-array-builder.cc |
+++ b/src/interpreter/constant-array-builder.cc |
@@ -46,6 +46,13 @@ Handle<Object> ConstantArrayBuilder::ConstantArraySlice::At( |
return constants_[index - start_index()]; |
} |
+void ConstantArrayBuilder::ConstantArraySlice::InsertAt(size_t index, |
+ Handle<Object> object) { |
+ DCHECK_GE(index, start_index()); |
+ DCHECK_LT(index, start_index() + size()); |
+ constants_[index - start_index()] = object; |
+} |
+ |
STATIC_CONST_MEMBER_DEFINITION const size_t ConstantArrayBuilder::k8BitCapacity; |
STATIC_CONST_MEMBER_DEFINITION const size_t |
ConstantArrayBuilder::k16BitCapacity; |
@@ -73,9 +80,9 @@ size_t ConstantArrayBuilder::size() const { |
return idx_slice_[0]->size(); |
} |
-const ConstantArrayBuilder::ConstantArraySlice* |
-ConstantArrayBuilder::IndexToSlice(size_t index) const { |
- for (const ConstantArraySlice* slice : idx_slice_) { |
+ConstantArrayBuilder::ConstantArraySlice* ConstantArrayBuilder::IndexToSlice( |
+ size_t index) const { |
+ for (ConstantArraySlice* slice : idx_slice_) { |
if (index <= slice->max_index()) { |
return slice; |
} |
@@ -129,28 +136,21 @@ size_t ConstantArrayBuilder::Insert(Handle<Object> object) { |
ConstantArrayBuilder::index_t ConstantArrayBuilder::AllocateEntry( |
Handle<Object> object) { |
DCHECK(!object->IsOddball()); |
+ index_t index = AllocateIndex(object); |
index_t* entry = constants_map()->Get(object); |
- for (size_t i = 0; i < arraysize(idx_slice_); ++i) { |
- if (idx_slice_[i]->available() > 0) { |
- size_t index = idx_slice_[i]->Allocate(object); |
- *entry = static_cast<index_t>(index); |
- return *entry; |
- break; |
- } |
- } |
- UNREACHABLE(); |
- return kMaxUInt32; |
+ *entry = index; |
+ return index; |
} |
-OperandSize ConstantArrayBuilder::CreateReservedEntry() { |
+ConstantArrayBuilder::index_t ConstantArrayBuilder::AllocateIndex( |
+ Handle<Object> object) { |
for (size_t i = 0; i < arraysize(idx_slice_); ++i) { |
if (idx_slice_[i]->available() > 0) { |
- idx_slice_[i]->Reserve(); |
- return idx_slice_[i]->operand_size(); |
+ return static_cast<index_t>(idx_slice_[i]->Allocate(object)); |
} |
} |
UNREACHABLE(); |
- return OperandSize::kNone; |
+ return kMaxUInt32; |
} |
ConstantArrayBuilder::ConstantArraySlice* |
@@ -174,6 +174,28 @@ ConstantArrayBuilder::OperandSizeToSlice(OperandSize operand_size) const { |
return slice; |
} |
+size_t ConstantArrayBuilder::AllocateEntry() { |
+ return AllocateIndex(isolate_->factory()->the_hole_value()); |
+} |
+ |
+void ConstantArrayBuilder::InsertAllocatedEntry(size_t index, |
+ Handle<Object> object) { |
+ DCHECK_EQ(isolate_->heap()->the_hole_value(), *At(index)); |
+ ConstantArraySlice* slice = IndexToSlice(index); |
+ slice->InsertAt(index, object); |
+} |
+ |
+OperandSize ConstantArrayBuilder::CreateReservedEntry() { |
+ for (size_t i = 0; i < arraysize(idx_slice_); ++i) { |
+ if (idx_slice_[i]->available() > 0) { |
+ idx_slice_[i]->Reserve(); |
+ return idx_slice_[i]->operand_size(); |
+ } |
+ } |
+ UNREACHABLE(); |
+ return OperandSize::kNone; |
+} |
+ |
size_t ConstantArrayBuilder::CommitReservedEntry(OperandSize operand_size, |
Handle<Object> object) { |
DiscardReservedEntry(operand_size); |