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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <iomanip> 5 #include <iomanip>
6 #include <sstream> 6 #include <sstream>
7 7
8 #include "src/v8.h" 8 #include "src/v8.h"
9 9
10 #include "src/accessors.h" 10 #include "src/accessors.h"
(...skipping 7838 matching lines...) Expand 10 before | Expand all | Expand 10 after
7849 UNREACHABLE(); 7849 UNREACHABLE();
7850 } 7850 }
7851 7851
7852 7852
7853 // static 7853 // static
7854 Handle<WeakFixedArray> WeakFixedArray::Allocate( 7854 Handle<WeakFixedArray> WeakFixedArray::Allocate(
7855 Isolate* isolate, int size, Handle<WeakFixedArray> initialize_from) { 7855 Isolate* isolate, int size, Handle<WeakFixedArray> initialize_from) {
7856 DCHECK(0 <= size); 7856 DCHECK(0 <= size);
7857 Handle<FixedArray> result = 7857 Handle<FixedArray> result =
7858 isolate->factory()->NewUninitializedFixedArray(size + kFirstIndex); 7858 isolate->factory()->NewUninitializedFixedArray(size + kFirstIndex);
7859 Handle<WeakFixedArray> casted_result = Handle<WeakFixedArray>::cast(result); 7859 int index = 0;
7860 if (initialize_from.is_null()) { 7860 if (!initialize_from.is_null()) {
7861 for (int i = 0; i < result->length(); ++i) {
7862 result->set(i, Smi::FromInt(0));
7863 }
7864 } else {
7865 DCHECK(initialize_from->Length() <= size); 7861 DCHECK(initialize_from->Length() <= size);
7866 Handle<FixedArray> raw_source = Handle<FixedArray>::cast(initialize_from); 7862 Handle<FixedArray> raw_source = Handle<FixedArray>::cast(initialize_from);
7867 int target_index = kFirstIndex; 7863 // Copy the entries without compacting, since the PrototypeInfo relies on
7868 for (int source_index = kFirstIndex; source_index < raw_source->length(); 7864 // the index of the entries not to change.
7869 ++source_index) { 7865 while (index < raw_source->length()) {
7870 // The act of allocating might have caused entries in the source array 7866 result->set(index, raw_source->get(index));
7871 // to be cleared. Copy only what's needed. 7867 index++;
7872 if (initialize_from->IsEmptySlot(source_index - kFirstIndex)) continue;
7873 result->set(target_index++, raw_source->get(source_index));
7874 }
7875 casted_result->set_last_used_index(target_index - 1 - kFirstIndex);
7876 for (; target_index < result->length(); ++target_index) {
7877 result->set(target_index, Smi::FromInt(0));
7878 } 7868 }
mvstanton 2015/08/19 13:52:12 How about calling set_last_used_index(index); here
7879 } 7869 }
7880 return casted_result; 7870 while (index < result->length()) {
7871 result->set(index, Smi::FromInt(0));
7872 index++;
7873 }
7874 return Handle<WeakFixedArray>::cast(result);
7881 } 7875 }
7882 7876
7883 7877
7884 Handle<ArrayList> ArrayList::Add(Handle<ArrayList> array, Handle<Object> obj, 7878 Handle<ArrayList> ArrayList::Add(Handle<ArrayList> array, Handle<Object> obj,
7885 AddMode mode) { 7879 AddMode mode) {
7886 int length = array->Length(); 7880 int length = array->Length();
7887 array = EnsureSpace(array, length + 1); 7881 array = EnsureSpace(array, length + 1);
7888 if (mode == kReloadLengthAfterAllocation) { 7882 if (mode == kReloadLengthAfterAllocation) {
7889 DCHECK(array->Length() <= length); 7883 DCHECK(array->Length() <= length);
7890 length = array->Length(); 7884 length = array->Length();
(...skipping 7826 matching lines...) Expand 10 before | Expand all | Expand 10 after
15717 if (cell->value() != *new_value) { 15711 if (cell->value() != *new_value) {
15718 cell->set_value(*new_value); 15712 cell->set_value(*new_value);
15719 Isolate* isolate = cell->GetIsolate(); 15713 Isolate* isolate = cell->GetIsolate();
15720 cell->dependent_code()->DeoptimizeDependentCodeGroup( 15714 cell->dependent_code()->DeoptimizeDependentCodeGroup(
15721 isolate, DependentCode::kPropertyCellChangedGroup); 15715 isolate, DependentCode::kPropertyCellChangedGroup);
15722 } 15716 }
15723 } 15717 }
15724 15718
15725 } // namespace internal 15719 } // namespace internal
15726 } // namespace v8 15720 } // namespace v8
OLDNEW
« 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