xref: /aosp_15_r20/external/pdfium/fxjs/gc/heap.h (revision 3ac0a46f773bac49fa9476ec2b1cf3f8da5ec3a4)
1 // Copyright 2020 The PDFium Authors
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 FXJS_GC_HEAP_H_
6 #define FXJS_GC_HEAP_H_
7 
8 #include <memory>
9 
10 #include "v8/include/cppgc/allocation.h"
11 
12 namespace cppgc {
13 class Heap;
14 }  // namespace cppgc
15 
16 namespace v8 {
17 class Isolate;
18 class Platform;
19 }  // namespace v8
20 
21 struct FXGCHeapDeleter {
22   void operator()(cppgc::Heap* heap);
23 };
24 
25 using FXGCScopedHeap = std::unique_ptr<cppgc::Heap, FXGCHeapDeleter>;
26 
27 void FXGC_Initialize(v8::Platform* platform, v8::Isolate* isolate);
28 void FXGC_Release();
29 FXGCScopedHeap FXGC_CreateHeap();
30 void FXGC_ForceGarbageCollection(cppgc::Heap* heap);
31 
32 #define CONSTRUCT_VIA_MAKE_GARBAGE_COLLECTED \
33   template <typename T>                      \
34   friend class cppgc::MakeGarbageCollectedTrait
35 
36 #endif  // FXJS_GC_HEAP_H_
37