[heap, runtime] Avoid redundant clearing of slots in a trimmed array.

The slots outside the trimmed array will be cleared by the sweeper and
will not be overwritten with an untagged value.

BUG=chromium:694255

Change-Id: I3e814b9934ca95a09e883e237687434e6bb58c80
Reviewed-on: https://chromium-review.googlesource.com/591651
Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
Commit-Queue: Ulan Degenbaev <ulan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#46998}
This commit is contained in:
Ulan Degenbaev 2017-07-28 16:56:34 +02:00 committed by Commit Bot
parent 2f897f5625
commit ed76f17b15

View File

@ -3404,7 +3404,8 @@ FixedArrayBase* Heap::LeftTrimFixedArray(FixedArrayBase* object,
// Technically in new space this write might be omitted (except for
// debug mode which iterates through the heap), but to play safer
// we still do it.
CreateFillerObjectAt(old_start, bytes_to_trim, ClearRecordedSlots::kYes);
// Recorded slots will be cleared by the sweeper.
CreateFillerObjectAt(old_start, bytes_to_trim, ClearRecordedSlots::kNo);
// Initialize header of the trimmed array. Since left trimming is only
// performed on pages which are not concurrently swept creating a filler
@ -3473,8 +3474,9 @@ void Heap::RightTrimFixedArray(FixedArrayBase* object, int elements_to_trim) {
// TODO(hpayer): We should shrink the large object page if the size
// of the object changed significantly.
if (!lo_space()->Contains(object)) {
// Recorded slots will be cleared by the sweeper.
HeapObject* filler =
CreateFillerObjectAt(new_end, bytes_to_trim, ClearRecordedSlots::kYes);
CreateFillerObjectAt(new_end, bytes_to_trim, ClearRecordedSlots::kNo);
DCHECK_NOT_NULL(filler);
// Clear the mark bits of the black area that belongs now to the filler.
// This is an optimization. The sweeper will release black fillers anyway.