OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 #ifndef V8_OBJECTS_VISITING_INL_H_ | 5 #ifndef V8_OBJECTS_VISITING_INL_H_ |
6 #define V8_OBJECTS_VISITING_INL_H_ | 6 #define V8_OBJECTS_VISITING_INL_H_ |
7 | 7 |
8 #include "src/heap/array-buffer-tracker.h" | 8 #include "src/heap/array-buffer-tracker.h" |
9 #include "src/heap/objects-visiting.h" | 9 #include "src/heap/objects-visiting.h" |
10 #include "src/ic/ic-state.h" | 10 #include "src/ic/ic-state.h" |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 &FlexibleBodyVisitor<StaticVisitor, FixedTypedArrayBase::BodyDescriptor, | 140 &FlexibleBodyVisitor<StaticVisitor, FixedTypedArrayBase::BodyDescriptor, |
141 void>::Visit); | 141 void>::Visit); |
142 | 142 |
143 table_.Register( | 143 table_.Register( |
144 kVisitFixedFloat64Array, | 144 kVisitFixedFloat64Array, |
145 &FlexibleBodyVisitor<StaticVisitor, FixedTypedArrayBase::BodyDescriptor, | 145 &FlexibleBodyVisitor<StaticVisitor, FixedTypedArrayBase::BodyDescriptor, |
146 void>::Visit); | 146 void>::Visit); |
147 | 147 |
148 table_.Register(kVisitNativeContext, &VisitNativeContext); | 148 table_.Register(kVisitNativeContext, &VisitNativeContext); |
149 | 149 |
150 table_.Register(kVisitAllocationSite, &VisitAllocationSite); | 150 table_.Register( |
| 151 kVisitAllocationSite, |
| 152 &FixedBodyVisitor<StaticVisitor, AllocationSite::MarkingBodyDescriptor, |
| 153 void>::Visit); |
151 | 154 |
152 table_.Register(kVisitByteArray, &DataObjectVisitor::Visit); | 155 table_.Register(kVisitByteArray, &DataObjectVisitor::Visit); |
153 | 156 |
154 table_.Register(kVisitBytecodeArray, &VisitBytecodeArray); | 157 table_.Register( |
| 158 kVisitBytecodeArray, |
| 159 &FixedBodyVisitor<StaticVisitor, BytecodeArray::MarkingBodyDescriptor, |
| 160 void>::Visit); |
155 | 161 |
156 table_.Register(kVisitFreeSpace, &DataObjectVisitor::Visit); | 162 table_.Register(kVisitFreeSpace, &DataObjectVisitor::Visit); |
157 | 163 |
158 table_.Register(kVisitSeqOneByteString, &DataObjectVisitor::Visit); | 164 table_.Register(kVisitSeqOneByteString, &DataObjectVisitor::Visit); |
159 | 165 |
160 table_.Register(kVisitSeqTwoByteString, &DataObjectVisitor::Visit); | 166 table_.Register(kVisitSeqTwoByteString, &DataObjectVisitor::Visit); |
161 | 167 |
162 table_.Register(kVisitJSWeakCollection, &VisitWeakCollection); | 168 table_.Register(kVisitJSWeakCollection, &VisitWeakCollection); |
163 | 169 |
164 table_.Register( | 170 table_.Register( |
165 kVisitOddball, | 171 kVisitOddball, |
166 &FixedBodyVisitor<StaticVisitor, Oddball::BodyDescriptor, void>::Visit); | 172 &FixedBodyVisitor<StaticVisitor, Oddball::BodyDescriptor, void>::Visit); |
167 | 173 |
168 table_.Register(kVisitMap, &VisitMap); | 174 table_.Register(kVisitMap, &VisitMap); |
169 | 175 |
170 table_.Register(kVisitCode, &VisitCode); | 176 table_.Register(kVisitCode, &VisitCode); |
171 | 177 |
172 table_.Register(kVisitSharedFunctionInfo, &VisitSharedFunctionInfo); | 178 table_.Register(kVisitSharedFunctionInfo, &VisitSharedFunctionInfo); |
173 | 179 |
174 table_.Register(kVisitJSFunction, &VisitJSFunction); | 180 table_.Register(kVisitJSFunction, &VisitJSFunction); |
175 | 181 |
176 table_.Register( | 182 table_.Register( |
177 kVisitJSArrayBuffer, | 183 kVisitJSArrayBuffer, |
178 &FlexibleBodyVisitor<StaticVisitor, JSArrayBuffer::BodyDescriptor, | 184 &FlexibleBodyVisitor<StaticVisitor, JSArrayBuffer::BodyDescriptor, |
179 void>::Visit); | 185 void>::Visit); |
180 | 186 |
181 // Registration for kVisitJSRegExp is done by StaticVisitor. | 187 table_.Register(kVisitJSRegExp, &JSObjectVisitor::Visit); |
182 | 188 |
183 table_.Register( | 189 table_.Register( |
184 kVisitCell, | 190 kVisitCell, |
185 &FixedBodyVisitor<StaticVisitor, Cell::BodyDescriptor, void>::Visit); | 191 &FixedBodyVisitor<StaticVisitor, Cell::BodyDescriptor, void>::Visit); |
186 | 192 |
187 table_.Register(kVisitPropertyCell, &VisitPropertyCell); | 193 table_.Register(kVisitPropertyCell, |
| 194 &FixedBodyVisitor<StaticVisitor, PropertyCell::BodyDescriptor, |
| 195 void>::Visit); |
188 | 196 |
189 table_.Register(kVisitWeakCell, &VisitWeakCell); | 197 table_.Register(kVisitWeakCell, &VisitWeakCell); |
190 | 198 |
191 table_.Register(kVisitTransitionArray, &VisitTransitionArray); | 199 table_.Register(kVisitTransitionArray, &VisitTransitionArray); |
192 | 200 |
193 table_.template RegisterSpecializations<DataObjectVisitor, kVisitDataObject, | 201 table_.template RegisterSpecializations<DataObjectVisitor, kVisitDataObject, |
194 kVisitDataObjectGeneric>(); | 202 kVisitDataObjectGeneric>(); |
195 | 203 |
196 table_.template RegisterSpecializations<JSObjectVisitor, kVisitJSObject, | 204 table_.template RegisterSpecializations<JSObjectVisitor, kVisitJSObject, |
197 kVisitJSObjectGeneric>(); | 205 kVisitJSObjectGeneric>(); |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 if (map_object->CanTransition()) { | 320 if (map_object->CanTransition()) { |
313 MarkMapContents(heap, map_object); | 321 MarkMapContents(heap, map_object); |
314 } else { | 322 } else { |
315 StaticVisitor::VisitPointers( | 323 StaticVisitor::VisitPointers( |
316 heap, object, | 324 heap, object, |
317 HeapObject::RawField(object, Map::kPointerFieldsBeginOffset), | 325 HeapObject::RawField(object, Map::kPointerFieldsBeginOffset), |
318 HeapObject::RawField(object, Map::kPointerFieldsEndOffset)); | 326 HeapObject::RawField(object, Map::kPointerFieldsEndOffset)); |
319 } | 327 } |
320 } | 328 } |
321 | 329 |
322 | |
323 template <typename StaticVisitor> | |
324 void StaticMarkingVisitor<StaticVisitor>::VisitPropertyCell( | |
325 Map* map, HeapObject* object) { | |
326 Heap* heap = map->GetHeap(); | |
327 | |
328 StaticVisitor::VisitPointers( | |
329 heap, object, | |
330 HeapObject::RawField(object, PropertyCell::kPointerFieldsBeginOffset), | |
331 HeapObject::RawField(object, PropertyCell::kPointerFieldsEndOffset)); | |
332 } | |
333 | |
334 | |
335 template <typename StaticVisitor> | 330 template <typename StaticVisitor> |
336 void StaticMarkingVisitor<StaticVisitor>::VisitWeakCell(Map* map, | 331 void StaticMarkingVisitor<StaticVisitor>::VisitWeakCell(Map* map, |
337 HeapObject* object) { | 332 HeapObject* object) { |
338 Heap* heap = map->GetHeap(); | 333 Heap* heap = map->GetHeap(); |
339 WeakCell* weak_cell = reinterpret_cast<WeakCell*>(object); | 334 WeakCell* weak_cell = reinterpret_cast<WeakCell*>(object); |
340 // Enqueue weak cell in linked list of encountered weak collections. | 335 // Enqueue weak cell in linked list of encountered weak collections. |
341 // We can ignore weak cells with cleared values because they will always | 336 // We can ignore weak cells with cleared values because they will always |
342 // contain smi zero. | 337 // contain smi zero. |
343 if (weak_cell->next_cleared() && !weak_cell->cleared()) { | 338 if (weak_cell->next_cleared() && !weak_cell->cleared()) { |
344 HeapObject* value = HeapObject::cast(weak_cell->value()); | 339 HeapObject* value = HeapObject::cast(weak_cell->value()); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 // Enqueue the array in linked list of encountered transition arrays if it is | 372 // Enqueue the array in linked list of encountered transition arrays if it is |
378 // not already in the list. | 373 // not already in the list. |
379 if (array->next_link()->IsUndefined(heap->isolate())) { | 374 if (array->next_link()->IsUndefined(heap->isolate())) { |
380 Heap* heap = map->GetHeap(); | 375 Heap* heap = map->GetHeap(); |
381 array->set_next_link(heap->encountered_transition_arrays(), | 376 array->set_next_link(heap->encountered_transition_arrays(), |
382 UPDATE_WEAK_WRITE_BARRIER); | 377 UPDATE_WEAK_WRITE_BARRIER); |
383 heap->set_encountered_transition_arrays(array); | 378 heap->set_encountered_transition_arrays(array); |
384 } | 379 } |
385 } | 380 } |
386 | 381 |
387 | |
388 template <typename StaticVisitor> | |
389 void StaticMarkingVisitor<StaticVisitor>::VisitAllocationSite( | |
390 Map* map, HeapObject* object) { | |
391 Heap* heap = map->GetHeap(); | |
392 | |
393 StaticVisitor::VisitPointers( | |
394 heap, object, | |
395 HeapObject::RawField(object, AllocationSite::kPointerFieldsBeginOffset), | |
396 HeapObject::RawField(object, AllocationSite::kPointerFieldsEndOffset)); | |
397 } | |
398 | |
399 | |
400 template <typename StaticVisitor> | 382 template <typename StaticVisitor> |
401 void StaticMarkingVisitor<StaticVisitor>::VisitWeakCollection( | 383 void StaticMarkingVisitor<StaticVisitor>::VisitWeakCollection( |
402 Map* map, HeapObject* object) { | 384 Map* map, HeapObject* object) { |
403 typedef FlexibleBodyVisitor<StaticVisitor, | 385 typedef FlexibleBodyVisitor<StaticVisitor, |
404 JSWeakCollection::BodyDescriptorWeak, | 386 JSWeakCollection::BodyDescriptorWeak, |
405 void> JSWeakCollectionBodyVisitor; | 387 void> JSWeakCollectionBodyVisitor; |
406 Heap* heap = map->GetHeap(); | 388 Heap* heap = map->GetHeap(); |
407 JSWeakCollection* weak_collection = | 389 JSWeakCollection* weak_collection = |
408 reinterpret_cast<JSWeakCollection*>(object); | 390 reinterpret_cast<JSWeakCollection*>(object); |
409 | 391 |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
497 VisitJSFunctionWeakCode(map, object); | 479 VisitJSFunctionWeakCode(map, object); |
498 return; | 480 return; |
499 } else { | 481 } else { |
500 // Visit all unoptimized code objects to prevent flushing them. | 482 // Visit all unoptimized code objects to prevent flushing them. |
501 StaticVisitor::MarkObject(heap, function->shared()->code()); | 483 StaticVisitor::MarkObject(heap, function->shared()->code()); |
502 } | 484 } |
503 } | 485 } |
504 VisitJSFunctionStrongCode(map, object); | 486 VisitJSFunctionStrongCode(map, object); |
505 } | 487 } |
506 | 488 |
507 | |
508 template <typename StaticVisitor> | |
509 void StaticMarkingVisitor<StaticVisitor>::VisitJSRegExp(Map* map, | |
510 HeapObject* object) { | |
511 JSObjectVisitor::Visit(map, object); | |
512 } | |
513 | |
514 template <typename StaticVisitor> | |
515 void StaticMarkingVisitor<StaticVisitor>::VisitBytecodeArray( | |
516 Map* map, HeapObject* object) { | |
517 StaticVisitor::VisitPointers( | |
518 map->GetHeap(), object, | |
519 HeapObject::RawField(object, BytecodeArray::kConstantPoolOffset), | |
520 HeapObject::RawField(object, BytecodeArray::kFrameSizeOffset)); | |
521 } | |
522 | |
523 | |
524 template <typename StaticVisitor> | 489 template <typename StaticVisitor> |
525 void StaticMarkingVisitor<StaticVisitor>::MarkMapContents(Heap* heap, | 490 void StaticMarkingVisitor<StaticVisitor>::MarkMapContents(Heap* heap, |
526 Map* map) { | 491 Map* map) { |
527 // Since descriptor arrays are potentially shared, ensure that only the | 492 // Since descriptor arrays are potentially shared, ensure that only the |
528 // descriptors that belong to this map are marked. The first time a non-empty | 493 // descriptors that belong to this map are marked. The first time a non-empty |
529 // descriptor array is marked, its header is also visited. The slot holding | 494 // descriptor array is marked, its header is also visited. The slot holding |
530 // the descriptor array will be implicitly recorded when the pointer fields of | 495 // the descriptor array will be implicitly recorded when the pointer fields of |
531 // this map are visited. Prototype maps don't keep track of transitions, so | 496 // this map are visited. Prototype maps don't keep track of transitions, so |
532 // just mark the entire descriptor array. | 497 // just mark the entire descriptor array. |
533 if (!map->is_prototype_map()) { | 498 if (!map->is_prototype_map()) { |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
705 typedef FlexibleBodyVisitor<StaticVisitor, JSFunction::BodyDescriptorWeakCode, | 670 typedef FlexibleBodyVisitor<StaticVisitor, JSFunction::BodyDescriptorWeakCode, |
706 void> JSFunctionWeakCodeBodyVisitor; | 671 void> JSFunctionWeakCodeBodyVisitor; |
707 JSFunctionWeakCodeBodyVisitor::Visit(map, object); | 672 JSFunctionWeakCodeBodyVisitor::Visit(map, object); |
708 } | 673 } |
709 | 674 |
710 | 675 |
711 } // namespace internal | 676 } // namespace internal |
712 } // namespace v8 | 677 } // namespace v8 |
713 | 678 |
714 #endif // V8_OBJECTS_VISITING_INL_H_ | 679 #endif // V8_OBJECTS_VISITING_INL_H_ |
OLD | NEW |