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 #include "src/heap/mark-compact.h" | 5 #include "src/heap/mark-compact.h" |
6 | 6 |
7 #include "src/base/atomicops.h" | 7 #include "src/base/atomicops.h" |
8 #include "src/base/bits.h" | 8 #include "src/base/bits.h" |
9 #include "src/base/sys-info.h" | 9 #include "src/base/sys-info.h" |
10 #include "src/code-stubs.h" | 10 #include "src/code-stubs.h" |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 public: | 55 public: |
56 virtual void Run() = 0; | 56 virtual void Run() = 0; |
57 | 57 |
58 protected: | 58 protected: |
59 explicit MarkingVerifier(Heap* heap) : heap_(heap) {} | 59 explicit MarkingVerifier(Heap* heap) : heap_(heap) {} |
60 | 60 |
61 virtual MarkingState marking_state(MemoryChunk* chunk) = 0; | 61 virtual MarkingState marking_state(MemoryChunk* chunk) = 0; |
62 | 62 |
63 virtual void VerifyPointers(Object** start, Object** end) = 0; | 63 virtual void VerifyPointers(Object** start, Object** end) = 0; |
64 | 64 |
65 void VisitPointers(Object** start, Object** end) override { | 65 void VisitPointers(HeapObject* host, Object** start, Object** end) override { |
66 VerifyPointers(start, end); | 66 VerifyPointers(start, end); |
67 } | 67 } |
68 | 68 |
69 void VisitRootPointers(Root root, Object** start, Object** end) override { | 69 void VisitRootPointers(Root root, Object** start, Object** end) override { |
70 VerifyPointers(start, end); | 70 VerifyPointers(start, end); |
71 } | 71 } |
72 | 72 |
73 void VerifyRoots(VisitMode mode); | 73 void VerifyRoots(VisitMode mode); |
74 void VerifyMarkingOnPage(const Page& page, const MarkingState& state, | 74 void VerifyMarkingOnPage(const Page& page, const MarkingState& state, |
75 Address start, Address end); | 75 Address start, Address end); |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 | 164 |
165 void VerifyPointers(Object** start, Object** end) override { | 165 void VerifyPointers(Object** start, Object** end) override { |
166 for (Object** current = start; current < end; current++) { | 166 for (Object** current = start; current < end; current++) { |
167 if ((*current)->IsHeapObject()) { | 167 if ((*current)->IsHeapObject()) { |
168 HeapObject* object = HeapObject::cast(*current); | 168 HeapObject* object = HeapObject::cast(*current); |
169 CHECK(ObjectMarking::IsBlackOrGrey(object, marking_state(object))); | 169 CHECK(ObjectMarking::IsBlackOrGrey(object, marking_state(object))); |
170 } | 170 } |
171 } | 171 } |
172 } | 172 } |
173 | 173 |
174 void VisitEmbeddedPointer(RelocInfo* rinfo) override { | 174 void VisitEmbeddedPointer(Code* host, RelocInfo* rinfo) override { |
175 DCHECK(rinfo->rmode() == RelocInfo::EMBEDDED_OBJECT); | 175 DCHECK(rinfo->rmode() == RelocInfo::EMBEDDED_OBJECT); |
176 if (!rinfo->host()->IsWeakObject(rinfo->target_object())) { | 176 if (!host->IsWeakObject(rinfo->target_object())) { |
177 Object* p = rinfo->target_object(); | 177 Object* p = rinfo->target_object(); |
178 VisitPointer(&p); | 178 VisitPointer(host, &p); |
179 } | 179 } |
180 } | 180 } |
181 | 181 |
182 void VisitCell(RelocInfo* rinfo) override { | 182 void VisitCellPointer(Code* host, RelocInfo* rinfo) override { |
183 Code* code = rinfo->host(); | |
184 DCHECK(rinfo->rmode() == RelocInfo::CELL); | 183 DCHECK(rinfo->rmode() == RelocInfo::CELL); |
185 if (!code->IsWeakObject(rinfo->target_cell())) { | 184 if (!host->IsWeakObject(rinfo->target_cell())) { |
186 ObjectVisitor::VisitCell(rinfo); | 185 ObjectVisitor::VisitCellPointer(host, rinfo); |
187 } | 186 } |
188 } | 187 } |
189 }; | 188 }; |
190 | 189 |
191 class YoungGenerationMarkingVerifier : public MarkingVerifier { | 190 class YoungGenerationMarkingVerifier : public MarkingVerifier { |
192 public: | 191 public: |
193 explicit YoungGenerationMarkingVerifier(Heap* heap) : MarkingVerifier(heap) {} | 192 explicit YoungGenerationMarkingVerifier(Heap* heap) : MarkingVerifier(heap) {} |
194 | 193 |
195 MarkingState marking_state(MemoryChunk* chunk) override { | 194 MarkingState marking_state(MemoryChunk* chunk) override { |
196 return MarkingState::External(chunk); | 195 return MarkingState::External(chunk); |
(...skipping 16 matching lines...) Expand all Loading... |
213 CHECK(ObjectMarking::IsBlackOrGrey(object, marking_state(object))); | 212 CHECK(ObjectMarking::IsBlackOrGrey(object, marking_state(object))); |
214 } | 213 } |
215 } | 214 } |
216 } | 215 } |
217 }; | 216 }; |
218 | 217 |
219 class EvacuationVerifier : public ObjectVisitor, public RootVisitor { | 218 class EvacuationVerifier : public ObjectVisitor, public RootVisitor { |
220 public: | 219 public: |
221 virtual void Run() = 0; | 220 virtual void Run() = 0; |
222 | 221 |
223 void VisitPointers(Object** start, Object** end) override { | 222 void VisitPointers(HeapObject* host, Object** start, Object** end) override { |
224 VerifyPointers(start, end); | 223 VerifyPointers(start, end); |
225 } | 224 } |
226 | 225 |
227 void VisitRootPointers(Root root, Object** start, Object** end) override { | 226 void VisitRootPointers(Root root, Object** start, Object** end) override { |
228 VerifyPointers(start, end); | 227 VerifyPointers(start, end); |
229 } | 228 } |
230 | 229 |
231 protected: | 230 protected: |
232 explicit EvacuationVerifier(Heap* heap) : heap_(heap) {} | 231 explicit EvacuationVerifier(Heap* heap) : heap_(heap) {} |
233 | 232 |
(...skipping 907 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1141 ClearNextCandidate(function, undefined); | 1140 ClearNextCandidate(function, undefined); |
1142 break; | 1141 break; |
1143 } | 1142 } |
1144 | 1143 |
1145 candidate = next_candidate; | 1144 candidate = next_candidate; |
1146 } | 1145 } |
1147 } | 1146 } |
1148 } | 1147 } |
1149 | 1148 |
1150 | 1149 |
1151 void CodeFlusher::IteratePointersToFromSpace(ObjectVisitor* v) { | |
1152 Heap* heap = isolate_->heap(); | |
1153 | |
1154 JSFunction** slot = &jsfunction_candidates_head_; | |
1155 JSFunction* candidate = jsfunction_candidates_head_; | |
1156 while (candidate != NULL) { | |
1157 if (heap->InFromSpace(candidate)) { | |
1158 v->VisitPointer(reinterpret_cast<Object**>(slot)); | |
1159 } | |
1160 candidate = GetNextCandidate(*slot); | |
1161 slot = GetNextCandidateSlot(*slot); | |
1162 } | |
1163 } | |
1164 | |
1165 class StaticYoungGenerationMarkingVisitor | 1150 class StaticYoungGenerationMarkingVisitor |
1166 : public StaticNewSpaceVisitor<StaticYoungGenerationMarkingVisitor> { | 1151 : public StaticNewSpaceVisitor<StaticYoungGenerationMarkingVisitor> { |
1167 public: | 1152 public: |
1168 static void Initialize(Heap* heap) { | 1153 static void Initialize(Heap* heap) { |
1169 StaticNewSpaceVisitor<StaticYoungGenerationMarkingVisitor>::Initialize(); | 1154 StaticNewSpaceVisitor<StaticYoungGenerationMarkingVisitor>::Initialize(); |
1170 } | 1155 } |
1171 | 1156 |
1172 inline static void VisitPointer(Heap* heap, HeapObject* object, Object** p) { | 1157 inline static void VisitPointer(Heap* heap, HeapObject* object, Object** p) { |
1173 Object* target = *p; | 1158 Object* target = *p; |
1174 if (heap->InNewSpace(target)) { | 1159 if (heap->InNewSpace(target)) { |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1374 private: | 1359 private: |
1375 MarkCompactCollector* collector_; | 1360 MarkCompactCollector* collector_; |
1376 }; | 1361 }; |
1377 | 1362 |
1378 class SharedFunctionInfoMarkingVisitor : public ObjectVisitor, | 1363 class SharedFunctionInfoMarkingVisitor : public ObjectVisitor, |
1379 public RootVisitor { | 1364 public RootVisitor { |
1380 public: | 1365 public: |
1381 explicit SharedFunctionInfoMarkingVisitor(MarkCompactCollector* collector) | 1366 explicit SharedFunctionInfoMarkingVisitor(MarkCompactCollector* collector) |
1382 : collector_(collector) {} | 1367 : collector_(collector) {} |
1383 | 1368 |
1384 void VisitPointers(Object** start, Object** end) override { | 1369 void VisitPointers(HeapObject* host, Object** start, Object** end) override { |
1385 for (Object** p = start; p < end; p++) MarkObject(p); | 1370 for (Object** p = start; p < end; p++) MarkObject(p); |
1386 } | 1371 } |
1387 | 1372 |
1388 void VisitPointer(Object** slot) override { MarkObject(slot); } | 1373 void VisitPointer(HeapObject* host, Object** slot) override { |
| 1374 MarkObject(slot); |
| 1375 } |
1389 | 1376 |
1390 void VisitRootPointers(Root root, Object** start, Object** end) override { | 1377 void VisitRootPointers(Root root, Object** start, Object** end) override { |
1391 for (Object** p = start; p < end; p++) MarkObject(p); | 1378 for (Object** p = start; p < end; p++) MarkObject(p); |
1392 } | 1379 } |
1393 | 1380 |
1394 void VisitRootPointer(Root root, Object** slot) override { MarkObject(slot); } | 1381 void VisitRootPointer(Root root, Object** slot) override { MarkObject(slot); } |
1395 | 1382 |
1396 private: | 1383 private: |
1397 void MarkObject(Object** slot) { | 1384 void MarkObject(Object** slot) { |
1398 Object* obj = *slot; | 1385 Object* obj = *slot; |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1484 | 1471 |
1485 // Visitor class for marking heap roots. | 1472 // Visitor class for marking heap roots. |
1486 // TODO(ulan): Remove ObjectVisitor base class after fixing marking of | 1473 // TODO(ulan): Remove ObjectVisitor base class after fixing marking of |
1487 // the string table and the top optimized code. | 1474 // the string table and the top optimized code. |
1488 class MarkCompactCollector::RootMarkingVisitor : public ObjectVisitor, | 1475 class MarkCompactCollector::RootMarkingVisitor : public ObjectVisitor, |
1489 public RootVisitor { | 1476 public RootVisitor { |
1490 public: | 1477 public: |
1491 explicit RootMarkingVisitor(Heap* heap) | 1478 explicit RootMarkingVisitor(Heap* heap) |
1492 : collector_(heap->mark_compact_collector()) {} | 1479 : collector_(heap->mark_compact_collector()) {} |
1493 | 1480 |
1494 void VisitPointer(Object** p) override { MarkObjectByPointer(p); } | 1481 void VisitPointer(HeapObject* host, Object** p) override { |
| 1482 MarkObjectByPointer(p); |
| 1483 } |
1495 | 1484 |
1496 void VisitPointers(Object** start, Object** end) override { | 1485 void VisitPointers(HeapObject* host, Object** start, Object** end) override { |
1497 for (Object** p = start; p < end; p++) MarkObjectByPointer(p); | 1486 for (Object** p = start; p < end; p++) MarkObjectByPointer(p); |
1498 } | 1487 } |
1499 | 1488 |
1500 void VisitRootPointer(Root root, Object** p) override { | 1489 void VisitRootPointer(Root root, Object** p) override { |
1501 MarkObjectByPointer(p); | 1490 MarkObjectByPointer(p); |
1502 } | 1491 } |
1503 | 1492 |
1504 void VisitRootPointers(Root root, Object** start, Object** end) override { | 1493 void VisitRootPointers(Root root, Object** start, Object** end) override { |
1505 for (Object** p = start; p < end; p++) MarkObjectByPointer(p); | 1494 for (Object** p = start; p < end; p++) MarkObjectByPointer(p); |
1506 } | 1495 } |
1507 | 1496 |
1508 // Skip the weak next code link in a code object, which is visited in | 1497 // Skip the weak next code link in a code object, which is visited in |
1509 // ProcessTopOptimizedFrame. | 1498 // ProcessTopOptimizedFrame. |
1510 void VisitNextCodeLink(Object** p) override {} | 1499 void VisitNextCodeLink(Code* host, Object** p) override {} |
1511 | 1500 |
1512 private: | 1501 private: |
1513 void MarkObjectByPointer(Object** p) { | 1502 void MarkObjectByPointer(Object** p) { |
1514 if (!(*p)->IsHeapObject()) return; | 1503 if (!(*p)->IsHeapObject()) return; |
1515 | 1504 |
1516 HeapObject* object = HeapObject::cast(*p); | 1505 HeapObject* object = HeapObject::cast(*p); |
1517 | 1506 |
1518 if (ObjectMarking::IsBlackOrGrey<MarkBit::NON_ATOMIC>( | 1507 if (ObjectMarking::IsBlackOrGrey<MarkBit::NON_ATOMIC>( |
1519 object, MarkingState::Internal(object))) | 1508 object, MarkingState::Internal(object))) |
1520 return; | 1509 return; |
(...skipping 13 matching lines...) Expand all Loading... |
1534 } | 1523 } |
1535 | 1524 |
1536 MarkCompactCollector* collector_; | 1525 MarkCompactCollector* collector_; |
1537 }; | 1526 }; |
1538 | 1527 |
1539 class InternalizedStringTableCleaner : public ObjectVisitor { | 1528 class InternalizedStringTableCleaner : public ObjectVisitor { |
1540 public: | 1529 public: |
1541 InternalizedStringTableCleaner(Heap* heap, HeapObject* table) | 1530 InternalizedStringTableCleaner(Heap* heap, HeapObject* table) |
1542 : heap_(heap), pointers_removed_(0), table_(table) {} | 1531 : heap_(heap), pointers_removed_(0), table_(table) {} |
1543 | 1532 |
1544 void VisitPointers(Object** start, Object** end) override { | 1533 void VisitPointers(HeapObject* host, Object** start, Object** end) override { |
1545 // Visit all HeapObject pointers in [start, end). | 1534 // Visit all HeapObject pointers in [start, end). |
1546 MarkCompactCollector* collector = heap_->mark_compact_collector(); | 1535 MarkCompactCollector* collector = heap_->mark_compact_collector(); |
1547 Object* the_hole = heap_->the_hole_value(); | 1536 Object* the_hole = heap_->the_hole_value(); |
1548 for (Object** p = start; p < end; p++) { | 1537 for (Object** p = start; p < end; p++) { |
1549 Object* o = *p; | 1538 Object* o = *p; |
1550 if (o->IsHeapObject()) { | 1539 if (o->IsHeapObject()) { |
1551 HeapObject* heap_object = HeapObject::cast(o); | 1540 HeapObject* heap_object = HeapObject::cast(o); |
1552 if (ObjectMarking::IsWhite(heap_object, | 1541 if (ObjectMarking::IsWhite(heap_object, |
1553 MarkingState::Internal(heap_object))) { | 1542 MarkingState::Internal(heap_object))) { |
1554 pointers_removed_++; | 1543 pointers_removed_++; |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1659 PushBlack(object); | 1648 PushBlack(object); |
1660 if (marking_deque()->IsFull()) return; | 1649 if (marking_deque()->IsFull()) return; |
1661 } | 1650 } |
1662 } | 1651 } |
1663 | 1652 |
1664 class RecordMigratedSlotVisitor final : public ObjectVisitor { | 1653 class RecordMigratedSlotVisitor final : public ObjectVisitor { |
1665 public: | 1654 public: |
1666 explicit RecordMigratedSlotVisitor(MarkCompactCollector* collector) | 1655 explicit RecordMigratedSlotVisitor(MarkCompactCollector* collector) |
1667 : collector_(collector) {} | 1656 : collector_(collector) {} |
1668 | 1657 |
1669 inline void VisitPointer(Object** p) final { | 1658 inline void VisitPointer(HeapObject* host, Object** p) final { |
1670 RecordMigratedSlot(*p, reinterpret_cast<Address>(p)); | 1659 RecordMigratedSlot(*p, reinterpret_cast<Address>(p)); |
1671 } | 1660 } |
1672 | 1661 |
1673 inline void VisitPointers(Object** start, Object** end) final { | 1662 inline void VisitPointers(HeapObject* host, Object** start, |
| 1663 Object** end) final { |
1674 while (start < end) { | 1664 while (start < end) { |
1675 RecordMigratedSlot(*start, reinterpret_cast<Address>(start)); | 1665 RecordMigratedSlot(*start, reinterpret_cast<Address>(start)); |
1676 ++start; | 1666 ++start; |
1677 } | 1667 } |
1678 } | 1668 } |
1679 | 1669 |
1680 inline void VisitCodeEntry(Address code_entry_slot) final { | 1670 inline void VisitCodeEntry(JSFunction* host, Address code_entry_slot) final { |
1681 Address code_entry = Memory::Address_at(code_entry_slot); | 1671 Address code_entry = Memory::Address_at(code_entry_slot); |
1682 if (Page::FromAddress(code_entry)->IsEvacuationCandidate()) { | 1672 if (Page::FromAddress(code_entry)->IsEvacuationCandidate()) { |
1683 RememberedSet<OLD_TO_OLD>::InsertTyped(Page::FromAddress(code_entry_slot), | 1673 RememberedSet<OLD_TO_OLD>::InsertTyped(Page::FromAddress(code_entry_slot), |
1684 nullptr, CODE_ENTRY_SLOT, | 1674 nullptr, CODE_ENTRY_SLOT, |
1685 code_entry_slot); | 1675 code_entry_slot); |
1686 } | 1676 } |
1687 } | 1677 } |
1688 | 1678 |
1689 inline void VisitCodeTarget(RelocInfo* rinfo) final { | 1679 inline void VisitCodeTarget(Code* host, RelocInfo* rinfo) final { |
| 1680 DCHECK_EQ(host, rinfo->host()); |
1690 DCHECK(RelocInfo::IsCodeTarget(rinfo->rmode())); | 1681 DCHECK(RelocInfo::IsCodeTarget(rinfo->rmode())); |
1691 Code* target = Code::GetCodeFromTargetAddress(rinfo->target_address()); | 1682 Code* target = Code::GetCodeFromTargetAddress(rinfo->target_address()); |
1692 Code* host = rinfo->host(); | |
1693 // The target is always in old space, we don't have to record the slot in | 1683 // The target is always in old space, we don't have to record the slot in |
1694 // the old-to-new remembered set. | 1684 // the old-to-new remembered set. |
1695 DCHECK(!collector_->heap()->InNewSpace(target)); | 1685 DCHECK(!collector_->heap()->InNewSpace(target)); |
1696 collector_->RecordRelocSlot(host, rinfo, target); | 1686 collector_->RecordRelocSlot(host, rinfo, target); |
1697 } | 1687 } |
1698 | 1688 |
1699 inline void VisitDebugTarget(RelocInfo* rinfo) final { | 1689 inline void VisitDebugTarget(Code* host, RelocInfo* rinfo) final { |
| 1690 DCHECK_EQ(host, rinfo->host()); |
1700 DCHECK(RelocInfo::IsDebugBreakSlot(rinfo->rmode()) && | 1691 DCHECK(RelocInfo::IsDebugBreakSlot(rinfo->rmode()) && |
1701 rinfo->IsPatchedDebugBreakSlotSequence()); | 1692 rinfo->IsPatchedDebugBreakSlotSequence()); |
1702 Code* target = Code::GetCodeFromTargetAddress(rinfo->debug_call_address()); | 1693 Code* target = Code::GetCodeFromTargetAddress(rinfo->debug_call_address()); |
1703 Code* host = rinfo->host(); | |
1704 // The target is always in old space, we don't have to record the slot in | 1694 // The target is always in old space, we don't have to record the slot in |
1705 // the old-to-new remembered set. | 1695 // the old-to-new remembered set. |
1706 DCHECK(!collector_->heap()->InNewSpace(target)); | 1696 DCHECK(!collector_->heap()->InNewSpace(target)); |
1707 collector_->RecordRelocSlot(host, rinfo, target); | 1697 collector_->RecordRelocSlot(host, rinfo, target); |
1708 } | 1698 } |
1709 | 1699 |
1710 inline void VisitEmbeddedPointer(RelocInfo* rinfo) final { | 1700 inline void VisitEmbeddedPointer(Code* host, RelocInfo* rinfo) final { |
| 1701 DCHECK_EQ(host, rinfo->host()); |
1711 DCHECK(rinfo->rmode() == RelocInfo::EMBEDDED_OBJECT); | 1702 DCHECK(rinfo->rmode() == RelocInfo::EMBEDDED_OBJECT); |
1712 HeapObject* object = HeapObject::cast(rinfo->target_object()); | 1703 HeapObject* object = HeapObject::cast(rinfo->target_object()); |
1713 Code* host = rinfo->host(); | |
1714 collector_->heap()->RecordWriteIntoCode(host, rinfo, object); | 1704 collector_->heap()->RecordWriteIntoCode(host, rinfo, object); |
1715 collector_->RecordRelocSlot(host, rinfo, object); | 1705 collector_->RecordRelocSlot(host, rinfo, object); |
1716 } | 1706 } |
1717 | 1707 |
1718 inline void VisitCell(RelocInfo* rinfo) final { | 1708 inline void VisitCellPointer(Code* host, RelocInfo* rinfo) final { |
| 1709 DCHECK_EQ(host, rinfo->host()); |
1719 DCHECK(rinfo->rmode() == RelocInfo::CELL); | 1710 DCHECK(rinfo->rmode() == RelocInfo::CELL); |
1720 Cell* cell = rinfo->target_cell(); | 1711 Cell* cell = rinfo->target_cell(); |
1721 Code* host = rinfo->host(); | |
1722 // The cell is always in old space, we don't have to record the slot in | 1712 // The cell is always in old space, we don't have to record the slot in |
1723 // the old-to-new remembered set. | 1713 // the old-to-new remembered set. |
1724 DCHECK(!collector_->heap()->InNewSpace(cell)); | 1714 DCHECK(!collector_->heap()->InNewSpace(cell)); |
1725 collector_->RecordRelocSlot(host, rinfo, cell); | 1715 collector_->RecordRelocSlot(host, rinfo, cell); |
1726 } | 1716 } |
1727 | 1717 |
1728 // Entries that will never move. | 1718 // Entries that will never move. |
1729 inline void VisitCodeAgeSequence(RelocInfo* rinfo) final { | 1719 inline void VisitCodeAgeSequence(Code* host, RelocInfo* rinfo) final { |
| 1720 DCHECK_EQ(host, rinfo->host()); |
1730 DCHECK(RelocInfo::IsCodeAgeSequence(rinfo->rmode())); | 1721 DCHECK(RelocInfo::IsCodeAgeSequence(rinfo->rmode())); |
1731 Code* stub = rinfo->code_age_stub(); | 1722 Code* stub = rinfo->code_age_stub(); |
1732 USE(stub); | 1723 USE(stub); |
1733 DCHECK(!Page::FromAddress(stub->address())->IsEvacuationCandidate()); | 1724 DCHECK(!Page::FromAddress(stub->address())->IsEvacuationCandidate()); |
1734 } | 1725 } |
1735 | 1726 |
1736 // Entries that are skipped for recording. | 1727 // Entries that are skipped for recording. |
1737 inline void VisitExternalReference(RelocInfo* rinfo) final {} | 1728 inline void VisitExternalReference(Code* host, RelocInfo* rinfo) final {} |
1738 inline void VisitExternalReference(Address* p) final {} | 1729 inline void VisitExternalReference(Foreign* host, Address* p) final {} |
1739 inline void VisitRuntimeEntry(RelocInfo* rinfo) final {} | 1730 inline void VisitRuntimeEntry(Code* host, RelocInfo* rinfo) final {} |
1740 inline void VisitInternalReference(RelocInfo* rinfo) final {} | 1731 inline void VisitInternalReference(Code* host, RelocInfo* rinfo) final {} |
1741 | 1732 |
1742 private: | 1733 private: |
1743 inline void RecordMigratedSlot(Object* value, Address slot) { | 1734 inline void RecordMigratedSlot(Object* value, Address slot) { |
1744 if (value->IsHeapObject()) { | 1735 if (value->IsHeapObject()) { |
1745 Page* p = Page::FromAddress(reinterpret_cast<Address>(value)); | 1736 Page* p = Page::FromAddress(reinterpret_cast<Address>(value)); |
1746 if (p->InNewSpace()) { | 1737 if (p->InNewSpace()) { |
1747 RememberedSet<OLD_TO_NEW>::Insert(Page::FromAddress(slot), slot); | 1738 RememberedSet<OLD_TO_NEW>::Insert(Page::FromAddress(slot), slot); |
1748 } else if (p->IsEvacuationCandidate()) { | 1739 } else if (p->IsEvacuationCandidate()) { |
1749 RememberedSet<OLD_TO_OLD>::Insert(Page::FromAddress(slot), slot); | 1740 RememberedSet<OLD_TO_OLD>::Insert(Page::FromAddress(slot), slot); |
1750 } | 1741 } |
(...skipping 1334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3085 } | 3076 } |
3086 return REMOVE_SLOT; | 3077 return REMOVE_SLOT; |
3087 } | 3078 } |
3088 | 3079 |
3089 // Visitor for updating root pointers and to-space pointers. | 3080 // Visitor for updating root pointers and to-space pointers. |
3090 // It does not expect to encounter pointers to dead objects. | 3081 // It does not expect to encounter pointers to dead objects. |
3091 // TODO(ulan): Remove code object specific functions. This visitor | 3082 // TODO(ulan): Remove code object specific functions. This visitor |
3092 // nevers visits code objects. | 3083 // nevers visits code objects. |
3093 class PointersUpdatingVisitor : public ObjectVisitor, public RootVisitor { | 3084 class PointersUpdatingVisitor : public ObjectVisitor, public RootVisitor { |
3094 public: | 3085 public: |
3095 void VisitPointer(Object** p) override { UpdateSlot(p); } | 3086 void VisitPointer(HeapObject* host, Object** p) override { UpdateSlot(p); } |
3096 | 3087 |
3097 void VisitPointers(Object** start, Object** end) override { | 3088 void VisitPointers(HeapObject* host, Object** start, Object** end) override { |
3098 for (Object** p = start; p < end; p++) UpdateSlot(p); | 3089 for (Object** p = start; p < end; p++) UpdateSlot(p); |
3099 } | 3090 } |
3100 | 3091 |
3101 void VisitRootPointer(Root root, Object** p) override { UpdateSlot(p); } | 3092 void VisitRootPointer(Root root, Object** p) override { UpdateSlot(p); } |
3102 | 3093 |
3103 void VisitRootPointers(Root root, Object** start, Object** end) override { | 3094 void VisitRootPointers(Root root, Object** start, Object** end) override { |
3104 for (Object** p = start; p < end; p++) UpdateSlot(p); | 3095 for (Object** p = start; p < end; p++) UpdateSlot(p); |
3105 } | 3096 } |
3106 | 3097 |
3107 void VisitCell(RelocInfo* rinfo) override { | 3098 void VisitCellPointer(Code* host, RelocInfo* rinfo) override { |
3108 UpdateTypedSlotHelper::UpdateCell(rinfo, UpdateSlot); | 3099 UpdateTypedSlotHelper::UpdateCell(rinfo, UpdateSlot); |
3109 } | 3100 } |
3110 | 3101 |
3111 void VisitEmbeddedPointer(RelocInfo* rinfo) override { | 3102 void VisitEmbeddedPointer(Code* host, RelocInfo* rinfo) override { |
3112 UpdateTypedSlotHelper::UpdateEmbeddedPointer(rinfo, UpdateSlot); | 3103 UpdateTypedSlotHelper::UpdateEmbeddedPointer(rinfo, UpdateSlot); |
3113 } | 3104 } |
3114 | 3105 |
3115 void VisitCodeTarget(RelocInfo* rinfo) override { | 3106 void VisitCodeTarget(Code* host, RelocInfo* rinfo) override { |
3116 UpdateTypedSlotHelper::UpdateCodeTarget(rinfo, UpdateSlot); | 3107 UpdateTypedSlotHelper::UpdateCodeTarget(rinfo, UpdateSlot); |
3117 } | 3108 } |
3118 | 3109 |
3119 void VisitCodeEntry(Address entry_address) override { | 3110 void VisitCodeEntry(JSFunction* host, Address entry_address) override { |
3120 UpdateTypedSlotHelper::UpdateCodeEntry(entry_address, UpdateSlot); | 3111 UpdateTypedSlotHelper::UpdateCodeEntry(entry_address, UpdateSlot); |
3121 } | 3112 } |
3122 | 3113 |
3123 void VisitDebugTarget(RelocInfo* rinfo) override { | 3114 void VisitDebugTarget(Code* host, RelocInfo* rinfo) override { |
3124 UpdateTypedSlotHelper::UpdateDebugTarget(rinfo, UpdateSlot); | 3115 UpdateTypedSlotHelper::UpdateDebugTarget(rinfo, UpdateSlot); |
3125 } | 3116 } |
3126 }; | 3117 }; |
3127 | 3118 |
3128 static String* UpdateReferenceInExternalStringTableEntry(Heap* heap, | 3119 static String* UpdateReferenceInExternalStringTableEntry(Heap* heap, |
3129 Object** p) { | 3120 Object** p) { |
3130 MapWord map_word = HeapObject::cast(*p)->map_word(); | 3121 MapWord map_word = HeapObject::cast(*p)->map_word(); |
3131 | 3122 |
3132 if (map_word.IsForwardingAddress()) { | 3123 if (map_word.IsForwardingAddress()) { |
3133 return String::cast(map_word.ToForwardingAddress()); | 3124 return String::cast(map_word.ToForwardingAddress()); |
(...skipping 1076 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4210 // The target is always in old space, we don't have to record the slot in | 4201 // The target is always in old space, we don't have to record the slot in |
4211 // the old-to-new remembered set. | 4202 // the old-to-new remembered set. |
4212 DCHECK(!heap()->InNewSpace(target)); | 4203 DCHECK(!heap()->InNewSpace(target)); |
4213 RecordRelocSlot(host, &rinfo, target); | 4204 RecordRelocSlot(host, &rinfo, target); |
4214 } | 4205 } |
4215 } | 4206 } |
4216 } | 4207 } |
4217 | 4208 |
4218 } // namespace internal | 4209 } // namespace internal |
4219 } // namespace v8 | 4210 } // namespace v8 |
OLD | NEW |