[heap] Pass object as argument to Heap::EnsureSweepingCompleted()

Prepare method by taking an object as argument. In the future we can
optimize this method by only sweeping the object's page.

Bug: v8:11837
Change-Id: Ife1ee7949bfaf590dcc305cc4d03aa1813c07b76
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2940888
Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
Reviewed-by: Igor Sheludko <ishell@chromium.org>
Commit-Queue: Dominik Inführ <dinfuehr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#74963}
This commit is contained in:
Dominik Inführ 2021-06-07 08:55:12 +02:00 committed by V8 LUCI CQ
parent c7a8627b2e
commit 89ec29a117
3 changed files with 6 additions and 3 deletions

View File

@ -2266,8 +2266,10 @@ void Heap::CompleteSweepingYoung(GarbageCollector collector) {
array_buffer_sweeper()->EnsureFinished();
}
void Heap::EnsureSweepingCompleted() {
void Heap::EnsureSweepingCompleted(Handle<HeapObject> object) {
// TODO(dinfuehr): Only sweep that object's page instead of whole heap.
mark_compact_collector()->EnsureSweepingCompleted();
USE(object);
}
void Heap::UpdateCurrentEpoch(GarbageCollector collector) {

View File

@ -1116,7 +1116,8 @@ class Heap {
void CompleteSweepingFull();
void CompleteSweepingYoung(GarbageCollector collector);
void EnsureSweepingCompleted();
// Ensures that sweeping is finished for that object's page.
void EnsureSweepingCompleted(Handle<HeapObject> object);
IncrementalMarking* incremental_marking() const {
return incremental_marking_.get();

View File

@ -626,7 +626,7 @@ Handle<Object> JsonParser<Char>::BuildJsonObject(
// must ensure that the sweeper is not running or has already swept the
// object's page. Otherwise the GC can add the contents of
// mutable_double_buffer to the free list.
isolate()->heap()->EnsureSweepingCompleted();
isolate()->heap()->EnsureSweepingCompleted(mutable_double_buffer);
mutable_double_buffer->set_length(0);
}
}