v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
gc-invoker.h
Go to the documentation of this file.
1// Copyright 2020 the V8 project authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef V8_HEAP_CPPGC_GC_INVOKER_H_
6#define V8_HEAP_CPPGC_GC_INVOKER_H_
7
8#include <optional>
9
11#include "include/cppgc/heap.h"
12#include "src/base/macros.h"
14
15namespace cppgc {
16
17class Platform;
18
19namespace internal {
20
21// GC invoker that dispatches GC depending on StackSupport and StackState:
22// 1. If StackState specifies no stack scan needed the GC is invoked
23// synchronously.
24// 2. If StackState specifies conservative GC and StackSupport prohibits stack
25// scanning: Delay GC until it can be invoked without accessing the stack.
26// To do so, a precise GC without stack scan is scheduled using the platform
27// if non-nestable tasks are supported, and otherwise no operation is carried
28// out. This means that the heuristics allows to arbitrary go over the limit
29// in case non-nestable tasks are not supported and only conservative GCs are
30// requested.
32 public:
35
36 GCInvoker(const GCInvoker&) = delete;
37 GCInvoker& operator=(const GCInvoker&) = delete;
38
39 void CollectGarbage(GCConfig) final;
40 void StartIncrementalGarbageCollection(GCConfig) final;
41 size_t epoch() const final;
42 std::optional<EmbedderStackState> overridden_stack_state() const final;
43 void set_override_stack_state(EmbedderStackState state) final;
44 void clear_overridden_stack_state() final;
45#ifdef V8_ENABLE_ALLOCATION_TIMEOUT
46 std::optional<int> UpdateAllocationTimeout() final;
47#endif // V8_ENABLE_ALLOCATION_TIMEOUT
48
49 private:
50 class GCInvokerImpl;
51 std::unique_ptr<GCInvokerImpl> impl_;
52};
53
54} // namespace internal
55} // namespace cppgc
56
57#endif // V8_HEAP_CPPGC_GC_INVOKER_H_
StackSupport
Definition heap.h:45
std::unique_ptr< GCInvokerImpl > impl_
Definition gc-invoker.h:51
GCInvoker & operator=(const GCInvoker &)=delete
GCInvoker(const GCInvoker &)=delete
EmbedderStackState
Definition common.h:15
STL namespace.
#define V8_EXPORT_PRIVATE
Definition macros.h:460