Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(105)

Side by Side Diff: src/mark-compact.cc

Issue 10996018: Allow partial scanning of large arrays in order to avoid (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/mark-compact.h ('k') | src/mark-compact-inl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1035 matching lines...) Expand 10 before | Expand all | Expand 10 after
1046 public: 1046 public:
1047 static inline void Visit(Map* map, HeapObject* obj); 1047 static inline void Visit(Map* map, HeapObject* obj);
1048 }; 1048 };
1049 1049
1050 static void Initialize(); 1050 static void Initialize();
1051 1051
1052 INLINE(static void VisitPointer(Heap* heap, Object** p)) { 1052 INLINE(static void VisitPointer(Heap* heap, Object** p)) {
1053 MarkObjectByPointer(heap->mark_compact_collector(), p, p); 1053 MarkObjectByPointer(heap->mark_compact_collector(), p, p);
1054 } 1054 }
1055 1055
1056 INLINE(static void VisitPointers(Heap* heap, Object** start, Object** end)) { 1056 INLINE(static void VisitPointers(Heap* heap,
1057 Object** anchor,
1058 Object** start,
1059 Object** end)) {
1057 // Mark all objects pointed to in [start, end). 1060 // Mark all objects pointed to in [start, end).
1058 const int kMinRangeForMarkingRecursion = 64; 1061 const int kMinRangeForMarkingRecursion = 64;
1059 if (end - start >= kMinRangeForMarkingRecursion) { 1062 if (end - start >= kMinRangeForMarkingRecursion) {
1060 if (VisitUnmarkedObjects(heap, start, end)) return; 1063 if (VisitUnmarkedObjects(heap, anchor, start, end)) return;
1061 // We are close to a stack overflow, so just mark the objects. 1064 // We are close to a stack overflow, so just mark the objects.
1062 } 1065 }
1063 MarkCompactCollector* collector = heap->mark_compact_collector(); 1066 MarkCompactCollector* collector = heap->mark_compact_collector();
1064 for (Object** p = start; p < end; p++) { 1067 for (Object** p = start; p < end; p++) {
1065 MarkObjectByPointer(collector, start, p); 1068 MarkObjectByPointer(collector, anchor, p);
1069 }
1070 }
1071
1072 static void VisitHugeFixedArray(Heap* heap, FixedArray* array, int length);
1073
1074 // The deque is contiguous and we use new space, it is therefore contained in
1075 // one page minus the header. It also has a size that is a power of two so
1076 // it is half the size of a page. We want to scan a number of array entries
1077 // that is less than the number of entries in the deque, so we divide by 2
1078 // once more.
1079 static const int kScanningChunk = Page::kPageSize / 4 / kPointerSize;
1080
1081 INLINE(static void VisitFixedArray(Map* map, HeapObject* object)) {
1082 FixedArray* array = FixedArray::cast(object);
1083 int length = array->length();
1084 Heap* heap = map->GetHeap();
1085
1086 if (length < kScanningChunk ||
1087 MemoryChunk::FromAddress(array->address())->owner()->identity() !=
1088 LO_SPACE) {
1089 Object** start_slot = array->data_start();
1090 VisitPointers(heap, start_slot, start_slot, start_slot + length);
1091 } else {
1092 VisitHugeFixedArray(heap, array, length);
1066 } 1093 }
1067 } 1094 }
1068 1095
1069 // Marks the object black and pushes it on the marking stack. 1096 // Marks the object black and pushes it on the marking stack.
1070 INLINE(static void MarkObject(Heap* heap, HeapObject* object)) { 1097 INLINE(static void MarkObject(Heap* heap, HeapObject* object)) {
1071 MarkBit mark = Marking::MarkBitFrom(object); 1098 MarkBit mark = Marking::MarkBitFrom(object);
1072 heap->mark_compact_collector()->MarkObject(object, mark); 1099 heap->mark_compact_collector()->MarkObject(object, mark);
1073 } 1100 }
1074 1101
1075 // Marks the object black without pushing it on the marking stack. 1102 // Marks the object black without pushing it on the marking stack.
(...skipping 29 matching lines...) Expand all
1105 Map* map = obj->map(); 1132 Map* map = obj->map();
1106 Heap* heap = obj->GetHeap(); 1133 Heap* heap = obj->GetHeap();
1107 MarkBit mark = Marking::MarkBitFrom(obj); 1134 MarkBit mark = Marking::MarkBitFrom(obj);
1108 heap->mark_compact_collector()->SetMark(obj, mark); 1135 heap->mark_compact_collector()->SetMark(obj, mark);
1109 // Mark the map pointer and the body. 1136 // Mark the map pointer and the body.
1110 MarkBit map_mark = Marking::MarkBitFrom(map); 1137 MarkBit map_mark = Marking::MarkBitFrom(map);
1111 heap->mark_compact_collector()->MarkObject(map, map_mark); 1138 heap->mark_compact_collector()->MarkObject(map, map_mark);
1112 IterateBody(map, obj); 1139 IterateBody(map, obj);
1113 } 1140 }
1114 1141
1115 // Visit all unmarked objects pointed to by [start, end). 1142 // Visit all unmarked objects pointed to by [start_slot, end_slot).
1116 // Returns false if the operation fails (lack of stack space). 1143 // Returns false if the operation fails (lack of stack space).
1117 static inline bool VisitUnmarkedObjects(Heap* heap, 1144 static inline bool VisitUnmarkedObjects(Heap* heap,
1118 Object** start, 1145 Object** anchor_slot,
1119 Object** end) { 1146 Object** start_slot,
1147 Object** end_slot) {
1120 // Return false is we are close to the stack limit. 1148 // Return false is we are close to the stack limit.
1121 StackLimitCheck check(heap->isolate()); 1149 StackLimitCheck check(heap->isolate());
1122 if (check.HasOverflowed()) return false; 1150 if (check.HasOverflowed()) return false;
1123 1151
1124 MarkCompactCollector* collector = heap->mark_compact_collector(); 1152 MarkCompactCollector* collector = heap->mark_compact_collector();
1125 // Visit the unmarked objects. 1153 // Visit the unmarked objects.
1126 for (Object** p = start; p < end; p++) { 1154 for (Object** p = start_slot; p < end_slot; p++) {
1127 Object* o = *p; 1155 Object* o = *p;
1128 if (!o->IsHeapObject()) continue; 1156 if (!o->IsHeapObject()) continue;
1129 collector->RecordSlot(start, p, o); 1157 collector->RecordSlot(anchor_slot, p, o);
1130 HeapObject* obj = HeapObject::cast(o); 1158 HeapObject* obj = HeapObject::cast(o);
1131 MarkBit mark = Marking::MarkBitFrom(obj); 1159 MarkBit mark = Marking::MarkBitFrom(obj);
1132 if (mark.Get()) continue; 1160 if (mark.Get()) continue;
1133 VisitUnmarkedObject(collector, obj); 1161 VisitUnmarkedObject(collector, obj);
1134 } 1162 }
1135 return true; 1163 return true;
1136 } 1164 }
1137 1165
1138 static void VisitJSWeakMap(Map* map, HeapObject* object) { 1166 static void VisitJSWeakMap(Map* map, HeapObject* object) {
1139 MarkCompactCollector* collector = map->GetHeap()->mark_compact_collector(); 1167 MarkCompactCollector* collector = map->GetHeap()->mark_compact_collector();
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
1440 reinterpret_cast<JSFunction*>(object), 1468 reinterpret_cast<JSFunction*>(object),
1441 false); 1469 false);
1442 } 1470 }
1443 1471
1444 1472
1445 static inline void VisitJSFunctionFields(Map* map, 1473 static inline void VisitJSFunctionFields(Map* map,
1446 JSFunction* object, 1474 JSFunction* object,
1447 bool flush_code_candidate) { 1475 bool flush_code_candidate) {
1448 Heap* heap = map->GetHeap(); 1476 Heap* heap = map->GetHeap();
1449 1477
1450 VisitPointers(heap, 1478 Object** start_slot =
1451 HeapObject::RawField(object, JSFunction::kPropertiesOffset), 1479 HeapObject::RawField(object, JSFunction::kPropertiesOffset);
1452 HeapObject::RawField(object, JSFunction::kCodeEntryOffset)); 1480 Object** end_slot =
1481 HeapObject::RawField(object, JSFunction::kCodeEntryOffset);
1482 VisitPointers(heap, start_slot, start_slot, end_slot);
1453 1483
1454 if (!flush_code_candidate) { 1484 if (!flush_code_candidate) {
1455 VisitCodeEntry(heap, object->address() + JSFunction::kCodeEntryOffset); 1485 VisitCodeEntry(heap, object->address() + JSFunction::kCodeEntryOffset);
1456 } else { 1486 } else {
1457 // Don't visit code object. 1487 // Don't visit code object.
1458 1488
1459 // Visit shared function info to avoid double checking of its 1489 // Visit shared function info to avoid double checking of its
1460 // flushability. 1490 // flushability.
1461 SharedFunctionInfo* shared_info = object->unchecked_shared(); 1491 SharedFunctionInfo* shared_info = object->unchecked_shared();
1462 MarkBit shared_info_mark = Marking::MarkBitFrom(shared_info); 1492 MarkBit shared_info_mark = Marking::MarkBitFrom(shared_info);
1463 if (!shared_info_mark.Get()) { 1493 if (!shared_info_mark.Get()) {
1464 Map* shared_info_map = shared_info->map(); 1494 Map* shared_info_map = shared_info->map();
1465 MarkBit shared_info_map_mark = 1495 MarkBit shared_info_map_mark =
1466 Marking::MarkBitFrom(shared_info_map); 1496 Marking::MarkBitFrom(shared_info_map);
1467 heap->mark_compact_collector()->SetMark(shared_info, shared_info_mark); 1497 heap->mark_compact_collector()->SetMark(shared_info, shared_info_mark);
1468 heap->mark_compact_collector()->MarkObject(shared_info_map, 1498 heap->mark_compact_collector()->MarkObject(shared_info_map,
1469 shared_info_map_mark); 1499 shared_info_map_mark);
1470 VisitSharedFunctionInfoAndFlushCodeGeneric(shared_info_map, 1500 VisitSharedFunctionInfoAndFlushCodeGeneric(shared_info_map,
1471 shared_info, 1501 shared_info,
1472 true); 1502 true);
1473 } 1503 }
1474 } 1504 }
1475 1505
1476 VisitPointers( 1506 start_slot =
1477 heap,
1478 HeapObject::RawField(object, 1507 HeapObject::RawField(object,
1479 JSFunction::kCodeEntryOffset + kPointerSize), 1508 JSFunction::kCodeEntryOffset + kPointerSize);
1480 HeapObject::RawField(object, JSFunction::kNonWeakFieldsEndOffset)); 1509 end_slot =
1510 HeapObject::RawField(object, JSFunction::kNonWeakFieldsEndOffset);
1511 VisitPointers(heap, start_slot, start_slot, end_slot);
1481 } 1512 }
1482 1513
1483 1514
1484 static void VisitSharedFunctionInfoFields(Heap* heap, 1515 static void VisitSharedFunctionInfoFields(Heap* heap,
1485 HeapObject* object, 1516 HeapObject* object,
1486 bool flush_code_candidate) { 1517 bool flush_code_candidate) {
1487 VisitPointer(heap, 1518 VisitPointer(heap,
1488 HeapObject::RawField(object, SharedFunctionInfo::kNameOffset)); 1519 HeapObject::RawField(object, SharedFunctionInfo::kNameOffset));
1489 1520
1490 if (!flush_code_candidate) { 1521 if (!flush_code_candidate) {
1491 VisitPointer(heap, 1522 VisitPointer(heap,
1492 HeapObject::RawField(object, 1523 HeapObject::RawField(object,
1493 SharedFunctionInfo::kCodeOffset)); 1524 SharedFunctionInfo::kCodeOffset));
1494 } 1525 }
1495 1526
1496 VisitPointers( 1527 Object** start_slot =
1497 heap,
1498 HeapObject::RawField(object, 1528 HeapObject::RawField(object,
1499 SharedFunctionInfo::kOptimizedCodeMapOffset), 1529 SharedFunctionInfo::kOptimizedCodeMapOffset);
1500 HeapObject::RawField(object, SharedFunctionInfo::kSize)); 1530 Object** end_slot =
1531 HeapObject::RawField(object, SharedFunctionInfo::kSize);
1532
1533 VisitPointers(heap, start_slot, start_slot, end_slot);
1501 } 1534 }
1502 1535
1503 static VisitorDispatchTable<Callback> non_count_table_; 1536 static VisitorDispatchTable<Callback> non_count_table_;
1504 }; 1537 };
1505 1538
1506 1539
1540 void MarkCompactMarkingVisitor::VisitHugeFixedArray(Heap* heap,
1541 FixedArray* array,
1542 int length) {
1543 MemoryChunk* chunk = MemoryChunk::FromAddress(array->address());
1544
1545 ASSERT(chunk->owner()->identity() == LO_SPACE);
1546
1547 Object** start_slot = array->data_start();
1548 int from =
1549 chunk->IsPartiallyScanned() ? chunk->PartiallyScannedProgress() : 0;
1550 int to = Min(from + kScanningChunk, length);
1551 VisitPointers(heap, start_slot, start_slot + from, start_slot + to);
1552
1553 if (to == length) {
1554 chunk->SetCompletelyScanned();
1555 } else {
1556 chunk->SetPartiallyScannedProgress(to);
1557 }
1558 }
1559
1560
1507 void MarkCompactMarkingVisitor::ObjectStatsCountFixedArray( 1561 void MarkCompactMarkingVisitor::ObjectStatsCountFixedArray(
1508 FixedArrayBase* fixed_array, 1562 FixedArrayBase* fixed_array,
1509 FixedArraySubInstanceType fast_type, 1563 FixedArraySubInstanceType fast_type,
1510 FixedArraySubInstanceType dictionary_type) { 1564 FixedArraySubInstanceType dictionary_type) {
1511 Heap* heap = fixed_array->map()->GetHeap(); 1565 Heap* heap = fixed_array->map()->GetHeap();
1512 if (fixed_array->map() != heap->fixed_cow_array_map() && 1566 if (fixed_array->map() != heap->fixed_cow_array_map() &&
1513 fixed_array->map() != heap->fixed_double_array_map() && 1567 fixed_array->map() != heap->fixed_double_array_map() &&
1514 fixed_array != heap->empty_fixed_array()) { 1568 fixed_array != heap->empty_fixed_array()) {
1515 if (fixed_array->IsDictionary()) { 1569 if (fixed_array->IsDictionary()) {
1516 heap->RecordObjectStats(FIXED_ARRAY_TYPE, 1570 heap->RecordObjectStats(FIXED_ARRAY_TYPE,
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
1638 1692
1639 table_.Register(kVisitSharedFunctionInfo, 1693 table_.Register(kVisitSharedFunctionInfo,
1640 &VisitSharedFunctionInfoAndFlushCode); 1694 &VisitSharedFunctionInfoAndFlushCode);
1641 1695
1642 table_.Register(kVisitJSFunction, 1696 table_.Register(kVisitJSFunction,
1643 &VisitJSFunctionAndFlushCode); 1697 &VisitJSFunctionAndFlushCode);
1644 1698
1645 table_.Register(kVisitJSRegExp, 1699 table_.Register(kVisitJSRegExp,
1646 &VisitRegExpAndFlushCode); 1700 &VisitRegExpAndFlushCode);
1647 1701
1702 table_.Register(kVisitFixedArray,
1703 &VisitFixedArray);
1704
1648 if (FLAG_track_gc_object_stats) { 1705 if (FLAG_track_gc_object_stats) {
1649 // Copy the visitor table to make call-through possible. 1706 // Copy the visitor table to make call-through possible.
1650 non_count_table_.CopyFrom(&table_); 1707 non_count_table_.CopyFrom(&table_);
1651 #define VISITOR_ID_COUNT_FUNCTION(id) \ 1708 #define VISITOR_ID_COUNT_FUNCTION(id) \
1652 table_.Register(kVisit##id, ObjectStatsTracker<kVisit##id>::Visit); 1709 table_.Register(kVisit##id, ObjectStatsTracker<kVisit##id>::Visit);
1653 VISITOR_ID_LIST(VISITOR_ID_COUNT_FUNCTION) 1710 VISITOR_ID_LIST(VISITOR_ID_COUNT_FUNCTION)
1654 #undef VISITOR_ID_COUNT_FUNCTION 1711 #undef VISITOR_ID_COUNT_FUNCTION
1655 } 1712 }
1656 } 1713 }
1657 1714
1658 1715
1659 VisitorDispatchTable<MarkCompactMarkingVisitor::Callback> 1716 VisitorDispatchTable<MarkCompactMarkingVisitor::Callback>
1660 MarkCompactMarkingVisitor::non_count_table_; 1717 MarkCompactMarkingVisitor::non_count_table_;
1661 1718
1662 1719
1663 class MarkingVisitor : public ObjectVisitor { 1720 class MarkingVisitor : public ObjectVisitor {
1664 public: 1721 public:
1665 explicit MarkingVisitor(Heap* heap) : heap_(heap) { } 1722 explicit MarkingVisitor(Heap* heap) : heap_(heap) { }
1666 1723
1667 void VisitPointer(Object** p) { 1724 void VisitPointer(Object** p) {
1668 MarkCompactMarkingVisitor::VisitPointer(heap_, p); 1725 MarkCompactMarkingVisitor::VisitPointer(heap_, p);
1669 } 1726 }
1670 1727
1671 void VisitPointers(Object** start, Object** end) { 1728 void VisitPointers(Object** start_slot, Object** end_slot) {
1672 MarkCompactMarkingVisitor::VisitPointers(heap_, start, end); 1729 MarkCompactMarkingVisitor::VisitPointers(
1730 heap_, start_slot, start_slot, end_slot);
1673 } 1731 }
1674 1732
1675 private: 1733 private:
1676 Heap* heap_; 1734 Heap* heap_;
1677 }; 1735 };
1678 1736
1679 1737
1680 class CodeMarkingVisitor : public ThreadVisitor { 1738 class CodeMarkingVisitor : public ThreadVisitor {
1681 public: 1739 public:
1682 explicit CodeMarkingVisitor(MarkCompactCollector* collector) 1740 explicit CodeMarkingVisitor(MarkCompactCollector* collector)
1683 : collector_(collector) {} 1741 : collector_(collector) {}
1684 1742
1685 void VisitThread(Isolate* isolate, ThreadLocalTop* top) { 1743 void VisitThread(Isolate* isolate, ThreadLocalTop* top) {
1686 collector_->PrepareThreadForCodeFlushing(isolate, top); 1744 collector_->PrepareThreadForCodeFlushing(isolate, top);
1687 } 1745 }
1688 1746
1689 private: 1747 private:
1690 MarkCompactCollector* collector_; 1748 MarkCompactCollector* collector_;
1691 }; 1749 };
1692 1750
1693 1751
1694 class SharedFunctionInfoMarkingVisitor : public ObjectVisitor { 1752 class SharedFunctionInfoMarkingVisitor : public ObjectVisitor {
1695 public: 1753 public:
1696 explicit SharedFunctionInfoMarkingVisitor(MarkCompactCollector* collector) 1754 explicit SharedFunctionInfoMarkingVisitor(MarkCompactCollector* collector)
1697 : collector_(collector) {} 1755 : collector_(collector) {}
1698 1756
1699 void VisitPointers(Object** start, Object** end) { 1757 void VisitPointers(Object** start_slot, Object** end_slot) {
1700 for (Object** p = start; p < end; p++) VisitPointer(p); 1758 for (Object** p = start_slot; p < end_slot; p++) VisitPointer(p);
1701 } 1759 }
1702 1760
1703 void VisitPointer(Object** slot) { 1761 void VisitPointer(Object** slot) {
1704 Object* obj = *slot; 1762 Object* obj = *slot;
1705 if (obj->IsSharedFunctionInfo()) { 1763 if (obj->IsSharedFunctionInfo()) {
1706 SharedFunctionInfo* shared = reinterpret_cast<SharedFunctionInfo*>(obj); 1764 SharedFunctionInfo* shared = reinterpret_cast<SharedFunctionInfo*>(obj);
1707 MarkBit shared_mark = Marking::MarkBitFrom(shared); 1765 MarkBit shared_mark = Marking::MarkBitFrom(shared);
1708 MarkBit code_mark = Marking::MarkBitFrom(shared->code()); 1766 MarkBit code_mark = Marking::MarkBitFrom(shared->code());
1709 collector_->MarkObject(shared->code(), code_mark); 1767 collector_->MarkObject(shared->code(), code_mark);
1710 collector_->MarkObject(shared, shared_mark); 1768 collector_->MarkObject(shared, shared_mark);
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
1801 // Visitor class for marking heap roots. 1859 // Visitor class for marking heap roots.
1802 class RootMarkingVisitor : public ObjectVisitor { 1860 class RootMarkingVisitor : public ObjectVisitor {
1803 public: 1861 public:
1804 explicit RootMarkingVisitor(Heap* heap) 1862 explicit RootMarkingVisitor(Heap* heap)
1805 : collector_(heap->mark_compact_collector()) { } 1863 : collector_(heap->mark_compact_collector()) { }
1806 1864
1807 void VisitPointer(Object** p) { 1865 void VisitPointer(Object** p) {
1808 MarkObjectByPointer(p); 1866 MarkObjectByPointer(p);
1809 } 1867 }
1810 1868
1811 void VisitPointers(Object** start, Object** end) { 1869 void VisitPointers(Object** start_slot, Object** end_slot) {
1812 for (Object** p = start; p < end; p++) MarkObjectByPointer(p); 1870 for (Object** p = start_slot; p < end_slot; p++) MarkObjectByPointer(p);
1813 } 1871 }
1814 1872
1815 private: 1873 private:
1816 void MarkObjectByPointer(Object** p) { 1874 void MarkObjectByPointer(Object** p) {
1817 if (!(*p)->IsHeapObject()) return; 1875 if (!(*p)->IsHeapObject()) return;
1818 1876
1819 // Replace flat cons strings in place. 1877 // Replace flat cons strings in place.
1820 HeapObject* object = ShortCircuitConsString(p); 1878 HeapObject* object = ShortCircuitConsString(p);
1821 MarkBit mark_bit = Marking::MarkBitFrom(object); 1879 MarkBit mark_bit = Marking::MarkBitFrom(object);
1822 if (mark_bit.Get()) return; 1880 if (mark_bit.Get()) return;
(...skipping 15 matching lines...) Expand all
1838 MarkCompactCollector* collector_; 1896 MarkCompactCollector* collector_;
1839 }; 1897 };
1840 1898
1841 1899
1842 // Helper class for pruning the symbol table. 1900 // Helper class for pruning the symbol table.
1843 class SymbolTableCleaner : public ObjectVisitor { 1901 class SymbolTableCleaner : public ObjectVisitor {
1844 public: 1902 public:
1845 explicit SymbolTableCleaner(Heap* heap) 1903 explicit SymbolTableCleaner(Heap* heap)
1846 : heap_(heap), pointers_removed_(0) { } 1904 : heap_(heap), pointers_removed_(0) { }
1847 1905
1848 virtual void VisitPointers(Object** start, Object** end) { 1906 virtual void VisitPointers(Object** start_slot, Object** end_slot) {
1849 // Visit all HeapObject pointers in [start, end). 1907 // Visit all HeapObject pointers in [start_slot, end_slot).
1850 for (Object** p = start; p < end; p++) { 1908 for (Object** p = start_slot; p < end_slot; p++) {
1851 Object* o = *p; 1909 Object* o = *p;
1852 if (o->IsHeapObject() && 1910 if (o->IsHeapObject() &&
1853 !Marking::MarkBitFrom(HeapObject::cast(o)).Get()) { 1911 !Marking::MarkBitFrom(HeapObject::cast(o)).Get()) {
1854 // Check if the symbol being pruned is an external symbol. We need to 1912 // Check if the symbol being pruned is an external symbol. We need to
1855 // delete the associated external data as this symbol is going away. 1913 // delete the associated external data as this symbol is going away.
1856 1914
1857 // Since no objects have yet been moved we can safely access the map of 1915 // Since no objects have yet been moved we can safely access the map of
1858 // the object. 1916 // the object.
1859 if (o->IsExternalString()) { 1917 if (o->IsExternalString()) {
1860 heap_->FinalizeExternalString(String::cast(*p)); 1918 heap_->FinalizeExternalString(String::cast(*p));
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
2121 ASSERT(object->IsHeapObject()); 2179 ASSERT(object->IsHeapObject());
2122 ASSERT(heap()->Contains(object)); 2180 ASSERT(heap()->Contains(object));
2123 ASSERT(Marking::IsBlack(Marking::MarkBitFrom(object))); 2181 ASSERT(Marking::IsBlack(Marking::MarkBitFrom(object)));
2124 2182
2125 Map* map = object->map(); 2183 Map* map = object->map();
2126 MarkBit map_mark = Marking::MarkBitFrom(map); 2184 MarkBit map_mark = Marking::MarkBitFrom(map);
2127 MarkObject(map, map_mark); 2185 MarkObject(map, map_mark);
2128 2186
2129 MarkCompactMarkingVisitor::IterateBody(map, object); 2187 MarkCompactMarkingVisitor::IterateBody(map, object);
2130 } 2188 }
2189 ProcessLargePostponedArrays(heap(), &marking_deque_);
2131 2190
2132 // Process encountered weak maps, mark objects only reachable by those 2191 // Process encountered weak maps, mark objects only reachable by those
2133 // weak maps and repeat until fix-point is reached. 2192 // weak maps and repeat until fix-point is reached.
2134 ProcessWeakMaps(); 2193 ProcessWeakMaps();
2135 } 2194 }
2136 } 2195 }
2137 2196
2138 2197
2198 void MarkCompactCollector::ProcessLargePostponedArrays(Heap* heap,
2199 MarkingDeque* deque) {
2200 ASSERT(deque->IsEmpty());
2201 LargeObjectIterator it(heap->lo_space());
2202 for (HeapObject* obj = it.Next(); obj != NULL; obj = it.Next()) {
2203 if (!obj->IsFixedArray()) continue;
2204 MemoryChunk* p = MemoryChunk::FromAddress(obj->address());
2205 if (p->IsPartiallyScanned()) {
2206 deque->PushBlack(obj);
2207 }
2208 }
2209 }
2210
2211
2139 // Sweep the heap for overflowed objects, clear their overflow bits, and 2212 // Sweep the heap for overflowed objects, clear their overflow bits, and
2140 // push them on the marking stack. Stop early if the marking stack fills 2213 // push them on the marking stack. Stop early if the marking stack fills
2141 // before sweeping completes. If sweeping completes, there are no remaining 2214 // before sweeping completes. If sweeping completes, there are no remaining
2142 // overflowed objects in the heap so the overflow flag on the markings stack 2215 // overflowed objects in the heap so the overflow flag on the markings stack
2143 // is cleared. 2216 // is cleared.
2144 void MarkCompactCollector::RefillMarkingDeque() { 2217 void MarkCompactCollector::RefillMarkingDeque() {
2218 if (FLAG_trace_gc) {
2219 PrintPID("Marking queue overflowed\n");
2220 }
2145 ASSERT(marking_deque_.overflowed()); 2221 ASSERT(marking_deque_.overflowed());
2146 2222
2147 SemiSpaceIterator new_it(heap()->new_space()); 2223 SemiSpaceIterator new_it(heap()->new_space());
2148 DiscoverGreyObjectsWithIterator(heap(), &marking_deque_, &new_it); 2224 DiscoverGreyObjectsWithIterator(heap(), &marking_deque_, &new_it);
2149 if (marking_deque_.IsFull()) return; 2225 if (marking_deque_.IsFull()) return;
2150 2226
2151 DiscoverGreyObjectsInSpace(heap(), 2227 DiscoverGreyObjectsInSpace(heap(),
2152 &marking_deque_, 2228 &marking_deque_,
2153 heap()->old_pointer_space()); 2229 heap()->old_pointer_space());
2154 if (marking_deque_.IsFull()) return; 2230 if (marking_deque_.IsFull()) return;
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after
2625 // Visitor for updating pointers from live objects in old spaces to new space. 2701 // Visitor for updating pointers from live objects in old spaces to new space.
2626 // It does not expect to encounter pointers to dead objects. 2702 // It does not expect to encounter pointers to dead objects.
2627 class PointersUpdatingVisitor: public ObjectVisitor { 2703 class PointersUpdatingVisitor: public ObjectVisitor {
2628 public: 2704 public:
2629 explicit PointersUpdatingVisitor(Heap* heap) : heap_(heap) { } 2705 explicit PointersUpdatingVisitor(Heap* heap) : heap_(heap) { }
2630 2706
2631 void VisitPointer(Object** p) { 2707 void VisitPointer(Object** p) {
2632 UpdatePointer(p); 2708 UpdatePointer(p);
2633 } 2709 }
2634 2710
2635 void VisitPointers(Object** start, Object** end) { 2711 void VisitPointers(Object** start_slot, Object** end_slot) {
2636 for (Object** p = start; p < end; p++) UpdatePointer(p); 2712 for (Object** p = start_slot; p < end_slot; p++) UpdatePointer(p);
2637 } 2713 }
2638 2714
2639 void VisitEmbeddedPointer(RelocInfo* rinfo) { 2715 void VisitEmbeddedPointer(RelocInfo* rinfo) {
2640 ASSERT(rinfo->rmode() == RelocInfo::EMBEDDED_OBJECT); 2716 ASSERT(rinfo->rmode() == RelocInfo::EMBEDDED_OBJECT);
2641 Object* target = rinfo->target_object(); 2717 Object* target = rinfo->target_object();
2642 VisitPointer(&target); 2718 VisitPointer(&target);
2643 rinfo->set_target_object(target); 2719 rinfo->set_target_object(target);
2644 } 2720 }
2645 2721
2646 void VisitCodeTarget(RelocInfo* rinfo) { 2722 void VisitCodeTarget(RelocInfo* rinfo) {
(...skipping 1418 matching lines...) Expand 10 before | Expand all | Expand 10 after
4065 while (buffer != NULL) { 4141 while (buffer != NULL) {
4066 SlotsBuffer* next_buffer = buffer->next(); 4142 SlotsBuffer* next_buffer = buffer->next();
4067 DeallocateBuffer(buffer); 4143 DeallocateBuffer(buffer);
4068 buffer = next_buffer; 4144 buffer = next_buffer;
4069 } 4145 }
4070 *buffer_address = NULL; 4146 *buffer_address = NULL;
4071 } 4147 }
4072 4148
4073 4149
4074 } } // namespace v8::internal 4150 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/mark-compact.h ('k') | src/mark-compact-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698