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