| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 642ad4f commit 055c6b9
5 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -449,31 +449,6 @@ void Heap::CopyBlock(Address dst, Address src, int byte_size) { | |||
| 449 | 449 | static_cast<size_t>(byte_size / kPointerSize)); | |
| 450 | 450 | } | |
| 451 | 451 | ||
| 452 | - bool Heap::PurgeLeftTrimmedObject(Object** object) { | ||
| 453 | - HeapObject* current = reinterpret_cast<HeapObject*>(*object); | ||
| 454 | - const MapWord map_word = current->map_word(); | ||
| 455 | - if (current->IsFiller() && !map_word.IsForwardingAddress()) { | ||
| 456 | - #ifdef DEBUG | ||
| 457 | - // We need to find a FixedArrayBase map after walking the fillers. | ||
| 458 | - while (current->IsFiller()) { | ||
| 459 | - Address next = reinterpret_cast<Address>(current); | ||
| 460 | - if (current->map() == one_pointer_filler_map()) { | ||
| 461 | - next += kPointerSize; | ||
| 462 | - } else if (current->map() == two_pointer_filler_map()) { | ||
| 463 | - next += 2 * kPointerSize; | ||
| 464 | - } else { | ||
| 465 | - next += current->Size(); | ||
| 466 | - } | ||
| 467 | - current = reinterpret_cast<HeapObject*>(next); | ||
| 468 | - } | ||
| 469 | - DCHECK(current->IsFixedArrayBase()); | ||
| 470 | - #endif // DEBUG | ||
| 471 | - *object = nullptr; | ||
| 472 | - return true; | ||
| 473 | - } | ||
| 474 | - return false; | ||
| 475 | - } | ||
| 476 | - | ||
| 477 | 452 | template <Heap::FindMementoMode mode> | |
| 478 | 453 | AllocationMemento* Heap::FindAllocationMemento(HeapObject* object) { | |
| 479 | 454 | // Check if there is potentially a memento behind the object. If | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4800,6 +4800,49 @@ void Heap::IterateSmiRoots(ObjectVisitor* v) { | |||
| 4800 | 4800 | v->Synchronize(VisitorSynchronization::kSmiRootList); | |
| 4801 | 4801 | } | |
| 4802 | 4802 | ||
| 4803 | + // We cannot avoid stale handles to left-trimmed objects, but can only make | ||
| 4804 | + // sure all handles still needed are updated. Filter out a stale pointer | ||
| 4805 | + // and clear the slot to allow post processing of handles (needed because | ||
| 4806 | + // the sweeper might actually free the underlying page). | ||
| 4807 | + class FixStaleLeftTrimmedHandlesVisitor : public ObjectVisitor { | ||
| 4808 | + public: | ||
| 4809 | + explicit FixStaleLeftTrimmedHandlesVisitor(Heap* heap) : heap_(heap) { | ||
| 4810 | + USE(heap_); | ||
| 4811 | + } | ||
| 4812 | + | ||
| 4813 | + void VisitPointer(Object** p) override { FixHandle(p); } | ||
| 4814 | + | ||
| 4815 | + void VisitPointers(Object** start, Object** end) override { | ||
| 4816 | + for (Object** p = start; p < end; p++) FixHandle(p); | ||
| 4817 | + } | ||
| 4818 | + | ||
| 4819 | + private: | ||
| 4820 | + inline void FixHandle(Object** p) { | ||
| 4821 | + HeapObject* current = reinterpret_cast<HeapObject*>(*p); | ||
| 4822 | + if (!current->IsHeapObject()) return; | ||
| 4823 | + const MapWord map_word = current->map_word(); | ||
| 4824 | + if (!map_word.IsForwardingAddress() && current->IsFiller()) { | ||
| 4825 | + #ifdef DEBUG | ||
| 4826 | + // We need to find a FixedArrayBase map after walking the fillers. | ||
| 4827 | + while (current->IsFiller()) { | ||
| 4828 | + Address next = reinterpret_cast<Address>(current); | ||
| 4829 | + if (current->map() == heap_->one_pointer_filler_map()) { | ||
| 4830 | + next += kPointerSize; | ||
| 4831 | + } else if (current->map() == heap_->two_pointer_filler_map()) { | ||
| 4832 | + next += 2 * kPointerSize; | ||
| 4833 | + } else { | ||
| 4834 | + next += current->Size(); | ||
| 4835 | + } | ||
| 4836 | + current = reinterpret_cast<HeapObject*>(next); | ||
| 4837 | + } | ||
| 4838 | + DCHECK(current->IsFixedArrayBase()); | ||
| 4839 | + #endif // DEBUG | ||
| 4840 | + *p = nullptr; | ||
| 4841 | + } | ||
| 4842 | + } | ||
| 4843 | + | ||
| 4844 | + Heap* heap_; | ||
| 4845 | + }; | ||
| 4803 | 4846 | ||
| 4804 | 4847 | void Heap::IterateStrongRoots(ObjectVisitor* v, VisitMode mode) { | |
| 4805 | 4848 | v->VisitPointers(&roots_[0], &roots_[kStrongRootListLength]); | |
@@ -4820,6 +4863,8 @@ void Heap::IterateStrongRoots(ObjectVisitor* v, VisitMode mode) { | |||
| 4820 | 4863 | v->Synchronize(VisitorSynchronization::kCompilationCache); | |
| 4821 | 4864 | ||
| 4822 | 4865 | // Iterate over local handles in handle scopes. | |
| 4866 | + FixStaleLeftTrimmedHandlesVisitor left_trim_visitor(this); | ||
| 4867 | + isolate_->handle_scope_implementer()->Iterate(&left_trim_visitor); | ||
| 4823 | 4868 | isolate_->handle_scope_implementer()->Iterate(v); | |
| 4824 | 4869 | isolate_->IterateDeferredHandles(v); | |
| 4825 | 4870 | v->Synchronize(VisitorSynchronization::kHandleScope); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -602,12 +602,6 @@ class Heap { | |||
| 602 | 602 | // stored on the map to facilitate fast dispatch for {StaticVisitorBase}. | |
| 603 | 603 | static int GetStaticVisitorIdForMap(Map* map); | |
| 604 | 604 | ||
| 605 | - // We cannot avoid stale handles to left-trimmed objects, but can only make | ||
| 606 | - // sure all handles still needed are updated. Filter out a stale pointer | ||
| 607 | - // and clear the slot to allow post processing of handles (needed because | ||
| 608 | - // the sweeper might actually free the underlying page). | ||
| 609 | - inline bool PurgeLeftTrimmedObject(Object** object); | ||
| 610 | - | ||
| 611 | 605 | // Notifies the heap that is ok to start marking or other activities that | |
| 612 | 606 | // should not happen during deserialization. | |
| 613 | 607 | void NotifyDeserializationComplete(); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1376,8 +1376,6 @@ class RootMarkingVisitor : public ObjectVisitor { | |||
| 1376 | 1376 | ||
| 1377 | 1377 | HeapObject* object = HeapObject::cast(*p); | |
| 1378 | 1378 | ||
| 1379 | - if (collector_->heap()->PurgeLeftTrimmedObject(p)) return; | ||
| 1380 | - | ||
| 1381 | 1379 | MarkBit mark_bit = Marking::MarkBitFrom(object); | |
| 1382 | 1380 | if (Marking::IsBlackOrGrey(mark_bit)) return; | |
| 1383 | 1381 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -463,8 +463,6 @@ void ScavengeVisitor::ScavengePointer(Object** p) { | |||
| 463 | 463 | Object* object = *p; | |
| 464 | 464 | if (!heap_->InNewSpace(object)) return; | |
| 465 | 465 | ||
| 466 | - if (heap_->PurgeLeftTrimmedObject(p)) return; | ||
| 467 | - | ||
| 468 | 466 | Scavenger::ScavengeObject(reinterpret_cast<HeapObject**>(p), | |
| 469 | 467 | reinterpret_cast<HeapObject*>(object)); | |
| 470 | 468 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments