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 | 8 |
9 namespace v8 { | 9 namespace v8 { |
10 namespace internal { | 10 namespace internal { |
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
397 | 397 |
398 | 398 |
399 template<typename StaticVisitor> | 399 template<typename StaticVisitor> |
400 void StaticMarkingVisitor<StaticVisitor>::VisitWeakCollection( | 400 void StaticMarkingVisitor<StaticVisitor>::VisitWeakCollection( |
401 Map* map, HeapObject* object) { | 401 Map* map, HeapObject* object) { |
402 Heap* heap = map->GetHeap(); | 402 Heap* heap = map->GetHeap(); |
403 JSWeakCollection* weak_collection = | 403 JSWeakCollection* weak_collection = |
404 reinterpret_cast<JSWeakCollection*>(object); | 404 reinterpret_cast<JSWeakCollection*>(object); |
405 MarkCompactCollector* collector = heap->mark_compact_collector(); | 405 MarkCompactCollector* collector = heap->mark_compact_collector(); |
406 | 406 |
407 // Enqueue weak map in linked list of encountered weak maps. | 407 // Enqueue weak collection in linked list of encountered weak collections. |
408 if (weak_collection->next() == heap->undefined_value()) { | 408 if (weak_collection->next() == heap->undefined_value()) { |
409 weak_collection->set_next(collector->encountered_weak_collections()); | 409 weak_collection->set_next(collector->encountered_weak_collections()); |
410 collector->set_encountered_weak_collections(weak_collection); | 410 collector->set_encountered_weak_collections(weak_collection); |
411 } | 411 } |
412 | 412 |
413 // Skip visiting the backing hash table containing the mappings and the | 413 // Skip visiting the backing hash table containing the mappings and the |
414 // pointer to the other enqueued weak collections, both are post-processed. | 414 // pointer to the other enqueued weak collections, both are post-processed. |
415 StaticVisitor::VisitPointers(heap, | 415 StaticVisitor::VisitPointers(heap, |
416 HeapObject::RawField(object, JSWeakCollection::kPropertiesOffset), | 416 HeapObject::RawField(object, JSWeakCollection::kPropertiesOffset), |
417 HeapObject::RawField(object, JSWeakCollection::kTableOffset)); | 417 HeapObject::RawField(object, JSWeakCollection::kTableOffset)); |
418 STATIC_ASSERT(JSWeakCollection::kTableOffset + kPointerSize == | 418 STATIC_ASSERT(JSWeakCollection::kTableOffset + kPointerSize == |
419 JSWeakCollection::kNextOffset); | 419 JSWeakCollection::kNextOffset); |
420 STATIC_ASSERT(JSWeakCollection::kNextOffset + kPointerSize == | 420 STATIC_ASSERT(JSWeakCollection::kNextOffset + kPointerSize == |
421 JSWeakCollection::kSize); | 421 JSWeakCollection::kSize); |
422 | 422 |
| 423 // Partially initialized weak collection is enqueued, but table is ignored. |
423 if (!weak_collection->table()->IsHashTable()) return; | 424 if (!weak_collection->table()->IsHashTable()) return; |
424 | 425 |
425 // Mark the backing hash table without pushing it on the marking stack. | 426 // Mark the backing hash table without pushing it on the marking stack. |
426 Object** slot = HeapObject::RawField(object, JSWeakCollection::kTableOffset); | 427 Object** slot = HeapObject::RawField(object, JSWeakCollection::kTableOffset); |
427 HeapObject* obj = HeapObject::cast(*slot); | 428 HeapObject* obj = HeapObject::cast(*slot); |
428 heap->mark_compact_collector()->RecordSlot(slot, slot, obj); | 429 heap->mark_compact_collector()->RecordSlot(slot, slot, obj); |
429 StaticVisitor::MarkObjectWithoutPush(heap, obj); | 430 StaticVisitor::MarkObjectWithoutPush(heap, obj); |
430 } | 431 } |
431 | 432 |
432 | 433 |
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
959 RelocIterator it(this, mode_mask); | 960 RelocIterator it(this, mode_mask); |
960 for (; !it.done(); it.next()) { | 961 for (; !it.done(); it.next()) { |
961 it.rinfo()->template Visit<StaticVisitor>(heap); | 962 it.rinfo()->template Visit<StaticVisitor>(heap); |
962 } | 963 } |
963 } | 964 } |
964 | 965 |
965 | 966 |
966 } } // namespace v8::internal | 967 } } // namespace v8::internal |
967 | 968 |
968 #endif // V8_OBJECTS_VISITING_INL_H_ | 969 #endif // V8_OBJECTS_VISITING_INL_H_ |
OLD | NEW |