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

Unified Diff: src/objects.cc

Issue 1294883004: Do not compact weak fixed array when re-allocating new backing store. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 4 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/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++;
}
mvstanton 2015/08/19 13:52:12 How about calling set_last_used_index(index); here
}
- return casted_result;
+ while (index < result->length()) {
+ result->set(index, Smi::FromInt(0));
+ index++;
+ }
+ return Handle<WeakFixedArray>::cast(result);
}
« 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