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 new_length = kFirstIndex; |
| 8301 for (int i = kFirstIndex; i < array->length(); i++) { |
| 8302 Object* element = array->get(i); |
| 8303 if (element->IsSmi()) continue; |
| 8304 if (WeakCell::cast(element)->cleared()) continue; |
| 8305 array->set(new_length++, element); |
| 8306 } |
| 8307 array->Shrink(new_length); |
| 8308 set_last_used_index(0); |
| 8309 } |
| 8310 |
| 8311 |
8298 void WeakFixedArray::Remove(Handle<HeapObject> value) { | 8312 void WeakFixedArray::Remove(Handle<HeapObject> value) { |
8299 // Optimize for the most recently added element to be removed again. | 8313 // Optimize for the most recently added element to be removed again. |
8300 int first_index = last_used_index(); | 8314 int first_index = last_used_index(); |
8301 for (int i = first_index;;) { | 8315 for (int i = first_index;;) { |
8302 if (Get(i) == *value) { | 8316 if (Get(i) == *value) { |
8303 clear(i); | 8317 clear(i); |
8304 // Users of WeakFixedArray should make sure that there are no duplicates, | 8318 // Users of WeakFixedArray should make sure that there are no duplicates, |
8305 // they can use Add(..., kAddIfNotFound) if necessary. | 8319 // they can use Add(..., kAddIfNotFound) if necessary. |
8306 return; | 8320 return; |
8307 } | 8321 } |
(...skipping 8782 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
17090 if (!invalidate && old_type == PropertyCellType::kConstant && | 17104 if (!invalidate && old_type == PropertyCellType::kConstant && |
17091 new_type != PropertyCellType::kConstant) { | 17105 new_type != PropertyCellType::kConstant) { |
17092 auto isolate = dictionary->GetIsolate(); | 17106 auto isolate = dictionary->GetIsolate(); |
17093 cell->dependent_code()->DeoptimizeDependentCodeGroup( | 17107 cell->dependent_code()->DeoptimizeDependentCodeGroup( |
17094 isolate, DependentCode::kPropertyCellChangedGroup); | 17108 isolate, DependentCode::kPropertyCellChangedGroup); |
17095 } | 17109 } |
17096 return value; | 17110 return value; |
17097 } | 17111 } |
17098 | 17112 |
17099 } } // namespace v8::internal | 17113 } } // namespace v8::internal |
OLD | NEW |