GarbageCollector.h
3.54 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#pragma once
struct Il2CppGuid;
struct Il2CppIUnknown;
struct Il2CppObject;
struct Il2CppThread;
namespace il2cpp
{
namespace gc
{
class LIBIL2CPP_CODEGEN_API GarbageCollector
{
public:
static void Collect(int maxGeneration);
static int32_t CollectALittle();
static int32_t GetCollectionCount(int32_t generation);
static int64_t GetUsedHeapSize();
#if IL2CPP_ENABLE_WRITE_BARRIERS
static void SetWriteBarrier(void **ptr);
static void SetWriteBarrier(void **ptr, size_t numBytes);
#else
static inline void SetWriteBarrier(void **ptr) {}
static inline void SetWriteBarrier(void **ptr, size_t numBytes) {}
#endif
public:
// internal
typedef void (*FinalizerCallback)(void* object, void* client_data);
// functions implemented in a GC agnostic manner
static void UninitializeGC();
static void AddMemoryPressure(int64_t value);
static int32_t GetMaxGeneration();
static int32_t GetGeneration(void* addr);
#if !IL2CPP_TINY_WITHOUT_DEBUGGER
static void InitializeFinalizer();
static bool IsFinalizerThread(Il2CppThread* thread);
static void UninitializeFinalizers();
static void NotifyFinalizers();
static void RunFinalizer(void *obj, void *data);
static void RegisterFinalizerForNewObject(Il2CppObject* obj);
static void RegisterFinalizer(Il2CppObject* obj);
static void SuppressFinalizer(Il2CppObject* obj);
static void WaitForPendingFinalizers();
static Il2CppIUnknown* GetOrCreateCCW(Il2CppObject* obj, const Il2CppGuid& iid);
#endif
// functions implemented in a GC specific manner
static void Initialize();
static void Enable();
static void Disable();
static bool IsDisabled();
static bool IsIncremental();
static int64_t GetMaxTimeSliceNs();
static void SetMaxTimeSliceNs(int64_t maxTimeSlice);
static FinalizerCallback RegisterFinalizerWithCallback(Il2CppObject* obj, FinalizerCallback callback);
static int64_t GetAllocatedHeapSize();
static void* MakeDescriptorForObject(size_t *bitmap, int numbits);
static void* MakeDescriptorForString();
static void* MakeDescriptorForArray();
#if IL2CPP_TINY_WITHOUT_DEBUGGER
static void* Allocate(size_t size);
#endif
static void* AllocateFixed(size_t size, void *descr);
static void FreeFixed(void* addr);
static bool RegisterThread(void *baseptr);
static bool UnregisterThread();
#if !IL2CPP_TINY_WITHOUT_DEBUGGER
static bool HasPendingFinalizers();
static int32_t InvokeFinalizers();
#endif
static void AddWeakLink(void **link_addr, Il2CppObject *obj, bool track);
static void RemoveWeakLink(void **link_addr);
static Il2CppObject *GetWeakLink(void **link_addr);
/* Used by liveness code */
static void StopWorld();
static void StartWorld();
typedef void (*HeapSectionCallback) (void* user_data, void* start, void* end);
static void ForEachHeapSection(void* user_data, HeapSectionCallback callback);
static size_t GetSectionCount();
typedef void* (*GCCallWithAllocLockCallback)(void* user_data);
static void* CallWithAllocLockHeld(GCCallWithAllocLockCallback callback, void* user_data);
static void RegisterRoot(char *start, size_t size);
static void UnregisterRoot(char* start);
static void SetSkipThread(bool skip);
};
} /* namespace vm */
} /* namespace il2cpp */