cppgc: Sweeper: Get task runner only when scheduling sweeping
Platform::GetForegroundTaskRunner() can only be used after attaching an Isolate in V8. Work around that problem by getting the runner only when needed. Bug: chromium:1056170 Change-Id: If15ec691e7f5cf11be8b7a3bc18827246ac083d6 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2674009 Commit-Queue: Michael Lippautz <mlippautz@chromium.org> Commit-Queue: Omer Katz <omerkatz@chromium.org> Auto-Submit: Michael Lippautz <mlippautz@chromium.org> Reviewed-by: Omer Katz <omerkatz@chromium.org> Cr-Commit-Position: refs/heads/master@{#72527}
This commit is contained in:
parent
8aadf7c5cb
commit
117f9b051c
@ -526,8 +526,7 @@ class Sweeper::SweeperImpl final {
|
|||||||
: heap_(heap),
|
: heap_(heap),
|
||||||
stats_collector_(stats_collector),
|
stats_collector_(stats_collector),
|
||||||
space_states_(heap->size()),
|
space_states_(heap->size()),
|
||||||
platform_(platform),
|
platform_(platform) {}
|
||||||
foreground_task_runner_(platform_->GetForegroundTaskRunner()) {}
|
|
||||||
|
|
||||||
~SweeperImpl() { CancelSweepers(); }
|
~SweeperImpl() { CancelSweepers(); }
|
||||||
|
|
||||||
@ -730,12 +729,11 @@ class Sweeper::SweeperImpl final {
|
|||||||
|
|
||||||
void ScheduleIncrementalSweeping() {
|
void ScheduleIncrementalSweeping() {
|
||||||
DCHECK(platform_);
|
DCHECK(platform_);
|
||||||
if (!foreground_task_runner_ ||
|
auto runner = platform_->GetForegroundTaskRunner();
|
||||||
!foreground_task_runner_->IdleTasksEnabled())
|
if (!runner || !runner->IdleTasksEnabled()) return;
|
||||||
return;
|
|
||||||
|
|
||||||
incremental_sweeper_handle_ =
|
incremental_sweeper_handle_ =
|
||||||
IncrementalSweepTask::Post(this, foreground_task_runner_.get());
|
IncrementalSweepTask::Post(this, runner.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScheduleConcurrentSweeping() {
|
void ScheduleConcurrentSweeping() {
|
||||||
@ -763,7 +761,6 @@ class Sweeper::SweeperImpl final {
|
|||||||
StatsCollector* stats_collector_;
|
StatsCollector* stats_collector_;
|
||||||
SpaceStates space_states_;
|
SpaceStates space_states_;
|
||||||
cppgc::Platform* platform_;
|
cppgc::Platform* platform_;
|
||||||
std::shared_ptr<cppgc::TaskRunner> foreground_task_runner_;
|
|
||||||
IncrementalSweepTask::Handle incremental_sweeper_handle_;
|
IncrementalSweepTask::Handle incremental_sweeper_handle_;
|
||||||
std::unique_ptr<cppgc::JobHandle> concurrent_sweeper_handle_;
|
std::unique_ptr<cppgc::JobHandle> concurrent_sweeper_handle_;
|
||||||
// Indicates whether the sweeping phase is in progress.
|
// Indicates whether the sweeping phase is in progress.
|
||||||
|
Loading…
Reference in New Issue
Block a user