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 566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
577 StaticVisitor::VisitPointers( | 577 StaticVisitor::VisitPointers( |
578 map->GetHeap(), | 578 map->GetHeap(), |
579 HeapObject::RawField(object, JSDataView::kWeakNextOffset + kPointerSize), | 579 HeapObject::RawField(object, JSDataView::kWeakNextOffset + kPointerSize), |
580 HeapObject::RawField(object, JSDataView::kSizeWithInternalFields)); | 580 HeapObject::RawField(object, JSDataView::kSizeWithInternalFields)); |
581 } | 581 } |
582 | 582 |
583 | 583 |
584 template <typename StaticVisitor> | 584 template <typename StaticVisitor> |
585 void StaticMarkingVisitor<StaticVisitor>::MarkMapContents(Heap* heap, | 585 void StaticMarkingVisitor<StaticVisitor>::MarkMapContents(Heap* heap, |
586 Map* map) { | 586 Map* map) { |
587 // Make sure that the back pointer stored either in the map itself or | 587 Object* raw_transitions = map->raw_transitions(); |
588 // inside its transitions array is marked. Skip recording the back | 588 if (TransitionArray::IsSimpleTransition(raw_transitions)) { |
589 // pointer slot since map space is not compacted. | 589 StaticVisitor::VisitPointer( |
590 StaticVisitor::MarkObject(heap, HeapObject::cast(map->GetBackPointer())); | 590 heap, HeapObject::RawField(map, Map::kTransitionsOffset)); |
Toon Verwaest
2015/03/05 13:18:54
This keeps all simple transitions alive?
Jakob Kummerow
2015/03/05 15:26:36
No, the WeakCell takes care of that. (We must keep
| |
591 | 591 } |
592 // Treat pointers in the transitions array as weak and also mark that | 592 if (TransitionArray::IsFullTransitionArray(raw_transitions)) { |
593 // array to prevent visiting it later. Skip recording the transition | 593 MarkTransitionArray(heap, TransitionArray::cast(raw_transitions)); |
594 // array slot, since it will be implicitly recorded when the pointer | |
595 // fields of this map are visited. | |
596 if (map->HasTransitionArray()) { | |
597 TransitionArray* transitions = map->transitions(); | |
598 MarkTransitionArray(heap, transitions); | |
599 } | 594 } |
600 | 595 |
601 // Since descriptor arrays are potentially shared, ensure that only the | 596 // Since descriptor arrays are potentially shared, ensure that only the |
602 // descriptors that belong to this map are marked. The first time a | 597 // descriptors that belong to this map are marked. The first time a |
603 // non-empty descriptor array is marked, its header is also visited. The slot | 598 // non-empty descriptor array is marked, its header is also visited. The slot |
604 // holding the descriptor array will be implicitly recorded when the pointer | 599 // holding the descriptor array will be implicitly recorded when the pointer |
605 // fields of this map are visited. | 600 // fields of this map are visited. |
606 DescriptorArray* descriptors = map->instance_descriptors(); | 601 DescriptorArray* descriptors = map->instance_descriptors(); |
607 if (StaticVisitor::MarkObjectWithoutPush(heap, descriptors) && | 602 if (StaticVisitor::MarkObjectWithoutPush(heap, descriptors) && |
608 descriptors->length() > 0) { | 603 descriptors->length() > 0) { |
(...skipping 15 matching lines...) Expand all Loading... | |
624 heap, HeapObject::RawField(map, Map::kPointerFieldsBeginOffset), | 619 heap, HeapObject::RawField(map, Map::kPointerFieldsBeginOffset), |
625 HeapObject::RawField(map, Map::kPointerFieldsEndOffset)); | 620 HeapObject::RawField(map, Map::kPointerFieldsEndOffset)); |
626 } | 621 } |
627 | 622 |
628 | 623 |
629 template <typename StaticVisitor> | 624 template <typename StaticVisitor> |
630 void StaticMarkingVisitor<StaticVisitor>::MarkTransitionArray( | 625 void StaticMarkingVisitor<StaticVisitor>::MarkTransitionArray( |
631 Heap* heap, TransitionArray* transitions) { | 626 Heap* heap, TransitionArray* transitions) { |
632 if (!StaticVisitor::MarkObjectWithoutPush(heap, transitions)) return; | 627 if (!StaticVisitor::MarkObjectWithoutPush(heap, transitions)) return; |
633 | 628 |
634 // Simple transitions do not have keys nor prototype transitions. | |
635 if (transitions->IsSimpleTransition()) return; | |
636 | |
637 if (transitions->HasPrototypeTransitions()) { | 629 if (transitions->HasPrototypeTransitions()) { |
638 // Mark prototype transitions array but do not push it onto marking | 630 // Mark prototype transitions array but do not push it onto marking |
639 // stack, this will make references from it weak. We will clean dead | 631 // stack, this will make references from it weak. We will clean dead |
640 // prototype transitions in ClearNonLiveTransitions. | 632 // prototype transitions in ClearNonLiveReferences. |
641 Object** slot = transitions->GetPrototypeTransitionsSlot(); | 633 Object** slot = transitions->GetPrototypeTransitionsSlot(); |
642 HeapObject* obj = HeapObject::cast(*slot); | 634 HeapObject* obj = HeapObject::cast(*slot); |
643 heap->mark_compact_collector()->RecordSlot(slot, slot, obj); | 635 heap->mark_compact_collector()->RecordSlot(slot, slot, obj); |
644 StaticVisitor::MarkObjectWithoutPush(heap, obj); | 636 StaticVisitor::MarkObjectWithoutPush(heap, obj); |
645 } | 637 } |
646 | 638 |
647 for (int i = 0; i < transitions->number_of_transitions(); ++i) { | 639 int num_transitions = TransitionArray::NumberOfTransitions(transitions); |
640 for (int i = 0; i < num_transitions; ++i) { | |
648 StaticVisitor::VisitPointer(heap, transitions->GetKeySlot(i)); | 641 StaticVisitor::VisitPointer(heap, transitions->GetKeySlot(i)); |
649 } | 642 } |
650 } | 643 } |
651 | 644 |
652 | 645 |
653 template <typename StaticVisitor> | 646 template <typename StaticVisitor> |
654 void StaticMarkingVisitor<StaticVisitor>::MarkInlinedFunctionsCode(Heap* heap, | 647 void StaticMarkingVisitor<StaticVisitor>::MarkInlinedFunctionsCode(Heap* heap, |
655 Code* code) { | 648 Code* code) { |
656 // Skip in absence of inlining. | 649 // Skip in absence of inlining. |
657 // TODO(turbofan): Revisit once we support inlining. | 650 // TODO(turbofan): Revisit once we support inlining. |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
901 | 894 |
902 RelocIterator it(this, mode_mask); | 895 RelocIterator it(this, mode_mask); |
903 for (; !it.done(); it.next()) { | 896 for (; !it.done(); it.next()) { |
904 it.rinfo()->template Visit<StaticVisitor>(heap); | 897 it.rinfo()->template Visit<StaticVisitor>(heap); |
905 } | 898 } |
906 } | 899 } |
907 } | 900 } |
908 } // namespace v8::internal | 901 } // namespace v8::internal |
909 | 902 |
910 #endif // V8_OBJECTS_VISITING_INL_H_ | 903 #endif // V8_OBJECTS_VISITING_INL_H_ |
OLD | NEW |