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

Side by Side Diff: src/objects.cc

Issue 1099103003: Compact weak fixed arrays before serializing. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 8 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 | « src/objects.h ('k') | src/snapshot/serialize.cc » ('j') | 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 8277 matching lines...) Expand 10 before | Expand all | Expand 10 after
8288 Handle<WeakFixedArray> new_array = 8288 Handle<WeakFixedArray> new_array =
8289 Allocate(array->GetIsolate(), new_length, array); 8289 Allocate(array->GetIsolate(), new_length, array);
8290 if (FLAG_trace_weak_arrays) { 8290 if (FLAG_trace_weak_arrays) {
8291 PrintF("[WeakFixedArray: growing to size %d ]\n", new_length); 8291 PrintF("[WeakFixedArray: growing to size %d ]\n", new_length);
8292 } 8292 }
8293 WeakFixedArray::Set(new_array, array->Length(), value); 8293 WeakFixedArray::Set(new_array, array->Length(), value);
8294 return new_array; 8294 return new_array;
8295 } 8295 }
8296 8296
8297 8297
8298 void WeakFixedArray::Compact() {
8299 FixedArray* array = FixedArray::cast(this);
8300 int w = 0;
ulan 2015/04/21 13:42:10 s/w/new_length/
8301 for (int r = 0; r < array->length(); r++) {
8302 Object* item = array->get(r);
8303 if (item->IsSmi()) continue;
8304 if (WeakCell::cast(item)->cleared()) continue;
8305 array->set(w++, item);
8306 }
8307 array->Shrink(w);
8308 }
8309
8310
8298 void WeakFixedArray::Remove(Handle<HeapObject> value) { 8311 void WeakFixedArray::Remove(Handle<HeapObject> value) {
8299 // Optimize for the most recently added element to be removed again. 8312 // Optimize for the most recently added element to be removed again.
8300 int first_index = last_used_index(); 8313 int first_index = last_used_index();
8301 for (int i = first_index;;) { 8314 for (int i = first_index;;) {
8302 if (Get(i) == *value) { 8315 if (Get(i) == *value) {
8303 clear(i); 8316 clear(i);
8304 // Users of WeakFixedArray should make sure that there are no duplicates, 8317 // Users of WeakFixedArray should make sure that there are no duplicates,
8305 // they can use Add(..., kAddIfNotFound) if necessary. 8318 // they can use Add(..., kAddIfNotFound) if necessary.
8306 return; 8319 return;
8307 } 8320 }
(...skipping 8782 matching lines...) Expand 10 before | Expand all | Expand 10 after
17090 if (!invalidate && old_type == PropertyCellType::kConstant && 17103 if (!invalidate && old_type == PropertyCellType::kConstant &&
17091 new_type != PropertyCellType::kConstant) { 17104 new_type != PropertyCellType::kConstant) {
17092 auto isolate = dictionary->GetIsolate(); 17105 auto isolate = dictionary->GetIsolate();
17093 cell->dependent_code()->DeoptimizeDependentCodeGroup( 17106 cell->dependent_code()->DeoptimizeDependentCodeGroup(
17094 isolate, DependentCode::kPropertyCellChangedGroup); 17107 isolate, DependentCode::kPropertyCellChangedGroup);
17095 } 17108 }
17096 return value; 17109 return value;
17097 } 17110 }
17098 17111
17099 } } // namespace v8::internal 17112 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects.h ('k') | src/snapshot/serialize.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698