11cb0ef41Sopenharmony_ci// Copyright 2015 the V8 project authors. All rights reserved.
21cb0ef41Sopenharmony_ci// Use of this source code is governed by a BSD-style license that can be
31cb0ef41Sopenharmony_ci// found in the LICENSE file.
41cb0ef41Sopenharmony_ci
51cb0ef41Sopenharmony_ci#ifndef V8_HEAP_SCAVENGE_JOB_H_
61cb0ef41Sopenharmony_ci#define V8_HEAP_SCAVENGE_JOB_H_
71cb0ef41Sopenharmony_ci
81cb0ef41Sopenharmony_ci#include "src/tasks/cancelable-task.h"
91cb0ef41Sopenharmony_ci
101cb0ef41Sopenharmony_cinamespace v8 {
111cb0ef41Sopenharmony_cinamespace internal {
121cb0ef41Sopenharmony_ci
131cb0ef41Sopenharmony_ciclass Heap;
141cb0ef41Sopenharmony_ciclass Isolate;
151cb0ef41Sopenharmony_ci
161cb0ef41Sopenharmony_ci// The scavenge job uses platform tasks to perform a young generation
171cb0ef41Sopenharmony_ci// Scavenge garbage collection. The job posts a foreground task.
181cb0ef41Sopenharmony_ciclass ScavengeJob {
191cb0ef41Sopenharmony_ci public:
201cb0ef41Sopenharmony_ci  ScavengeJob() V8_NOEXCEPT = default;
211cb0ef41Sopenharmony_ci
221cb0ef41Sopenharmony_ci  void ScheduleTaskIfNeeded(Heap* heap);
231cb0ef41Sopenharmony_ci
241cb0ef41Sopenharmony_ci  static size_t YoungGenerationTaskTriggerSize(Heap* heap);
251cb0ef41Sopenharmony_ci
261cb0ef41Sopenharmony_ci private:
271cb0ef41Sopenharmony_ci  class Task;
281cb0ef41Sopenharmony_ci
291cb0ef41Sopenharmony_ci  static bool YoungGenerationSizeTaskTriggerReached(Heap* heap);
301cb0ef41Sopenharmony_ci
311cb0ef41Sopenharmony_ci  void set_task_pending(bool value) { task_pending_ = value; }
321cb0ef41Sopenharmony_ci
331cb0ef41Sopenharmony_ci  bool task_pending_ = false;
341cb0ef41Sopenharmony_ci};
351cb0ef41Sopenharmony_ci}  // namespace internal
361cb0ef41Sopenharmony_ci}  // namespace v8
371cb0ef41Sopenharmony_ci
381cb0ef41Sopenharmony_ci#endif  // V8_HEAP_SCAVENGE_JOB_H_
39