From be11971d257536484aa4189618f00526359b6a58 Mon Sep 17 00:00:00 2001 From: Ulan Degenbaev Date: Wed, 23 Jan 2019 13:06:50 +0100 Subject: [PATCH] [heap] Preserve the weakness tag in short-circuiting cases of Scavenger Bug: chromium:852420 Change-Id: Idc8104e0617a22586aa5d3bf1bf2618caaacacc1 Reviewed-on: https://chromium-review.googlesource.com/c/1430060 Reviewed-by: Michael Lippautz Commit-Queue: Ulan Degenbaev Cr-Commit-Position: refs/heads/master@{#59031} --- src/heap/scavenger-inl.h | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/heap/scavenger-inl.h b/src/heap/scavenger-inl.h index bfd8e11ff8..db41b43e6f 100644 --- a/src/heap/scavenger-inl.h +++ b/src/heap/scavenger-inl.h @@ -306,7 +306,7 @@ SlotCallbackResult Scavenger::EvacuateThinString(Map map, THeapObjectSlot slot, // ThinStrings always refer to internalized strings, which are always in old // space. DCHECK(!Heap::InNewSpace(actual)); - slot.StoreHeapObject(actual); + HeapObjectReference::Update(slot, actual); return REMOVE_SLOT; } @@ -326,7 +326,7 @@ SlotCallbackResult Scavenger::EvacuateShortcutCandidate(Map map, object->unchecked_second() == ReadOnlyRoots(heap()).empty_string()) { HeapObject first = HeapObject::cast(object->unchecked_first()); - slot.StoreHeapObject(first); + HeapObjectReference::Update(slot, first); if (!Heap::InNewSpace(first)) { object->map_slot().Release_Store( @@ -338,7 +338,7 @@ SlotCallbackResult Scavenger::EvacuateShortcutCandidate(Map map, if (first_word.IsForwardingAddress()) { HeapObject target = first_word.ToForwardingAddress(); - slot.StoreHeapObject(target); + HeapObjectReference::Update(slot, target); object->map_slot().Release_Store( MapWord::FromForwardingAddress(target).ToMap()); return Heap::InToSpace(target) ? KEEP_SLOT : REMOVE_SLOT; @@ -396,13 +396,7 @@ SlotCallbackResult Scavenger::ScavengeObject(THeapObjectSlot p, // copied. if (first_word.IsForwardingAddress()) { HeapObject dest = first_word.ToForwardingAddress(); - DCHECK(Heap::InFromSpace(*p)); - if ((*p)->IsWeak()) { - p.store(HeapObjectReference::Weak(dest)); - } else { - DCHECK((*p)->IsStrong()); - p.store(HeapObjectReference::Strong(dest)); - } + HeapObjectReference::Update(p, dest); DCHECK_IMPLIES(Heap::InNewSpace(dest), (Heap::InToSpace(dest) || MemoryChunk::FromHeapObject(dest)->owner()->identity() ==