Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 Loading... | |
| 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 |
| OLD | NEW |