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

Unified Diff: src/heap/mark-compact.cc

Issue 2078403002: [heap] Filter out stale left-trimmed handles (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Remove check that ensure that only a single handle points to left-trimmed array Created 4 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/heap/heap.cc ('k') | test/mjsunit/regress/regress-620553.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/heap/mark-compact.cc
diff --git a/src/heap/mark-compact.cc b/src/heap/mark-compact.cc
index 5f1c6de4a8f6fe98f91358f67b8e414fb2e91b5d..4fdb3abc4dae5ba9feb95c099da5a328e8aa3b7d 100644
--- a/src/heap/mark-compact.cc
+++ b/src/heap/mark-compact.cc
@@ -1418,8 +1418,34 @@ class RootMarkingVisitor : public ObjectVisitor {
void MarkObjectByPointer(Object** p) {
if (!(*p)->IsHeapObject()) return;
- // Replace flat cons strings in place.
HeapObject* object = HeapObject::cast(*p);
+
+ // We cannot avoid stale handles to left-trimmed objects, but can only make
+ // sure all handles still needed are updated. Filter out any stale pointers
+ // and clear the slot to allow post processing of handles (needed because
+ // the sweeper might actually free the underlying page).
+ if (object->IsFiller()) {
+#ifdef DEBUG
+ // We need to find a FixedArrayBase map after walking the fillers.
+ Heap* heap = collector_->heap();
+ HeapObject* current = object;
+ while (current->IsFiller()) {
+ Address next = reinterpret_cast<Address>(current);
+ if (current->map() == heap->one_pointer_filler_map()) {
+ next += kPointerSize;
+ } else if (current->map() == heap->two_pointer_filler_map()) {
+ next += 2 * kPointerSize;
+ } else {
+ next += current->Size();
+ }
+ current = reinterpret_cast<HeapObject*>(next);
+ }
+ DCHECK(current->IsFixedArrayBase());
+#endif // DEBUG
+ *p = nullptr;
+ return;
+ }
+
MarkBit mark_bit = Marking::MarkBitFrom(object);
if (Marking::IsBlackOrGrey(mark_bit)) return;
« no previous file with comments | « src/heap/heap.cc ('k') | test/mjsunit/regress/regress-620553.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698