Commit bd808e7a authored by Michael Lippautz's avatar Michael Lippautz Committed by Commit Bot

Reland "[heap] Move ArrayBufferTracker updating to pointers updating"

This reverts commit ecd8d2c2.

Bug: chromium:651354
Change-Id: I744ef9104cf9d56b8ce6d814f5abda152b0743b0
Reviewed-on: https://chromium-review.googlesource.com/552147Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#46291}
parent e44c607b
......@@ -55,18 +55,17 @@ void LocalArrayBufferTracker::Process(Callback callback) {
} else if (result == kUpdateEntry) {
DCHECK_NOT_NULL(new_buffer);
Page* target_page = Page::FromAddress(new_buffer->address());
// We need to lock the target page because we cannot guarantee
// exclusive access to new space pages.
if (target_page->InNewSpace()) target_page->mutex()->Lock();
LocalArrayBufferTracker* tracker = target_page->local_tracker();
if (tracker == nullptr) {
target_page->AllocateLocalTracker();
tracker = target_page->local_tracker();
{
base::LockGuard<base::RecursiveMutex> guard(target_page->mutex());
LocalArrayBufferTracker* tracker = target_page->local_tracker();
if (tracker == nullptr) {
target_page->AllocateLocalTracker();
tracker = target_page->local_tracker();
}
DCHECK_NOT_NULL(tracker);
DCHECK_EQ(length, new_buffer->allocation_length());
tracker->Add(new_buffer, length);
}
DCHECK_NOT_NULL(tracker);
DCHECK_EQ(length, new_buffer->allocation_length());
tracker->Add(new_buffer, length);
if (target_page->InNewSpace()) target_page->mutex()->Unlock();
it = array_buffers_.erase(it);
} else if (result == kRemoveEntry) {
freed_memory += length;
......
......@@ -3490,7 +3490,6 @@ class Evacuator : public Malloced {
if (chunk->IsFlagSet(MemoryChunk::PAGE_NEW_NEW_PROMOTION))
return kPageNewToNew;
if (chunk->InNewSpace()) return kObjectsNewToOld;
DCHECK(chunk->IsEvacuationCandidate());
return kObjectsOldToOld;
}
......@@ -3628,8 +3627,7 @@ void FullEvacuator::RawEvacuatePage(Page* page, intptr_t* live_bytes) {
case kObjectsNewToOld:
LiveObjectVisitor::VisitBlackObjectsNoFail(
page, state, &new_space_visitor_, LiveObjectVisitor::kClearMarkbits);
ArrayBufferTracker::ProcessBuffers(
page, ArrayBufferTracker::kUpdateForwardedRemoveOthers);
// ArrayBufferTracker will be updated during pointers updating.
break;
case kPageNewToOld:
LiveObjectVisitor::VisitBlackObjectsNoFail(
......@@ -3654,8 +3652,7 @@ void FullEvacuator::RawEvacuatePage(Page* page, intptr_t* live_bytes) {
// thread for simplicity reasons.
collector_->ReportAbortedEvacuationCandidate(failed_object, page);
} else {
ArrayBufferTracker::ProcessBuffers(
page, ArrayBufferTracker::kUpdateForwardedRemoveOthers);
// ArrayBufferTracker will be updated during pointers updating.
}
break;
}
......@@ -3682,8 +3679,7 @@ void YoungGenerationEvacuator::RawEvacuatePage(Page* page,
case kObjectsNewToOld:
LiveObjectVisitor::VisitGreyObjectsNoFail(
page, state, &new_space_visitor_, LiveObjectVisitor::kClearMarkbits);
ArrayBufferTracker::ProcessBuffers(
page, ArrayBufferTracker::kUpdateForwardedRemoveOthers);
// ArrayBufferTracker will be updated during pointers updating.
break;
case kPageNewToOld:
LiveObjectVisitor::VisitGreyObjectsNoFail(
......@@ -4424,6 +4420,25 @@ class GlobalHandlesUpdatingItem : public UpdatingItem {
size_t end_;
};
// Update array buffers on a page that has been evacuated by copying objects.
// Target page exclusivity in old space is guaranteed by the fact that
// evacuation tasks either (a) retrieved a fresh page, or (b) retrieved all
// free list items of a given page. For new space the tracker will update
// using a lock.
class ArrayBufferTrackerUpdatingItem : public UpdatingItem {
public:
explicit ArrayBufferTrackerUpdatingItem(Page* page) : page_(page) {}
virtual ~ArrayBufferTrackerUpdatingItem() {}
void Process() override {
ArrayBufferTracker::ProcessBuffers(
page_, ArrayBufferTracker::kUpdateForwardedRemoveOthers);
}
private:
Page* page_;
};
int MarkCompactCollectorBase::CollectToSpaceUpdatingItems(
ItemParallelJob* job) {
// Seed to space pages.
......@@ -4470,6 +4485,34 @@ int MarkCompactCollectorBase::CollectRememberedSetUpdatingItems(
: NumberOfParallelPointerUpdateTasks(pages, old_to_new_slots_);
}
void MinorMarkCompactCollector::CollectNewSpaceArrayBufferTrackerItems(
ItemParallelJob* job) {
for (Page* p : new_space_evacuation_pages_) {
if (Evacuator::ComputeEvacuationMode(p) == Evacuator::kObjectsNewToOld) {
job->AddItem(new ArrayBufferTrackerUpdatingItem(p));
}
}
}
void MarkCompactCollector::CollectNewSpaceArrayBufferTrackerItems(
ItemParallelJob* job) {
for (Page* p : new_space_evacuation_pages_) {
if (Evacuator::ComputeEvacuationMode(p) == Evacuator::kObjectsNewToOld) {
job->AddItem(new ArrayBufferTrackerUpdatingItem(p));
}
}
}
void MarkCompactCollector::CollectOldSpaceArrayBufferTrackerItems(
ItemParallelJob* job) {
for (Page* p : old_space_evacuation_pages_) {
if (Evacuator::ComputeEvacuationMode(p) == Evacuator::kObjectsOldToOld &&
p->IsEvacuationCandidate()) {
job->AddItem(new ArrayBufferTrackerUpdatingItem(p));
}
}
}
void MarkCompactCollector::UpdatePointersAfterEvacuation() {
TRACE_GC(heap()->tracer(), GCTracer::Scope::MC_EVACUATE_UPDATE_POINTERS);
......@@ -4477,6 +4520,9 @@ void MarkCompactCollector::UpdatePointersAfterEvacuation() {
ItemParallelJob updating_job(isolate()->cancelable_task_manager(),
&page_parallel_job_semaphore_);
CollectNewSpaceArrayBufferTrackerItems(&updating_job);
CollectOldSpaceArrayBufferTrackerItems(&updating_job);
const int to_space_tasks = CollectToSpaceUpdatingItems(&updating_job);
const int remembered_set_tasks = CollectRememberedSetUpdatingItems(
&updating_job, RememberedSetUpdatingMode::ALL);
......@@ -4516,6 +4562,7 @@ void MinorMarkCompactCollector::UpdatePointersAfterEvacuation() {
ItemParallelJob updating_job(isolate()->cancelable_task_manager(),
&page_parallel_job_semaphore_);
CollectNewSpaceArrayBufferTrackerItems(&updating_job);
// Create batches of global handles.
SeedGlobalHandles<GlobalHandlesUpdatingItem>(isolate()->global_handles(),
&updating_job);
......
......@@ -369,6 +369,8 @@ class MinorMarkCompactCollector final : public MarkCompactCollectorBase {
void EvacuatePagesInParallel() override;
void UpdatePointersAfterEvacuation() override;
void CollectNewSpaceArrayBufferTrackerItems(ItemParallelJob* job);
int NumberOfParallelMarkingTasks(int pages);
Worklist* worklist_;
......@@ -745,6 +747,9 @@ class MarkCompactCollector final : public MarkCompactCollectorBase {
void EvacuatePagesInParallel() override;
void UpdatePointersAfterEvacuation() override;
void CollectNewSpaceArrayBufferTrackerItems(ItemParallelJob* job);
void CollectOldSpaceArrayBufferTrackerItems(ItemParallelJob* job);
void ReleaseEvacuationCandidates();
void PostProcessEvacuationCandidates();
void ReportAbortedEvacuationCandidate(HeapObject* failed_object, Page* page);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment