| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 610 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 621 // Already marked by marking map->GetBackPointer() above. | 621 // Already marked by marking map->GetBackPointer() above. |
| 622 ASSERT(transitions->IsMap() || transitions->IsUndefined()); | 622 ASSERT(transitions->IsMap() || transitions->IsUndefined()); |
| 623 } | 623 } |
| 624 | 624 |
| 625 // Since descriptor arrays are potentially shared, ensure that only the | 625 // Since descriptor arrays are potentially shared, ensure that only the |
| 626 // descriptors that belong to this map are marked. The first time a | 626 // descriptors that belong to this map are marked. The first time a |
| 627 // non-empty descriptor array is marked, its header is also visited. The slot | 627 // non-empty descriptor array is marked, its header is also visited. The slot |
| 628 // holding the descriptor array will be implicitly recorded when the pointer | 628 // holding the descriptor array will be implicitly recorded when the pointer |
| 629 // fields of this map are visited. | 629 // fields of this map are visited. |
| 630 DescriptorArray* descriptors = map->instance_descriptors(); | 630 DescriptorArray* descriptors = map->instance_descriptors(); |
| 631 MarkCompactCollector* collector = heap->mark_compact_collector(); |
| 632 |
| 631 if (StaticVisitor::MarkObjectWithoutPush(heap, descriptors) && | 633 if (StaticVisitor::MarkObjectWithoutPush(heap, descriptors) && |
| 632 descriptors->length() > 0) { | 634 descriptors->length() > 0) { |
| 635 // Record all keys and values in the descriptor array to ensure that they |
| 636 // are updated if they are on evacuation candidates and are alive, but the |
| 637 // descriptor array is not yet installed in the map that's adding the |
| 638 // descriptors. |
| 639 for (int i = 0; i < descriptors->number_of_descriptors(); i++) { |
| 640 Object** key_slot = descriptors->GetKeySlot(i); |
| 641 ASSERT((*key_slot)->IsHeapObject()); |
| 642 collector->RecordSlot(key_slot, key_slot, *key_slot); |
| 643 Object** value_slot = descriptors->GetValueSlot(i); |
| 644 if ((*value_slot)->IsHeapObject()) { |
| 645 collector->RecordSlot(value_slot, value_slot, *value_slot); |
| 646 } |
| 647 } |
| 633 StaticVisitor::VisitPointers(heap, | 648 StaticVisitor::VisitPointers(heap, |
| 634 descriptors->GetFirstElementAddress(), | 649 descriptors->GetFirstElementAddress(), |
| 635 descriptors->GetDescriptorEndSlot(0)); | 650 descriptors->GetDescriptorEndSlot(0)); |
| 636 } | 651 } |
| 637 int start = 0; | 652 int start = 0; |
| 638 int end = map->NumberOfOwnDescriptors(); | 653 int end = map->NumberOfOwnDescriptors(); |
| 639 if (start < end) { | 654 if (start < end) { |
| 640 StaticVisitor::VisitPointers(heap, | 655 for (Object** p = descriptors->GetDescriptorStartSlot(start); |
| 641 descriptors->GetDescriptorStartSlot(start), | 656 p < descriptors->GetDescriptorEndSlot(end); |
| 642 descriptors->GetDescriptorEndSlot(end)); | 657 p++) { |
| 658 if ((*p)->IsHeapObject()) { |
| 659 StaticVisitor::MarkObject(heap, HeapObject::cast(*p)); |
| 660 } |
| 661 } |
| 643 } | 662 } |
| 644 | 663 |
| 645 // Mark prototype dependent codes array but do not push it onto marking | 664 // Mark prototype dependent codes array but do not push it onto marking |
| 646 // stack, this will make references from it weak. We will clean dead | 665 // stack, this will make references from it weak. We will clean dead |
| 647 // codes when we iterate over maps in ClearNonLiveTransitions. | 666 // codes when we iterate over maps in ClearNonLiveTransitions. |
| 648 Object** slot = HeapObject::RawField(map, Map::kDependentCodeOffset); | 667 Object** slot = HeapObject::RawField(map, Map::kDependentCodeOffset); |
| 649 HeapObject* obj = HeapObject::cast(*slot); | 668 HeapObject* obj = HeapObject::cast(*slot); |
| 650 heap->mark_compact_collector()->RecordSlot(slot, slot, obj); | 669 collector->RecordSlot(slot, slot, obj); |
| 651 StaticVisitor::MarkObjectWithoutPush(heap, obj); | 670 StaticVisitor::MarkObjectWithoutPush(heap, obj); |
| 652 | 671 |
| 653 // Mark the pointer fields of the Map. Since the transitions array has | 672 // Mark the pointer fields of the Map. Since the transitions array has |
| 654 // been marked already, it is fine that one of these fields contains a | 673 // been marked already, it is fine that one of these fields contains a |
| 655 // pointer to it. | 674 // pointer to it. |
| 656 StaticVisitor::VisitPointers(heap, | 675 StaticVisitor::VisitPointers(heap, |
| 657 HeapObject::RawField(map, Map::kPointerFieldsBeginOffset), | 676 HeapObject::RawField(map, Map::kPointerFieldsBeginOffset), |
| 658 HeapObject::RawField(map, Map::kPointerFieldsEndOffset)); | 677 HeapObject::RawField(map, Map::kPointerFieldsEndOffset)); |
| 659 } | 678 } |
| 660 | 679 |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 940 RelocIterator it(this, mode_mask); | 959 RelocIterator it(this, mode_mask); |
| 941 for (; !it.done(); it.next()) { | 960 for (; !it.done(); it.next()) { |
| 942 it.rinfo()->template Visit<StaticVisitor>(heap); | 961 it.rinfo()->template Visit<StaticVisitor>(heap); |
| 943 } | 962 } |
| 944 } | 963 } |
| 945 | 964 |
| 946 | 965 |
| 947 } } // namespace v8::internal | 966 } } // namespace v8::internal |
| 948 | 967 |
| 949 #endif // V8_OBJECTS_VISITING_INL_H_ | 968 #endif // V8_OBJECTS_VISITING_INL_H_ |
| OLD | NEW |