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 1654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1665 // that one of these fields contains a pointer to it. | 1665 // that one of these fields contains a pointer to it. |
1666 Object** start_slot = HeapObject::RawField(map, | 1666 Object** start_slot = HeapObject::RawField(map, |
1667 Map::kPointerFieldsBeginOffset); | 1667 Map::kPointerFieldsBeginOffset); |
1668 | 1668 |
1669 Object** end_slot = HeapObject::RawField(map, Map::kPointerFieldsEndOffset); | 1669 Object** end_slot = HeapObject::RawField(map, Map::kPointerFieldsEndOffset); |
1670 | 1670 |
1671 StaticMarkingVisitor::VisitPointers(map->GetHeap(), start_slot, end_slot); | 1671 StaticMarkingVisitor::VisitPointers(map->GetHeap(), start_slot, end_slot); |
1672 } | 1672 } |
1673 | 1673 |
1674 | 1674 |
| 1675 void MarkCompactCollector::MarkAccessorPairSlot(HeapObject* accessors, |
| 1676 int offset) { |
| 1677 Object** slot = HeapObject::RawField(accessors, offset); |
| 1678 HeapObject* accessor = HeapObject::cast(*slot); |
| 1679 if (accessor->IsMap()) return; |
| 1680 RecordSlot(slot, slot, accessor); |
| 1681 MarkObjectAndPush(accessor); |
| 1682 } |
| 1683 |
| 1684 |
1675 void MarkCompactCollector::MarkDescriptorArray( | 1685 void MarkCompactCollector::MarkDescriptorArray( |
1676 DescriptorArray* descriptors) { | 1686 DescriptorArray* descriptors) { |
1677 MarkBit descriptors_mark = Marking::MarkBitFrom(descriptors); | 1687 MarkBit descriptors_mark = Marking::MarkBitFrom(descriptors); |
1678 if (descriptors_mark.Get()) return; | 1688 if (descriptors_mark.Get()) return; |
1679 // Empty descriptor array is marked as a root before any maps are marked. | 1689 // Empty descriptor array is marked as a root before any maps are marked. |
1680 ASSERT(descriptors != heap()->empty_descriptor_array()); | 1690 ASSERT(descriptors != heap()->empty_descriptor_array()); |
1681 SetMark(descriptors, descriptors_mark); | 1691 SetMark(descriptors, descriptors_mark); |
1682 | 1692 |
1683 FixedArray* contents = reinterpret_cast<FixedArray*>( | 1693 FixedArray* contents = reinterpret_cast<FixedArray*>( |
1684 descriptors->get(DescriptorArray::kContentArrayIndex)); | 1694 descriptors->get(DescriptorArray::kContentArrayIndex)); |
1685 ASSERT(contents->IsHeapObject()); | 1695 ASSERT(contents->IsHeapObject()); |
1686 ASSERT(!IsMarked(contents)); | 1696 ASSERT(!IsMarked(contents)); |
1687 ASSERT(contents->IsFixedArray()); | 1697 ASSERT(contents->IsFixedArray()); |
1688 ASSERT(contents->length() >= 2); | 1698 ASSERT(contents->length() >= 2); |
1689 MarkBit contents_mark = Marking::MarkBitFrom(contents); | 1699 MarkBit contents_mark = Marking::MarkBitFrom(contents); |
1690 SetMark(contents, contents_mark); | 1700 SetMark(contents, contents_mark); |
1691 // Contents contains (value, details) pairs. If the details say that the type | 1701 // Contents contains (value, details) pairs. If the details say that the type |
1692 // of descriptor is MAP_TRANSITION, CONSTANT_TRANSITION, | 1702 // of descriptor is MAP_TRANSITION, CONSTANT_TRANSITION, |
1693 // EXTERNAL_ARRAY_TRANSITION or NULL_DESCRIPTOR, we don't mark the value as | 1703 // EXTERNAL_ARRAY_TRANSITION or NULL_DESCRIPTOR, we don't mark the value as |
1694 // live. Only for MAP_TRANSITION, EXTERNAL_ARRAY_TRANSITION and | 1704 // live. Only for MAP_TRANSITION, EXTERNAL_ARRAY_TRANSITION and |
1695 // CONSTANT_TRANSITION is the value an Object* (a Map*). | 1705 // CONSTANT_TRANSITION is the value an Object* (a Map*). |
1696 for (int i = 0; i < contents->length(); i += 2) { | 1706 for (int i = 0; i < contents->length(); i += 2) { |
1697 // If the pair (value, details) at index i, i+1 is not | 1707 // If the pair (value, details) at index i, i+1 is not |
1698 // a transition or null descriptor, mark the value. | 1708 // a transition or null descriptor, mark the value. |
1699 PropertyDetails details(Smi::cast(contents->get(i + 1))); | 1709 PropertyDetails details(Smi::cast(contents->get(i + 1))); |
1700 | 1710 |
1701 Object** slot = contents->data_start() + i; | 1711 Object** slot = contents->data_start() + i; |
1702 Object* value = *slot; | 1712 if (!(*slot)->IsHeapObject()) continue; |
1703 if (!value->IsHeapObject()) continue; | 1713 HeapObject* value = HeapObject::cast(*slot); |
1704 | 1714 |
1705 RecordSlot(slot, slot, *slot); | 1715 RecordSlot(slot, slot, *slot); |
1706 | 1716 |
1707 if (details.IsProperty()) { | 1717 switch (details.type()) { |
1708 HeapObject* object = HeapObject::cast(value); | 1718 case NORMAL: |
1709 MarkBit mark = Marking::MarkBitFrom(HeapObject::cast(object)); | 1719 case FIELD: |
1710 if (!mark.Get()) { | 1720 case CONSTANT_FUNCTION: |
1711 SetMark(HeapObject::cast(object), mark); | 1721 case HANDLER: |
1712 marking_deque_.PushBlack(object); | 1722 case INTERCEPTOR: |
1713 } | 1723 MarkObjectAndPush(value); |
1714 } else if (details.type() == ELEMENTS_TRANSITION && value->IsFixedArray()) { | 1724 break; |
1715 // For maps with multiple elements transitions, the transition maps are | 1725 case CALLBACKS: |
1716 // stored in a FixedArray. Keep the fixed array alive but not the maps | 1726 if (!value->IsAccessorPair()) { |
1717 // that it refers to. | 1727 MarkObjectAndPush(value); |
1718 HeapObject* object = HeapObject::cast(value); | 1728 } else if (!MarkObjectWithoutPush(value)) { |
1719 MarkBit mark = Marking::MarkBitFrom(HeapObject::cast(object)); | 1729 MarkAccessorPairSlot(value, AccessorPair::kGetterOffset); |
1720 if (!mark.Get()) { | 1730 MarkAccessorPairSlot(value, AccessorPair::kSetterOffset); |
1721 SetMark(HeapObject::cast(object), mark); | 1731 } |
1722 } | 1732 break; |
| 1733 case ELEMENTS_TRANSITION: |
| 1734 // For maps with multiple elements transitions, the transition maps are |
| 1735 // stored in a FixedArray. Keep the fixed array alive but not the maps |
| 1736 // that it refers to. |
| 1737 if (value->IsFixedArray()) MarkObjectWithoutPush(value); |
| 1738 break; |
| 1739 case MAP_TRANSITION: |
| 1740 case CONSTANT_TRANSITION: |
| 1741 case NULL_DESCRIPTOR: |
| 1742 break; |
1723 } | 1743 } |
1724 } | 1744 } |
1725 // The DescriptorArray descriptors contains a pointer to its contents array, | 1745 // The DescriptorArray descriptors contains a pointer to its contents array, |
1726 // but the contents array is already marked. | 1746 // but the contents array is already marked. |
1727 marking_deque_.PushBlack(descriptors); | 1747 marking_deque_.PushBlack(descriptors); |
1728 } | 1748 } |
1729 | 1749 |
1730 | 1750 |
1731 void MarkCompactCollector::CreateBackPointers() { | 1751 void MarkCompactCollector::CreateBackPointers() { |
1732 HeapObjectIterator iterator(heap()->map_space()); | 1752 HeapObjectIterator iterator(heap()->map_space()); |
(...skipping 2180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3913 while (buffer != NULL) { | 3933 while (buffer != NULL) { |
3914 SlotsBuffer* next_buffer = buffer->next(); | 3934 SlotsBuffer* next_buffer = buffer->next(); |
3915 DeallocateBuffer(buffer); | 3935 DeallocateBuffer(buffer); |
3916 buffer = next_buffer; | 3936 buffer = next_buffer; |
3917 } | 3937 } |
3918 *buffer_address = NULL; | 3938 *buffer_address = NULL; |
3919 } | 3939 } |
3920 | 3940 |
3921 | 3941 |
3922 } } // namespace v8::internal | 3942 } } // namespace v8::internal |
OLD | NEW |