Reviewers: Jakob, mvstanton,
Description:
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 1e65e2018.
[email protected], [email protected]
Please review this at https://codereview.chromium.org/1294883004/
Base URL: https://chromium.googlesource.com/v8/v8.git@master
Affected files (+12, -18 lines):
M src/objects.cc
Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index
1f25a5d11b7dcd788a6541e41781eb98e826f6b7..ed394ad0ca8c79c75cd6f964c151e111afaef537
100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -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);
}
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.