Commit 147299b9 authored by yangguo's avatar yangguo Committed by Commit bot

Do not compact weak fixed array when re-allocating new backing store.

JSObject::UnregisterPrototypeUser relies on the index of the weak
fixed array entry not to change.

See commit 1e65e201.

There is no bug currently, because we would only re-allocate if there is no empty slot left. In which case there is no actual compaction going on during re-allocation.

R=jkummerow@chromium.org, mvstanton@chromium.org

Review URL: https://codereview.chromium.org/1294883004

Cr-Commit-Position: refs/heads/master@{#30251}
parent fe432e1a
......@@ -7856,28 +7856,22 @@ Handle<WeakFixedArray> WeakFixedArray::Allocate(
DCHECK(0 <= size);
Handle<FixedArray> result =
isolate->factory()->NewUninitializedFixedArray(size + kFirstIndex);
Handle<WeakFixedArray> casted_result = Handle<WeakFixedArray>::cast(result);
if (initialize_from.is_null()) {
for (int i = 0; i < result->length(); ++i) {
result->set(i, Smi::FromInt(0));
}
} else {
int index = 0;
if (!initialize_from.is_null()) {
DCHECK(initialize_from->Length() <= size);
Handle<FixedArray> raw_source = Handle<FixedArray>::cast(initialize_from);
int target_index = kFirstIndex;
for (int source_index = kFirstIndex; source_index < raw_source->length();
++source_index) {
// The act of allocating might have caused entries in the source array
// to be cleared. Copy only what's needed.
if (initialize_from->IsEmptySlot(source_index - kFirstIndex)) continue;
result->set(target_index++, raw_source->get(source_index));
}
casted_result->set_last_used_index(target_index - 1 - kFirstIndex);
for (; target_index < result->length(); ++target_index) {
result->set(target_index, Smi::FromInt(0));
// Copy the entries without compacting, since the PrototypeInfo relies on
// the index of the entries not to change.
while (index < raw_source->length()) {
result->set(index, raw_source->get(index));
index++;
}
}
return casted_result;
while (index < result->length()) {
result->set(index, Smi::FromInt(0));
index++;
}
return Handle<WeakFixedArray>::cast(result);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment