summaryrefslogtreecommitdiff
path: root/deps/v8/src/heap/finalization-registry-cleanup-task.h
blob: bb25c1abec93baff5ad293caac88f9b8b3e2d1d6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// Copyright 2020 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef V8_HEAP_FINALIZATION_REGISTRY_CLEANUP_TASK_H_
#define V8_HEAP_FINALIZATION_REGISTRY_CLEANUP_TASK_H_

#include "src/objects/js-weak-refs.h"
#include "src/tasks/cancelable-task.h"

namespace v8 {
namespace internal {

// The GC schedules a cleanup task when the dirty FinalizationRegistry list is
// non-empty. The task processes a single FinalizationRegistry and posts another
// cleanup task if there are remaining dirty FinalizationRegistries on the list.
class FinalizationRegistryCleanupTask : public CancelableTask {
 public:
  explicit FinalizationRegistryCleanupTask(Heap* heap);
  ~FinalizationRegistryCleanupTask() override = default;

 private:
  FinalizationRegistryCleanupTask(const FinalizationRegistryCleanupTask&) =
      delete;
  void operator=(const FinalizationRegistryCleanupTask&) = delete;

  void RunInternal() override;
  void SlowAssertNoActiveJavaScript();

  Heap* heap_;
};

}  // namespace internal
}  // namespace v8

#endif  // V8_HEAP_FINALIZATION_REGISTRY_CLEANUP_TASK_H_