Skip to content

Commit e71129e

Browse files
committed
deps: cherry-pick a715957 from V8 upstream
Original commit message: Iterate handles with special left-trim visitor BUG=chromium:620553 LOG=N R=hpayer@chromium.org Review-Url: https://codereview.chromium.org/2102243002 Cr-Commit-Position: refs/heads/master@{#37366} PR-URL: #10666 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com> Reviewed-By: Ali Ijaz Sheikh <ofrobots@google.com>
1 parent 87839ca commit e71129e

File tree

5 files changed

+45
-35
lines changed

5 files changed

+45
-35
lines changed

deps/v8/src/heap/heap-inl.h

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -449,31 +449,6 @@ void Heap::CopyBlock(Address dst, Address src, int byte_size) {
449449
static_cast<size_t>(byte_size / kPointerSize));
450450
}
451451

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-
477452
template <Heap::FindMementoMode mode>
478453
AllocationMemento* Heap::FindAllocationMemento(HeapObject* object) {
479454
// Check if there is potentially a memento behind the object. If

deps/v8/src/heap/heap.cc

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4800,6 +4800,49 @@ void Heap::IterateSmiRoots(ObjectVisitor* v) {
48004800
v->Synchronize(VisitorSynchronization::kSmiRootList);
48014801
}
48024802

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+
};
48034846

48044847
void Heap::IterateStrongRoots(ObjectVisitor* v, VisitMode mode) {
48054848
v->VisitPointers(&roots_[0], &roots_[kStrongRootListLength]);
@@ -4820,6 +4863,8 @@ void Heap::IterateStrongRoots(ObjectVisitor* v, VisitMode mode) {
48204863
v->Synchronize(VisitorSynchronization::kCompilationCache);
48214864

48224865
// Iterate over local handles in handle scopes.
4866+
FixStaleLeftTrimmedHandlesVisitor left_trim_visitor(this);
4867+
isolate_->handle_scope_implementer()->Iterate(&left_trim_visitor);
48234868
isolate_->handle_scope_implementer()->Iterate(v);
48244869
isolate_->IterateDeferredHandles(v);
48254870
v->Synchronize(VisitorSynchronization::kHandleScope);

deps/v8/src/heap/heap.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -602,12 +602,6 @@ class Heap {
602602
// stored on the map to facilitate fast dispatch for {StaticVisitorBase}.
603603
static int GetStaticVisitorIdForMap(Map* map);
604604

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-
611605
// Notifies the heap that is ok to start marking or other activities that
612606
// should not happen during deserialization.
613607
void NotifyDeserializationComplete();

deps/v8/src/heap/mark-compact.cc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1376,8 +1376,6 @@ class RootMarkingVisitor : public ObjectVisitor {
13761376

13771377
HeapObject* object = HeapObject::cast(*p);
13781378

1379-
if (collector_->heap()->PurgeLeftTrimmedObject(p)) return;
1380-
13811379
MarkBit mark_bit = Marking::MarkBitFrom(object);
13821380
if (Marking::IsBlackOrGrey(mark_bit)) return;
13831381

deps/v8/src/heap/scavenger.cc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -463,8 +463,6 @@ void ScavengeVisitor::ScavengePointer(Object** p) {
463463
Object* object = *p;
464464
if (!heap_->InNewSpace(object)) return;
465465

466-
if (heap_->PurgeLeftTrimmedObject(p)) return;
467-
468466
Scavenger::ScavengeObject(reinterpret_cast<HeapObject**>(p),
469467
reinterpret_cast<HeapObject*>(object));
470468
}

0 commit comments

Comments
 (0)