v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
prefinalizer-handler.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_PREFINALIZER_HANDLER_H_
6#define V8_HEAP_CPPGC_PREFINALIZER_HANDLER_H_
7
8#include <utility>
9#include <vector>
10
12
13namespace cppgc {
14namespace internal {
15
16class HeapBase;
17
18struct PreFinalizer final {
20
21 void* object;
23
24 bool operator==(const PreFinalizer& other) const;
25};
26
28 public:
30
31 void RegisterPrefinalizer(PreFinalizer pre_finalizer);
32
34
35 bool IsInvokingPreFinalizers() const { return is_invoking_; }
36
39 return std::exchange(bytes_allocated_in_prefinalizers, 0);
40 }
41
42 private:
43 // Checks that the current thread is the thread that created the heap.
45
46 // Pre-finalizers are called in the reverse order in which they are
47 // registered by the constructors (including constructors of Mixin
48 // objects) for an object, by processing the ordered_pre_finalizers_
49 // back-to-front.
50 std::vector<PreFinalizer> ordered_pre_finalizers_;
51 std::vector<PreFinalizer>* current_ordered_pre_finalizers_;
52
54 bool is_invoking_ = false;
55
56 // Counter of bytes allocated during prefinalizers.
58};
59
60} // namespace internal
61} // namespace cppgc
62
63#endif // V8_HEAP_CPPGC_PREFINALIZER_HANDLER_H_
void RegisterPrefinalizer(PreFinalizer pre_finalizer)
std::vector< PreFinalizer > * current_ordered_pre_finalizers_
std::vector< PreFinalizer > ordered_pre_finalizers_
bool(*)(const cppgc::LivenessBroker &, void *) Callback
PrefinalizerRegistration::Callback Callback
bool operator==(const PreFinalizer &other) const