krillplayer-plugin 0.6.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (150) hide show
  1. package/LICENSE +2 -1
  2. package/README.md +1 -0
  3. package/dist/cli.js +351 -73
  4. package/dist/crypto.js +37 -11
  5. package/dist/engine/engine.c +6 -3
  6. package/kernel/Sources/CQuickJS/include/kernel_qjs.h +8 -1
  7. package/kernel/Sources/CQuickJS/kernel_internal.h +54 -0
  8. package/kernel/Sources/CQuickJS/kernel_qjs.c +17 -29
  9. package/kernel/Sources/CQuickJS/kernel_wasm.c +1155 -0
  10. package/kernel/Sources/CWAMR/include/kernel_wamr.h +151 -0
  11. package/kernel/Sources/CWAMR/include/kernel_wamr_config.h +66 -0
  12. package/kernel/Sources/CWAMR/vendor/LICENSE +219 -0
  13. package/kernel/Sources/CWAMR/vendor/core/config.h +727 -0
  14. package/kernel/Sources/CWAMR/vendor/core/iwasm/aot/aot_runtime.h +899 -0
  15. package/kernel/Sources/CWAMR/vendor/core/iwasm/common/arch/invokeNative_general.c +123 -0
  16. package/kernel/Sources/CWAMR/vendor/core/iwasm/common/wasm_application.c +933 -0
  17. package/kernel/Sources/CWAMR/vendor/core/iwasm/common/wasm_blocking_op.c +92 -0
  18. package/kernel/Sources/CWAMR/vendor/core/iwasm/common/wasm_c_api.c +5391 -0
  19. package/kernel/Sources/CWAMR/vendor/core/iwasm/common/wasm_c_api_internal.h +246 -0
  20. package/kernel/Sources/CWAMR/vendor/core/iwasm/common/wasm_exec_env.c +336 -0
  21. package/kernel/Sources/CWAMR/vendor/core/iwasm/common/wasm_exec_env.h +328 -0
  22. package/kernel/Sources/CWAMR/vendor/core/iwasm/common/wasm_loader_common.c +242 -0
  23. package/kernel/Sources/CWAMR/vendor/core/iwasm/common/wasm_loader_common.h +62 -0
  24. package/kernel/Sources/CWAMR/vendor/core/iwasm/common/wasm_memory.c +1999 -0
  25. package/kernel/Sources/CWAMR/vendor/core/iwasm/common/wasm_memory.h +154 -0
  26. package/kernel/Sources/CWAMR/vendor/core/iwasm/common/wasm_native.c +1532 -0
  27. package/kernel/Sources/CWAMR/vendor/core/iwasm/common/wasm_native.h +117 -0
  28. package/kernel/Sources/CWAMR/vendor/core/iwasm/common/wasm_runtime_common.c +8070 -0
  29. package/kernel/Sources/CWAMR/vendor/core/iwasm/common/wasm_runtime_common.h +1396 -0
  30. package/kernel/Sources/CWAMR/vendor/core/iwasm/common/wasm_shared_memory.c +477 -0
  31. package/kernel/Sources/CWAMR/vendor/core/iwasm/common/wasm_shared_memory.h +63 -0
  32. package/kernel/Sources/CWAMR/vendor/core/iwasm/common/wasm_suspend_flags.h +52 -0
  33. package/kernel/Sources/CWAMR/vendor/core/iwasm/compilation/aot.h +366 -0
  34. package/kernel/Sources/CWAMR/vendor/core/iwasm/include/lib_export.h +60 -0
  35. package/kernel/Sources/CWAMR/vendor/core/iwasm/include/wasm_c_api.h +910 -0
  36. package/kernel/Sources/CWAMR/vendor/core/iwasm/include/wasm_export.h +2440 -0
  37. package/kernel/Sources/CWAMR/vendor/core/iwasm/interpreter/wasm.h +1492 -0
  38. package/kernel/Sources/CWAMR/vendor/core/iwasm/interpreter/wasm_interp.h +122 -0
  39. package/kernel/Sources/CWAMR/vendor/core/iwasm/interpreter/wasm_interp_fast.c +7998 -0
  40. package/kernel/Sources/CWAMR/vendor/core/iwasm/interpreter/wasm_loader.c +16909 -0
  41. package/kernel/Sources/CWAMR/vendor/core/iwasm/interpreter/wasm_loader.h +80 -0
  42. package/kernel/Sources/CWAMR/vendor/core/iwasm/interpreter/wasm_opcode.h +1043 -0
  43. package/kernel/Sources/CWAMR/vendor/core/iwasm/interpreter/wasm_runtime.c +5174 -0
  44. package/kernel/Sources/CWAMR/vendor/core/iwasm/interpreter/wasm_runtime.h +912 -0
  45. package/kernel/Sources/CWAMR/vendor/core/iwasm/libraries/thread-mgr/thread_manager.c +1569 -0
  46. package/kernel/Sources/CWAMR/vendor/core/iwasm/libraries/thread-mgr/thread_manager.h +256 -0
  47. package/kernel/Sources/CWAMR/vendor/core/shared/mem-alloc/ems/ems_alloc.c +1169 -0
  48. package/kernel/Sources/CWAMR/vendor/core/shared/mem-alloc/ems/ems_gc.c +497 -0
  49. package/kernel/Sources/CWAMR/vendor/core/shared/mem-alloc/ems/ems_gc.h +350 -0
  50. package/kernel/Sources/CWAMR/vendor/core/shared/mem-alloc/ems/ems_gc_internal.h +384 -0
  51. package/kernel/Sources/CWAMR/vendor/core/shared/mem-alloc/ems/ems_hmu.c +95 -0
  52. package/kernel/Sources/CWAMR/vendor/core/shared/mem-alloc/ems/ems_kfc.c +547 -0
  53. package/kernel/Sources/CWAMR/vendor/core/shared/mem-alloc/mem_alloc.c +252 -0
  54. package/kernel/Sources/CWAMR/vendor/core/shared/mem-alloc/mem_alloc.h +96 -0
  55. package/kernel/Sources/CWAMR/vendor/core/shared/platform/common/memory/mremap.c +12 -0
  56. package/kernel/Sources/CWAMR/vendor/core/shared/platform/common/posix/posix_blocking_op.c +70 -0
  57. package/kernel/Sources/CWAMR/vendor/core/shared/platform/common/posix/posix_malloc.c +72 -0
  58. package/kernel/Sources/CWAMR/vendor/core/shared/platform/common/posix/posix_memmap.c +302 -0
  59. package/kernel/Sources/CWAMR/vendor/core/shared/platform/common/posix/posix_sleep.c +20 -0
  60. package/kernel/Sources/CWAMR/vendor/core/shared/platform/common/posix/posix_thread.c +784 -0
  61. package/kernel/Sources/CWAMR/vendor/core/shared/platform/common/posix/posix_time.c +28 -0
  62. package/kernel/Sources/CWAMR/vendor/core/shared/platform/darwin/platform_init.c +43 -0
  63. package/kernel/Sources/CWAMR/vendor/core/shared/platform/darwin/platform_internal.h +126 -0
  64. package/kernel/Sources/CWAMR/vendor/core/shared/platform/include/platform_api_extension.h +1676 -0
  65. package/kernel/Sources/CWAMR/vendor/core/shared/platform/include/platform_api_vmcore.h +192 -0
  66. package/kernel/Sources/CWAMR/vendor/core/shared/platform/include/platform_common.h +204 -0
  67. package/kernel/Sources/CWAMR/vendor/core/shared/platform/include/platform_wasi_types.h +610 -0
  68. package/kernel/Sources/CWAMR/vendor/core/shared/platform/linux/platform_init.c +43 -0
  69. package/kernel/Sources/CWAMR/vendor/core/shared/platform/linux/platform_internal.h +139 -0
  70. package/kernel/Sources/CWAMR/vendor/core/shared/utils/bh_assert.c +25 -0
  71. package/kernel/Sources/CWAMR/vendor/core/shared/utils/bh_assert.h +42 -0
  72. package/kernel/Sources/CWAMR/vendor/core/shared/utils/bh_atomic.h +300 -0
  73. package/kernel/Sources/CWAMR/vendor/core/shared/utils/bh_bitmap.c +27 -0
  74. package/kernel/Sources/CWAMR/vendor/core/shared/utils/bh_bitmap.h +114 -0
  75. package/kernel/Sources/CWAMR/vendor/core/shared/utils/bh_common.c +217 -0
  76. package/kernel/Sources/CWAMR/vendor/core/shared/utils/bh_common.h +83 -0
  77. package/kernel/Sources/CWAMR/vendor/core/shared/utils/bh_hashmap.c +339 -0
  78. package/kernel/Sources/CWAMR/vendor/core/shared/utils/bh_hashmap.h +168 -0
  79. package/kernel/Sources/CWAMR/vendor/core/shared/utils/bh_leb128.c +77 -0
  80. package/kernel/Sources/CWAMR/vendor/core/shared/utils/bh_leb128.h +30 -0
  81. package/kernel/Sources/CWAMR/vendor/core/shared/utils/bh_list.c +111 -0
  82. package/kernel/Sources/CWAMR/vendor/core/shared/utils/bh_list.h +109 -0
  83. package/kernel/Sources/CWAMR/vendor/core/shared/utils/bh_log.c +111 -0
  84. package/kernel/Sources/CWAMR/vendor/core/shared/utils/bh_log.h +94 -0
  85. package/kernel/Sources/CWAMR/vendor/core/shared/utils/bh_platform.h +38 -0
  86. package/kernel/Sources/CWAMR/vendor/core/shared/utils/bh_queue.c +256 -0
  87. package/kernel/Sources/CWAMR/vendor/core/shared/utils/bh_queue.h +80 -0
  88. package/kernel/Sources/CWAMR/vendor/core/shared/utils/bh_vector.c +279 -0
  89. package/kernel/Sources/CWAMR/vendor/core/shared/utils/bh_vector.h +126 -0
  90. package/kernel/Sources/CWAMR/vendor/core/shared/utils/gnuc.h +14 -0
  91. package/kernel/Sources/CWAMR/vendor/core/shared/utils/runtime_timer.c +469 -0
  92. package/kernel/Sources/CWAMR/vendor/core/shared/utils/runtime_timer.h +51 -0
  93. package/kernel/Sources/CWAMR/vendor/core/version.h +24 -0
  94. package/kernel/Sources/CWAMR/wamr_bh_assert.c +98 -0
  95. package/kernel/Sources/CWAMR/wamr_bh_bitmap.c +98 -0
  96. package/kernel/Sources/CWAMR/wamr_bh_common.c +98 -0
  97. package/kernel/Sources/CWAMR/wamr_bh_hashmap.c +98 -0
  98. package/kernel/Sources/CWAMR/wamr_bh_leb128.c +98 -0
  99. package/kernel/Sources/CWAMR/wamr_bh_list.c +98 -0
  100. package/kernel/Sources/CWAMR/wamr_bh_log.c +98 -0
  101. package/kernel/Sources/CWAMR/wamr_bh_queue.c +98 -0
  102. package/kernel/Sources/CWAMR/wamr_bh_vector.c +98 -0
  103. package/kernel/Sources/CWAMR/wamr_ems_alloc.c +98 -0
  104. package/kernel/Sources/CWAMR/wamr_ems_gc.c +98 -0
  105. package/kernel/Sources/CWAMR/wamr_ems_hmu.c +98 -0
  106. package/kernel/Sources/CWAMR/wamr_ems_kfc.c +98 -0
  107. package/kernel/Sources/CWAMR/wamr_invokeNative_general.c +98 -0
  108. package/kernel/Sources/CWAMR/wamr_mem_alloc.c +98 -0
  109. package/kernel/Sources/CWAMR/wamr_mremap.c +98 -0
  110. package/kernel/Sources/CWAMR/wamr_platform_init_darwin.c +100 -0
  111. package/kernel/Sources/CWAMR/wamr_platform_init_linux.c +100 -0
  112. package/kernel/Sources/CWAMR/wamr_posix_blocking_op.c +98 -0
  113. package/kernel/Sources/CWAMR/wamr_posix_malloc.c +98 -0
  114. package/kernel/Sources/CWAMR/wamr_posix_memmap.c +98 -0
  115. package/kernel/Sources/CWAMR/wamr_posix_sleep.c +98 -0
  116. package/kernel/Sources/CWAMR/wamr_posix_thread.c +98 -0
  117. package/kernel/Sources/CWAMR/wamr_posix_time.c +98 -0
  118. package/kernel/Sources/CWAMR/wamr_runtime_timer.c +98 -0
  119. package/kernel/Sources/CWAMR/wamr_thread_manager.c +98 -0
  120. package/kernel/Sources/CWAMR/wamr_wasm_application.c +98 -0
  121. package/kernel/Sources/CWAMR/wamr_wasm_blocking_op.c +98 -0
  122. package/kernel/Sources/CWAMR/wamr_wasm_c_api.c +98 -0
  123. package/kernel/Sources/CWAMR/wamr_wasm_exec_env.c +98 -0
  124. package/kernel/Sources/CWAMR/wamr_wasm_interp_fast.c +98 -0
  125. package/kernel/Sources/CWAMR/wamr_wasm_loader.c +98 -0
  126. package/kernel/Sources/CWAMR/wamr_wasm_loader_common.c +98 -0
  127. package/kernel/Sources/CWAMR/wamr_wasm_memory.c +98 -0
  128. package/kernel/Sources/CWAMR/wamr_wasm_native.c +98 -0
  129. package/kernel/Sources/CWAMR/wamr_wasm_runtime.c +98 -0
  130. package/kernel/Sources/CWAMR/wamr_wasm_runtime_common.c +98 -0
  131. package/kernel/Sources/CWAMR/wamr_wasm_shared_memory.c +98 -0
  132. package/kernel/Sources/Kernel/PluginPrelude.js +5 -2
  133. package/kernel/Tests/KernelTests/CasePins.js +50 -0
  134. package/package.json +2 -2
  135. package/skill/krillplayer-plugin/SKILL.md +2 -0
  136. package/skill/krillplayer-plugin/assets/samples/live-video-platform/cases/danmaku-send-content-rejected.json +8 -4
  137. package/skill/krillplayer-plugin/assets/samples/live-video-platform/cases/danmaku-send-login-expired.json +8 -4
  138. package/skill/krillplayer-plugin/assets/samples/live-video-platform/cases/danmaku-send-muted.json +8 -4
  139. package/skill/krillplayer-plugin/assets/samples/live-video-platform/cases/danmaku-send-other.json +8 -4
  140. package/skill/krillplayer-plugin/assets/samples/live-video-platform/cases/danmaku-send-rate-limited.json +8 -4
  141. package/skill/krillplayer-plugin/assets/samples/live-video-platform/cases/danmaku-send-sent.json +8 -4
  142. package/skill/krillplayer-plugin/assets/samples/live-video-platform/cases/play-live-logged-in.json +39 -0
  143. package/skill/krillplayer-plugin/assets/samples/live-video-platform/cases/play-live-selected-backup-line.json +8 -0
  144. package/skill/krillplayer-plugin/assets/samples/live-video-platform/cases/play-live-selected-line-gone.json +8 -0
  145. package/skill/krillplayer-plugin/assets/samples/live-video-platform/cases/play-live.json +8 -0
  146. package/skill/krillplayer-plugin/assets/samples/live-video-platform/plugin.ts +26 -9
  147. package/skill/krillplayer-plugin/references/cases.md +19 -1
  148. package/skill/krillplayer-plugin/references/contract.d.ts +104 -11
  149. package/skill/krillplayer-plugin/references/crypto-tools.md +104 -0
  150. package/skill/krillplayer-plugin/references/errors-and-fixes.md +5 -1
@@ -0,0 +1,350 @@
1
+ /*
2
+ * Copyright (C) 2019 Intel Corporation. All rights reserved.
3
+ * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
4
+ */
5
+
6
+ /**
7
+ * @file ems_gc.h
8
+ * @date Wed Aug 3 10:46:38 2011
9
+ *
10
+ * @brief This file defines GC modules types and interfaces.
11
+ */
12
+
13
+ #ifndef _EMS_GC_H
14
+ #define _EMS_GC_H
15
+
16
+ #include "bh_platform.h"
17
+
18
+ #ifdef __cplusplus
19
+ extern "C" {
20
+ #endif
21
+
22
+ #ifndef GC_STAT_DATA
23
+ #define GC_STAT_DATA 0
24
+ #endif
25
+
26
+ #ifndef GC_STAT_SHOW
27
+ #define GC_STAT_SHOW 0
28
+ #endif
29
+
30
+ #ifndef GC_IN_EVERY_ALLOCATION
31
+ #define GC_IN_EVERY_ALLOCATION 0
32
+ #endif
33
+
34
+ #ifndef GC_MANUALLY
35
+ #define GC_MANUALLY 0
36
+ #endif
37
+
38
+ #define GC_HEAD_PADDING 4
39
+
40
+ #ifndef NULL_REF
41
+ #define NULL_REF ((gc_object_t)NULL)
42
+ #endif
43
+
44
+ #define GC_SUCCESS (0)
45
+ #define GC_ERROR (-1)
46
+
47
+ #define GC_TRUE (1)
48
+ #define GC_FALSE (0)
49
+
50
+ #define GC_MAX_HEAP_SIZE (256 * BH_KB)
51
+
52
+ typedef void *gc_handle_t;
53
+ typedef void *gc_object_t;
54
+ typedef uint64 gc_uint64;
55
+ typedef int64 gc_int64;
56
+ typedef uint32 gc_uint32;
57
+ typedef int32 gc_int32;
58
+ typedef uint16 gc_uint16;
59
+ typedef int16 gc_int16;
60
+ typedef uint8 gc_uint8;
61
+ typedef int8 gc_int8;
62
+ typedef uint32 gc_size_t;
63
+
64
+ typedef enum {
65
+ GC_STAT_TOTAL = 0,
66
+ GC_STAT_FREE,
67
+ GC_STAT_HIGHMARK,
68
+ GC_STAT_COUNT,
69
+ GC_STAT_TIME,
70
+ GC_STAT_MAX
71
+ } GC_STAT_INDEX;
72
+
73
+ #ifndef GC_FINALIZER_T_DEFINED
74
+ #define GC_FINALIZER_T_DEFINED
75
+ typedef void (*gc_finalizer_t)(void *obj, void *data);
76
+ #endif
77
+
78
+ #ifndef EXTRA_INFO_NORMAL_NODE_CNT
79
+ #define EXTRA_INFO_NORMAL_NODE_CNT 32
80
+ #endif
81
+
82
+ /* extra information attached to specific object */
83
+ typedef struct extra_info_node {
84
+ gc_object_t obj;
85
+ gc_finalizer_t finalizer;
86
+ void *data;
87
+ } extra_info_node_t;
88
+
89
+ /**
90
+ * GC initialization from a buffer, which is separated into
91
+ * two parts: the beginning of the buffer is used to create
92
+ * the heap structure, and the left is used to create the
93
+ * actual pool data
94
+ *
95
+ * @param buf the buffer to be initialized to a heap
96
+ * @param buf_size the size of buffer
97
+ *
98
+ * @return gc handle if success, NULL otherwise
99
+ */
100
+ gc_handle_t
101
+ gc_init_with_pool(char *buf, gc_size_t buf_size);
102
+
103
+ /**
104
+ * GC initialization from heap struct buffer and pool buffer
105
+ *
106
+ * @param struct_buf the struct buffer to create the heap structure
107
+ * @param struct_buf_size the size of struct buffer
108
+ * @param pool_buf the pool buffer to create pool data
109
+ * @param pool_buf_size the size of poll buffer
110
+ *
111
+ * @return gc handle if success, NULL otherwise
112
+ */
113
+ gc_handle_t
114
+ gc_init_with_struct_and_pool(char *struct_buf, gc_size_t struct_buf_size,
115
+ char *pool_buf, gc_size_t pool_buf_size);
116
+
117
+ /**
118
+ * Destroy heap which is initialized from a buffer
119
+ *
120
+ * @param handle handle to heap needed destroy
121
+ *
122
+ * @return GC_SUCCESS if success
123
+ * GC_ERROR for bad parameters or failed system resource freeing.
124
+ */
125
+ int
126
+ gc_destroy_with_pool(gc_handle_t handle);
127
+
128
+ #if WASM_ENABLE_GC != 0
129
+ /**
130
+ * Enable or disable GC reclaim for a heap
131
+ *
132
+ * @param handle handle of the heap
133
+ * @param exec_env the exec_env of current module instance
134
+ */
135
+ #if WASM_ENABLE_THREAD_MGR == 0
136
+ void
137
+ gc_enable_gc_reclaim(gc_handle_t handle, void *exec_env);
138
+ #else
139
+ /**
140
+ * Enable or disable GC reclaim for a heap
141
+ *
142
+ * @param handle handle of the heap
143
+ * @param cluster the tread cluster of current module instance
144
+ */
145
+ void
146
+ gc_enable_gc_reclaim(gc_handle_t handle, void *cluster);
147
+ #endif
148
+ #endif
149
+
150
+ /**
151
+ * Return heap struct size
152
+ */
153
+ uint32
154
+ gc_get_heap_struct_size(void);
155
+
156
+ /**
157
+ * Migrate heap from one pool buf to another pool buf
158
+ *
159
+ * @param handle handle of the new heap
160
+ * @param pool_buf_new the new pool buffer
161
+ * @param pool_buf_size the size of new pool buffer
162
+ *
163
+ * @return GC_SUCCESS if success, GC_ERROR otherwise
164
+ */
165
+ int
166
+ gc_migrate(gc_handle_t handle, char *pool_buf_new, gc_size_t pool_buf_size);
167
+
168
+ /**
169
+ * Check whether the heap is corrupted
170
+ *
171
+ * @param handle handle of the heap
172
+ *
173
+ * @return true if success, false otherwise
174
+ */
175
+ bool
176
+ gc_is_heap_corrupted(gc_handle_t handle);
177
+
178
+ /**
179
+ * Get Heap Stats
180
+ *
181
+ * @param stats [out] integer array to save heap stats
182
+ * @param size [in] the size of stats
183
+ * @param mmt [in] type of heap, MMT_SHARED or MMT_INSTANCE
184
+ */
185
+ void *
186
+ gc_heap_stats(void *heap, uint32 *stats, int size);
187
+
188
+ #if BH_ENABLE_GC_VERIFY == 0
189
+
190
+ gc_object_t
191
+ gc_alloc_vo(void *heap, gc_size_t size);
192
+
193
+ gc_object_t
194
+ gc_realloc_vo(void *heap, void *ptr, gc_size_t size);
195
+
196
+ int
197
+ gc_free_vo(void *heap, gc_object_t obj);
198
+
199
+ #if WASM_ENABLE_GC != 0
200
+ gc_object_t
201
+ gc_alloc_wo(void *heap, gc_size_t size);
202
+
203
+ void
204
+ gc_free_wo(void *vheap, void *ptr);
205
+ #endif
206
+
207
+ #else /* else of BH_ENABLE_GC_VERIFY */
208
+
209
+ gc_object_t
210
+ gc_alloc_vo_internal(void *heap, gc_size_t size, const char *file, int line);
211
+
212
+ gc_object_t
213
+ gc_realloc_vo_internal(void *heap, void *ptr, gc_size_t size, const char *file,
214
+ int line);
215
+
216
+ int
217
+ gc_free_vo_internal(void *heap, gc_object_t obj, const char *file, int line);
218
+
219
+ #if WASM_ENABLE_GC != 0
220
+ gc_object_t
221
+ gc_alloc_wo_internal(void *heap, gc_size_t size, const char *file, int line);
222
+
223
+ void
224
+ gc_free_wo_internal(void *vheap, void *ptr, const char *file, int line);
225
+ #endif
226
+
227
+ /* clang-format off */
228
+ #define gc_alloc_vo(heap, size) \
229
+ gc_alloc_vo_internal(heap, size, __FILE__, __LINE__)
230
+
231
+ #define gc_realloc_vo(heap, ptr, size) \
232
+ gc_realloc_vo_internal(heap, ptr, size, __FILE__, __LINE__)
233
+
234
+ #define gc_free_vo(heap, obj) \
235
+ gc_free_vo_internal(heap, obj, __FILE__, __LINE__)
236
+
237
+ #if WASM_ENABLE_GC != 0
238
+ #define gc_alloc_wo(heap, size) \
239
+ gc_alloc_wo_internal(heap, size, __FILE__, __LINE__)
240
+
241
+ #define gc_free_wo(heap, obj) \
242
+ gc_free_wo_internal(heap, obj, __FILE__, __LINE__)
243
+ #endif
244
+ /* clang-format on */
245
+
246
+ #endif /* end of BH_ENABLE_GC_VERIFY */
247
+
248
+ #if WASM_ENABLE_GC != 0
249
+ /**
250
+ * Add gc object ref to the rootset of a gc heap.
251
+ *
252
+ * @param heap the heap to add the gc object to its rootset
253
+ * @param obj pointer to a valid WASM object managed by the gc heap.
254
+ *
255
+ * @return GC_SUCCESS if success, GC_ERROR otherwise
256
+ */
257
+ int
258
+ gc_add_root(void *heap, gc_object_t obj);
259
+
260
+ int
261
+ gci_gc_heap(void *heap);
262
+
263
+ extra_info_node_t *
264
+ gc_search_extra_info_node(gc_handle_t handle, gc_object_t obj,
265
+ gc_size_t *p_index);
266
+
267
+ /**
268
+ * Set finalizer to the given object, if another finalizer is set to the same
269
+ * object, the previous one will be cancelled
270
+ *
271
+ * @param handle handle of the heap
272
+ * @param obj object to set finalizer
273
+ * @param cb finalizer function to be called before this object is freed
274
+ * @param data custom data to be passed to finalizer function
275
+ *
276
+ * @return true if success, false otherwise
277
+ */
278
+ bool
279
+ gc_set_finalizer(gc_handle_t handle, gc_object_t obj, gc_finalizer_t cb,
280
+ void *data);
281
+
282
+ /**
283
+ * Unset finalizer to the given object
284
+ *
285
+ * @param handle handle of the heap
286
+ * @param obj object to unset finalizer
287
+ */
288
+ void
289
+ gc_unset_finalizer(gc_handle_t handle, gc_object_t obj);
290
+
291
+ #if WASM_ENABLE_THREAD_MGR == 0
292
+ bool
293
+ wasm_runtime_traverse_gc_rootset(void *exec_env, void *heap);
294
+ #else
295
+ bool
296
+ wasm_runtime_traverse_gc_rootset(void *cluster, void *heap);
297
+ #endif
298
+
299
+ bool
300
+ wasm_runtime_get_wasm_object_ref_list(gc_object_t obj, bool *p_is_compact_mode,
301
+ gc_uint32 *p_ref_num,
302
+ gc_uint16 **p_ref_list,
303
+ gc_uint32 *p_ref_start_offset);
304
+
305
+ bool
306
+ wasm_runtime_get_wasm_object_extra_info_flag(gc_object_t obj);
307
+
308
+ void
309
+ wasm_runtime_set_wasm_object_extra_info_flag(gc_object_t obj, bool set);
310
+
311
+ void
312
+ wasm_runtime_gc_prepare(void *exec_env);
313
+
314
+ void
315
+ wasm_runtime_gc_finalize(void *exec_env);
316
+ #endif /* end of WASM_ENABLE_GC != 0 */
317
+
318
+ #define GC_HEAP_STAT_SIZE (128 / 4)
319
+
320
+ typedef struct {
321
+ int usage;
322
+ int usage_block;
323
+ int vo_usage;
324
+ int wo_usage;
325
+ int free;
326
+ int free_block;
327
+ int vo_free;
328
+ int wo_free;
329
+ int usage_sizes[GC_HEAP_STAT_SIZE];
330
+ int free_sizes[GC_HEAP_STAT_SIZE];
331
+ } gc_stat_t;
332
+
333
+ void
334
+ gc_show_stat(gc_handle_t handle);
335
+
336
+ #if WASM_ENABLE_GC != 0
337
+ void
338
+ gc_show_fragment(gc_handle_t handle);
339
+
340
+ #if WASM_ENABLE_GC_PERF_PROFILING != 0
341
+ void
342
+ gc_dump_perf_profiling(gc_handle_t *handle);
343
+ #endif
344
+ #endif
345
+
346
+ #ifdef __cplusplus
347
+ }
348
+ #endif
349
+
350
+ #endif