Chromium Code Reviews| 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 bool MarkCompactCollector::MarkUnmarked(Object* value) { | |
|
Michael Starzinger
2012/01/24 13:28:30
The name is kind of misleading, because it not onl
| |
| 1676 HeapObject* object = HeapObject::cast(value); | |
| 1677 MarkBit mark = Marking::MarkBitFrom(object); | |
| 1678 bool old_mark = mark.Get(); | |
| 1679 if (!old_mark) SetMark(object, mark); | |
| 1680 return old_mark; | |
| 1681 } | |
| 1682 | |
| 1683 | |
| 1684 bool MarkCompactCollector::MarkUnmarkedAndPush(Object* value) { | |
|
Michael Starzinger
2012/01/24 13:28:30
Boolean return value is never used, can we drop it
| |
| 1685 bool old_mark = MarkUnmarked(value); | |
| 1686 if (!old_mark) marking_deque_.PushBlack(HeapObject::cast(value)); | |
| 1687 return old_mark; | |
| 1688 } | |
| 1689 | |
| 1690 | |
| 1691 void MarkCompactCollector::MarkAccessorPairSlot(AccessorPair* accessors, | |
| 1692 int offset) { | |
| 1693 Object** slot = HeapObject::RawField(accessors, offset); | |
| 1694 Object* accessor = *slot; | |
| 1695 if (accessor->IsMap()) return; | |
| 1696 RecordSlot(slot, slot, accessor); | |
| 1697 MarkUnmarkedAndPush(accessor); | |
| 1698 } | |
| 1699 | |
| 1700 | |
| 1675 void MarkCompactCollector::MarkDescriptorArray( | 1701 void MarkCompactCollector::MarkDescriptorArray( |
| 1676 DescriptorArray* descriptors) { | 1702 DescriptorArray* descriptors) { |
| 1677 MarkBit descriptors_mark = Marking::MarkBitFrom(descriptors); | 1703 MarkBit descriptors_mark = Marking::MarkBitFrom(descriptors); |
| 1678 if (descriptors_mark.Get()) return; | 1704 if (descriptors_mark.Get()) return; |
| 1679 // Empty descriptor array is marked as a root before any maps are marked. | 1705 // Empty descriptor array is marked as a root before any maps are marked. |
| 1680 ASSERT(descriptors != heap()->empty_descriptor_array()); | 1706 ASSERT(descriptors != heap()->empty_descriptor_array()); |
| 1681 SetMark(descriptors, descriptors_mark); | 1707 SetMark(descriptors, descriptors_mark); |
| 1682 | 1708 |
| 1683 FixedArray* contents = reinterpret_cast<FixedArray*>( | 1709 FixedArray* contents = reinterpret_cast<FixedArray*>( |
| 1684 descriptors->get(DescriptorArray::kContentArrayIndex)); | 1710 descriptors->get(DescriptorArray::kContentArrayIndex)); |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 1697 // If the pair (value, details) at index i, i+1 is not | 1723 // If the pair (value, details) at index i, i+1 is not |
| 1698 // a transition or null descriptor, mark the value. | 1724 // a transition or null descriptor, mark the value. |
| 1699 PropertyDetails details(Smi::cast(contents->get(i + 1))); | 1725 PropertyDetails details(Smi::cast(contents->get(i + 1))); |
| 1700 | 1726 |
| 1701 Object** slot = contents->data_start() + i; | 1727 Object** slot = contents->data_start() + i; |
| 1702 Object* value = *slot; | 1728 Object* value = *slot; |
| 1703 if (!value->IsHeapObject()) continue; | 1729 if (!value->IsHeapObject()) continue; |
| 1704 | 1730 |
| 1705 RecordSlot(slot, slot, *slot); | 1731 RecordSlot(slot, slot, *slot); |
| 1706 | 1732 |
| 1707 if (details.IsProperty()) { | 1733 switch (details.type()) { |
| 1708 HeapObject* object = HeapObject::cast(value); | 1734 case NORMAL: |
| 1709 MarkBit mark = Marking::MarkBitFrom(HeapObject::cast(object)); | 1735 case FIELD: |
| 1710 if (!mark.Get()) { | 1736 case CONSTANT_FUNCTION: |
| 1711 SetMark(HeapObject::cast(object), mark); | 1737 case HANDLER: |
| 1712 marking_deque_.PushBlack(object); | 1738 case INTERCEPTOR: |
| 1713 } | 1739 MarkUnmarkedAndPush(value); |
| 1714 } else if (details.type() == ELEMENTS_TRANSITION && value->IsFixedArray()) { | 1740 break; |
| 1715 // For maps with multiple elements transitions, the transition maps are | 1741 case CALLBACKS: |
| 1716 // stored in a FixedArray. Keep the fixed array alive but not the maps | 1742 if (!value->IsAccessorPair()) { |
| 1717 // that it refers to. | 1743 MarkUnmarkedAndPush(value); |
| 1718 HeapObject* object = HeapObject::cast(value); | 1744 } else if (!MarkUnmarked(value)) { |
| 1719 MarkBit mark = Marking::MarkBitFrom(HeapObject::cast(object)); | 1745 AccessorPair* accessors = AccessorPair::cast(value); |
| 1720 if (!mark.Get()) { | 1746 MarkAccessorPairSlot(accessors, AccessorPair::kGetterOffset); |
| 1721 SetMark(HeapObject::cast(object), mark); | 1747 MarkAccessorPairSlot(accessors, AccessorPair::kSetterOffset); |
| 1722 } | 1748 } |
| 1749 break; | |
| 1750 case ELEMENTS_TRANSITION: | |
| 1751 // For maps with multiple elements transitions, the transition maps are | |
| 1752 // stored in a FixedArray. Keep the fixed array alive but not the maps | |
| 1753 // that it refers to. | |
| 1754 if (value->IsFixedArray()) MarkUnmarked(value); | |
| 1755 break; | |
| 1756 case MAP_TRANSITION: | |
| 1757 case CONSTANT_TRANSITION: | |
| 1758 case NULL_DESCRIPTOR: | |
| 1759 break; | |
| 1723 } | 1760 } |
| 1724 } | 1761 } |
| 1725 // The DescriptorArray descriptors contains a pointer to its contents array, | 1762 // The DescriptorArray descriptors contains a pointer to its contents array, |
| 1726 // but the contents array is already marked. | 1763 // but the contents array is already marked. |
| 1727 marking_deque_.PushBlack(descriptors); | 1764 marking_deque_.PushBlack(descriptors); |
| 1728 } | 1765 } |
| 1729 | 1766 |
| 1730 | 1767 |
| 1731 void MarkCompactCollector::CreateBackPointers() { | 1768 void MarkCompactCollector::CreateBackPointers() { |
| 1732 HeapObjectIterator iterator(heap()->map_space()); | 1769 HeapObjectIterator iterator(heap()->map_space()); |
| (...skipping 2180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3913 while (buffer != NULL) { | 3950 while (buffer != NULL) { |
| 3914 SlotsBuffer* next_buffer = buffer->next(); | 3951 SlotsBuffer* next_buffer = buffer->next(); |
| 3915 DeallocateBuffer(buffer); | 3952 DeallocateBuffer(buffer); |
| 3916 buffer = next_buffer; | 3953 buffer = next_buffer; |
| 3917 } | 3954 } |
| 3918 *buffer_address = NULL; | 3955 *buffer_address = NULL; |
| 3919 } | 3956 } |
| 3920 | 3957 |
| 3921 | 3958 |
| 3922 } } // namespace v8::internal | 3959 } } // namespace v8::internal |
| OLD | NEW |