krillplayer-plugin 0.5.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 +2 -0
  3. package/dist/cli.js +397 -80
  4. package/dist/crypto.js +38 -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 +46 -0
  144. package/skill/krillplayer-plugin/assets/samples/live-video-platform/cases/play-live-selected-line-gone.json +46 -0
  145. package/skill/krillplayer-plugin/assets/samples/live-video-platform/cases/play-live.json +21 -1
  146. package/skill/krillplayer-plugin/assets/samples/live-video-platform/plugin.ts +39 -4
  147. package/skill/krillplayer-plugin/references/cases.md +20 -2
  148. package/skill/krillplayer-plugin/references/contract.d.ts +114 -12
  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,1396 @@
1
+ /*
2
+ * Copyright (C) 2019 Intel Corporation. All rights reserved.
3
+ * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
4
+ */
5
+
6
+ #ifndef _WASM_COMMON_H
7
+ #define _WASM_COMMON_H
8
+
9
+ #include "bh_platform.h"
10
+ #include "bh_common.h"
11
+ #include "wasm_exec_env.h"
12
+ #include "wasm_native.h"
13
+ #include "../include/wasm_export.h"
14
+ #include "../interpreter/wasm.h"
15
+ #if WASM_ENABLE_GC != 0
16
+ #include "gc/gc_object.h"
17
+ #endif
18
+
19
+ #if WASM_ENABLE_LIBC_WASI != 0
20
+ #if WASM_ENABLE_UVWASI == 0
21
+ #include "posix.h"
22
+ #else
23
+ #include "uvwasi.h"
24
+ #endif
25
+ #endif
26
+
27
+ #ifdef __cplusplus
28
+ extern "C" {
29
+ #endif
30
+
31
+ /* Internal use for setting default running mode */
32
+ #define Mode_Default 0
33
+
34
+ #if WASM_CPU_SUPPORTS_UNALIGNED_ADDR_ACCESS != 0
35
+
36
+ #define PUT_I64_TO_ADDR(addr, value) \
37
+ do { \
38
+ *(int64 *)(addr) = (int64)(value); \
39
+ } while (0)
40
+ #define PUT_V128_TO_ADDR(addr, value) \
41
+ do { \
42
+ *(V128 *)(addr) = (value); \
43
+ } while (0)
44
+ #define PUT_F64_TO_ADDR(addr, value) \
45
+ do { \
46
+ *(float64 *)(addr) = (float64)(value); \
47
+ } while (0)
48
+ #define PUT_REF_TO_ADDR(addr, value) \
49
+ do { \
50
+ *(void **)(addr) = (void *)(value); \
51
+ } while (0)
52
+
53
+ #define GET_I64_FROM_ADDR(addr) (*(int64 *)(addr))
54
+ #define GET_F64_FROM_ADDR(addr) (*(float64 *)(addr))
55
+ #define GET_REF_FROM_ADDR(addr) (*(void **)(addr))
56
+ #define GET_V128_FROM_ADDR(addr) (*(V128 *)(addr))
57
+
58
+ /* For STORE opcodes */
59
+ #define STORE_I64 PUT_I64_TO_ADDR
60
+ static inline void
61
+ STORE_U32(void *addr, uint32_t value)
62
+ {
63
+ *(uint32_t *)(addr) = (uint32_t)(value);
64
+ }
65
+ static inline void
66
+ STORE_U16(void *addr, uint16_t value)
67
+ {
68
+ *(uint16_t *)(addr) = (uint16_t)(value);
69
+ }
70
+ static inline void
71
+ STORE_U8(void *addr, uint8_t value)
72
+ {
73
+ *(uint8 *)addr = value;
74
+ }
75
+
76
+ static inline void
77
+ STORE_V128(void *addr, V128 value)
78
+ {
79
+ *(V128 *)addr = value;
80
+ }
81
+
82
+ /* For LOAD opcodes */
83
+ #define LOAD_I64(addr) (*(int64 *)(addr))
84
+ #define LOAD_F64(addr) (*(float64 *)(addr))
85
+ #define LOAD_I32(addr) (*(int32 *)(addr))
86
+ #define LOAD_U32(addr) (*(uint32 *)(addr))
87
+ #define LOAD_I16(addr) (*(int16 *)(addr))
88
+ #define LOAD_U16(addr) (*(uint16 *)(addr))
89
+ #define LOAD_V128(addr) (*(V128 *)(addr))
90
+
91
+ #define STORE_PTR(addr, ptr) \
92
+ do { \
93
+ *(void **)addr = (void *)ptr; \
94
+ } while (0)
95
+
96
+ #else /* WASM_CPU_SUPPORTS_UNALIGNED_ADDR_ACCESS != 0 */
97
+
98
+ #define PUT_V128_TO_ADDR(addr, value) \
99
+ do { \
100
+ uint32 *addr_u32 = (uint32 *)(addr); \
101
+ addr_u32[0] = (value).i32x4[0]; \
102
+ addr_u32[1] = (value).i32x4[1]; \
103
+ addr_u32[2] = (value).i32x4[2]; \
104
+ addr_u32[3] = (value).i32x4[3]; \
105
+ } while (0)
106
+
107
+ #define PUT_I64_TO_ADDR(addr, value) \
108
+ do { \
109
+ uint32 *addr_u32 = (uint32 *)(addr); \
110
+ union { \
111
+ int64 val; \
112
+ uint32 parts[2]; \
113
+ } u; \
114
+ u.val = (int64)(value); \
115
+ addr_u32[0] = u.parts[0]; \
116
+ addr_u32[1] = u.parts[1]; \
117
+ } while (0)
118
+ #define PUT_F64_TO_ADDR(addr, value) \
119
+ do { \
120
+ uint32 *addr_u32 = (uint32 *)(addr); \
121
+ union { \
122
+ float64 val; \
123
+ uint32 parts[2]; \
124
+ } u; \
125
+ u.val = (value); \
126
+ addr_u32[0] = u.parts[0]; \
127
+ addr_u32[1] = u.parts[1]; \
128
+ } while (0)
129
+ #if UINTPTR_MAX == UINT64_MAX
130
+ #define PUT_REF_TO_ADDR(addr, value) \
131
+ do { \
132
+ uint32 *addr_u32 = (uint32 *)(addr); \
133
+ union { \
134
+ void *val; \
135
+ uint32 parts[2]; \
136
+ } u; \
137
+ u.val = (void *)(value); \
138
+ addr_u32[0] = u.parts[0]; \
139
+ addr_u32[1] = u.parts[1]; \
140
+ } while (0)
141
+ #else
142
+ #define PUT_REF_TO_ADDR(addr, value) \
143
+ do { \
144
+ *(void **)(addr) = (void *)(value); \
145
+ } while (0)
146
+ #endif
147
+
148
+ static inline V128
149
+ GET_V128_FROM_ADDR(uint32 *addr)
150
+ {
151
+ V128 ret;
152
+ ret.i32x4[0] = addr[0];
153
+ ret.i32x4[1] = addr[1];
154
+ ret.i32x4[2] = addr[2];
155
+ ret.i32x4[3] = addr[3];
156
+ return ret;
157
+ }
158
+
159
+ static inline int64
160
+ GET_I64_FROM_ADDR(uint32 *addr)
161
+ {
162
+ union {
163
+ int64 val;
164
+ uint32 parts[2];
165
+ } u;
166
+ u.parts[0] = addr[0];
167
+ u.parts[1] = addr[1];
168
+ return u.val;
169
+ }
170
+
171
+ static inline float64
172
+ GET_F64_FROM_ADDR(uint32 *addr)
173
+ {
174
+ union {
175
+ float64 val;
176
+ uint32 parts[2];
177
+ } u;
178
+ u.parts[0] = addr[0];
179
+ u.parts[1] = addr[1];
180
+ return u.val;
181
+ }
182
+
183
+ #if UINTPTR_MAX == UINT64_MAX
184
+ static inline void *
185
+ GET_REF_FROM_ADDR(uint32 *addr)
186
+ {
187
+ union {
188
+ void *val;
189
+ uint32 parts[2];
190
+ } u;
191
+ u.parts[0] = addr[0];
192
+ u.parts[1] = addr[1];
193
+ return u.val;
194
+ }
195
+ #else
196
+ #define GET_REF_FROM_ADDR(addr) (*(void **)(addr))
197
+ #endif
198
+
199
+ /* For STORE opcodes */
200
+ #define STORE_I64(addr, value) \
201
+ do { \
202
+ uintptr_t addr_ = (uintptr_t)(addr); \
203
+ union { \
204
+ int64 val; \
205
+ uint32 u32[2]; \
206
+ uint16 u16[4]; \
207
+ uint8 u8[8]; \
208
+ } u; \
209
+ if ((addr_ & (uintptr_t)7) == 0) \
210
+ *(int64 *)(addr) = (int64)(value); \
211
+ else { \
212
+ u.val = (int64)(value); \
213
+ if ((addr_ & (uintptr_t)3) == 0) { \
214
+ ((uint32 *)(addr))[0] = u.u32[0]; \
215
+ ((uint32 *)(addr))[1] = u.u32[1]; \
216
+ } \
217
+ else if ((addr_ & (uintptr_t)1) == 0) { \
218
+ ((uint16 *)(addr))[0] = u.u16[0]; \
219
+ ((uint16 *)(addr))[1] = u.u16[1]; \
220
+ ((uint16 *)(addr))[2] = u.u16[2]; \
221
+ ((uint16 *)(addr))[3] = u.u16[3]; \
222
+ } \
223
+ else { \
224
+ int32 t; \
225
+ for (t = 0; t < 8; t++) \
226
+ ((uint8 *)(addr))[t] = u.u8[t]; \
227
+ } \
228
+ } \
229
+ } while (0)
230
+
231
+ static inline void
232
+ STORE_U32(void *addr, uint32_t value)
233
+ {
234
+ uintptr_t addr_ = (uintptr_t)(addr);
235
+ union {
236
+ uint32_t val;
237
+ uint16_t u16[2];
238
+ uint8_t u8[4];
239
+ } u;
240
+ if ((addr_ & (uintptr_t)3) == 0)
241
+ *(uint32_t *)(addr) = (uint32_t)(value);
242
+ else {
243
+ u.val = (uint32_t)(value);
244
+ if ((addr_ & (uintptr_t)1) == 0) {
245
+ ((uint16_t *)(addr))[0] = u.u16[0];
246
+ ((uint16_t *)(addr))[1] = u.u16[1];
247
+ }
248
+ else {
249
+ ((uint8_t *)(addr))[0] = u.u8[0];
250
+ ((uint8_t *)(addr))[1] = u.u8[1];
251
+ ((uint8_t *)(addr))[2] = u.u8[2];
252
+ ((uint8_t *)(addr))[3] = u.u8[3];
253
+ }
254
+ }
255
+ }
256
+
257
+ static inline void
258
+ STORE_U8(void *addr, uint8_t value)
259
+ {
260
+ *(uint8 *)addr = value;
261
+ }
262
+
263
+ static inline void
264
+ STORE_U16(void *addr, uint16_t value)
265
+ {
266
+ union {
267
+ uint16_t val;
268
+ uint8_t u8[2];
269
+ } u;
270
+ u.val = (uint16_t)(value);
271
+ ((uint8_t *)(addr))[0] = u.u8[0];
272
+ ((uint8_t *)(addr))[1] = u.u8[1];
273
+ }
274
+
275
+ static inline void
276
+ STORE_V128(void *addr, V128 value)
277
+ {
278
+ uintptr_t addr_ = (uintptr_t)(addr);
279
+ union {
280
+ V128 val;
281
+ uint64 u64[2];
282
+ uint32 u32[4];
283
+ uint16 u16[8];
284
+ uint8 u8[16];
285
+ } u;
286
+
287
+ if ((addr_ & (uintptr_t)15) == 0) {
288
+ *(V128 *)addr = value;
289
+ }
290
+ else if ((addr_ & (uintptr_t)7) == 0) {
291
+ u.val = value;
292
+ ((uint64 *)(addr))[0] = u.u64[0];
293
+ ((uint64 *)(addr))[1] = u.u64[1];
294
+ }
295
+ else if ((addr_ & (uintptr_t)3) == 0) {
296
+ u.val = value;
297
+ ((uint32 *)addr)[0] = u.u32[0];
298
+ ((uint32 *)addr)[1] = u.u32[1];
299
+ ((uint32 *)addr)[2] = u.u32[2];
300
+ ((uint32 *)addr)[3] = u.u32[3];
301
+ }
302
+ else if ((addr_ & (uintptr_t)1) == 0) {
303
+ u.val = value;
304
+ ((uint16 *)addr)[0] = u.u16[0];
305
+ ((uint16 *)addr)[1] = u.u16[1];
306
+ ((uint16 *)addr)[2] = u.u16[2];
307
+ ((uint16 *)addr)[3] = u.u16[3];
308
+ ((uint16 *)addr)[4] = u.u16[4];
309
+ ((uint16 *)addr)[5] = u.u16[5];
310
+ ((uint16 *)addr)[6] = u.u16[6];
311
+ ((uint16 *)addr)[7] = u.u16[7];
312
+ }
313
+ else {
314
+ u.val = value;
315
+ for (int i = 0; i < 16; i++)
316
+ ((uint8 *)addr)[i] = u.u8[i];
317
+ }
318
+ }
319
+
320
+ /* For LOAD opcodes */
321
+ static inline V128
322
+ LOAD_V128(void *addr)
323
+ {
324
+ uintptr_t addr1 = (uintptr_t)addr;
325
+ union {
326
+ V128 val;
327
+ uint64 u64[2];
328
+ uint32 u32[4];
329
+ uint16 u16[8];
330
+ uint8 u8[16];
331
+ } u;
332
+ if ((addr1 & (uintptr_t)15) == 0)
333
+ return *(V128 *)addr;
334
+
335
+ if ((addr1 & (uintptr_t)7) == 0) {
336
+ u.u64[0] = ((uint64 *)addr)[0];
337
+ u.u64[1] = ((uint64 *)addr)[1];
338
+ }
339
+ else if ((addr1 & (uintptr_t)3) == 0) {
340
+ u.u32[0] = ((uint32 *)addr)[0];
341
+ u.u32[1] = ((uint32 *)addr)[1];
342
+ u.u32[2] = ((uint32 *)addr)[2];
343
+ u.u32[3] = ((uint32 *)addr)[3];
344
+ }
345
+ else if ((addr1 & (uintptr_t)1) == 0) {
346
+ u.u16[0] = ((uint16 *)addr)[0];
347
+ u.u16[1] = ((uint16 *)addr)[1];
348
+ u.u16[2] = ((uint16 *)addr)[2];
349
+ u.u16[3] = ((uint16 *)addr)[3];
350
+ u.u16[4] = ((uint16 *)addr)[4];
351
+ u.u16[5] = ((uint16 *)addr)[5];
352
+ u.u16[6] = ((uint16 *)addr)[6];
353
+ u.u16[7] = ((uint16 *)addr)[7];
354
+ }
355
+ else {
356
+ for (int i = 0; i < 16; i++)
357
+ u.u8[i] = ((uint8 *)addr)[i];
358
+ }
359
+ return u.val;
360
+ }
361
+
362
+ static inline int64
363
+ LOAD_I64(void *addr)
364
+ {
365
+ uintptr_t addr1 = (uintptr_t)addr;
366
+ union {
367
+ int64 val;
368
+ uint32 u32[2];
369
+ uint16 u16[4];
370
+ uint8 u8[8];
371
+ } u;
372
+ if ((addr1 & (uintptr_t)7) == 0)
373
+ return *(int64 *)addr;
374
+
375
+ if ((addr1 & (uintptr_t)3) == 0) {
376
+ u.u32[0] = ((uint32 *)addr)[0];
377
+ u.u32[1] = ((uint32 *)addr)[1];
378
+ }
379
+ else if ((addr1 & (uintptr_t)1) == 0) {
380
+ u.u16[0] = ((uint16 *)addr)[0];
381
+ u.u16[1] = ((uint16 *)addr)[1];
382
+ u.u16[2] = ((uint16 *)addr)[2];
383
+ u.u16[3] = ((uint16 *)addr)[3];
384
+ }
385
+ else {
386
+ int32 t;
387
+ for (t = 0; t < 8; t++)
388
+ u.u8[t] = ((uint8 *)addr)[t];
389
+ }
390
+ return u.val;
391
+ }
392
+
393
+ static inline float64
394
+ LOAD_F64(void *addr)
395
+ {
396
+ uintptr_t addr1 = (uintptr_t)addr;
397
+ union {
398
+ float64 val;
399
+ uint32 u32[2];
400
+ uint16 u16[4];
401
+ uint8 u8[8];
402
+ } u;
403
+ if ((addr1 & (uintptr_t)7) == 0)
404
+ return *(float64 *)addr;
405
+
406
+ if ((addr1 & (uintptr_t)3) == 0) {
407
+ u.u32[0] = ((uint32 *)addr)[0];
408
+ u.u32[1] = ((uint32 *)addr)[1];
409
+ }
410
+ else if ((addr1 & (uintptr_t)1) == 0) {
411
+ u.u16[0] = ((uint16 *)addr)[0];
412
+ u.u16[1] = ((uint16 *)addr)[1];
413
+ u.u16[2] = ((uint16 *)addr)[2];
414
+ u.u16[3] = ((uint16 *)addr)[3];
415
+ }
416
+ else {
417
+ int32 t;
418
+ for (t = 0; t < 8; t++)
419
+ u.u8[t] = ((uint8 *)addr)[t];
420
+ }
421
+ return u.val;
422
+ }
423
+
424
+ static inline int32
425
+ LOAD_I32(void *addr)
426
+ {
427
+ uintptr_t addr1 = (uintptr_t)addr;
428
+ union {
429
+ int32 val;
430
+ uint16 u16[2];
431
+ uint8 u8[4];
432
+ } u;
433
+ if ((addr1 & (uintptr_t)3) == 0)
434
+ return *(int32 *)addr;
435
+
436
+ if ((addr1 & (uintptr_t)1) == 0) {
437
+ u.u16[0] = ((uint16 *)addr)[0];
438
+ u.u16[1] = ((uint16 *)addr)[1];
439
+ }
440
+ else {
441
+ u.u8[0] = ((uint8 *)addr)[0];
442
+ u.u8[1] = ((uint8 *)addr)[1];
443
+ u.u8[2] = ((uint8 *)addr)[2];
444
+ u.u8[3] = ((uint8 *)addr)[3];
445
+ }
446
+ return u.val;
447
+ }
448
+
449
+ static inline int16
450
+ LOAD_I16(void *addr)
451
+ {
452
+ uintptr_t addr1 = (uintptr_t)addr;
453
+ union {
454
+ int16 val;
455
+ uint8 u8[2];
456
+ } u;
457
+ if ((addr1 & (uintptr_t)1)) {
458
+ u.u8[0] = ((uint8 *)addr)[0];
459
+ u.u8[1] = ((uint8 *)addr)[1];
460
+ return u.val;
461
+ }
462
+ return *(int16 *)addr;
463
+ }
464
+
465
+ #define LOAD_U32(addr) ((uint32)LOAD_I32(addr))
466
+ #define LOAD_U16(addr) ((uint16)LOAD_I16(addr))
467
+
468
+ #if UINTPTR_MAX == UINT32_MAX
469
+ #define STORE_PTR(addr, ptr) STORE_U32(addr, (uintptr_t)ptr)
470
+ #elif UINTPTR_MAX == UINT64_MAX
471
+ #define STORE_PTR(addr, ptr) STORE_I64(addr, (uintptr_t)ptr)
472
+ #endif
473
+
474
+ #endif /* WASM_CPU_SUPPORTS_UNALIGNED_ADDR_ACCESS != 0 */
475
+
476
+ #if WASM_ENABLE_SHARED_MEMORY != 0
477
+ #define SHARED_MEMORY_LOCK(memory) shared_memory_lock(memory)
478
+ #define SHARED_MEMORY_UNLOCK(memory) shared_memory_unlock(memory)
479
+ #else
480
+ #define SHARED_MEMORY_LOCK(memory) (void)0
481
+ #define SHARED_MEMORY_UNLOCK(memory) (void)0
482
+ #endif
483
+
484
+ #define CLAMP_U64_TO_U32(value) \
485
+ ((value) > UINT32_MAX ? UINT32_MAX : (uint32)(value))
486
+
487
+ typedef struct WASMModuleCommon {
488
+ /* Module type, for module loaded from WASM bytecode binary,
489
+ this field is Wasm_Module_Bytecode, and this structure should
490
+ be treated as WASMModule structure;
491
+ for module loaded from AOT binary, this field is
492
+ Wasm_Module_AoT, and this structure should be treated as
493
+ AOTModule structure. */
494
+ uint32 module_type;
495
+
496
+ /* The following uint8[1] member is a dummy just to indicate
497
+ some module_type dependent members follow.
498
+ Typically, it should be accessed by casting to the corresponding
499
+ actual module_type dependent structure, not via this member. */
500
+ uint8 module_data[1];
501
+ } WASMModuleCommon;
502
+
503
+ typedef struct WASMModuleInstanceCommon {
504
+ /* Module instance type, for module instance loaded from WASM
505
+ bytecode binary, this field is Wasm_Module_Bytecode, and this
506
+ structure should be treated as WASMModuleInstance structure;
507
+ for module instance loaded from AOT binary, this field is
508
+ Wasm_Module_AoT, and this structure should be treated as
509
+ AOTModuleInstance structure. */
510
+ uint32 module_type;
511
+
512
+ /* The following uint8[1] member is a dummy just to indicate
513
+ some module_type dependent members follow.
514
+ Typically, it should be accessed by casting to the corresponding
515
+ actual module_type dependent structure, not via this member. */
516
+ uint8 module_inst_data[1];
517
+ } WASMModuleInstanceCommon;
518
+
519
+ typedef struct WASMModuleMemConsumption {
520
+ uint32 total_size;
521
+ uint32 module_struct_size;
522
+ uint32 types_size;
523
+ uint32 imports_size;
524
+ uint32 functions_size;
525
+ uint32 tables_size;
526
+ uint32 memories_size;
527
+ uint32 globals_size;
528
+ uint32 exports_size;
529
+ uint32 table_segs_size;
530
+ uint32 data_segs_size;
531
+ uint32 const_strs_size;
532
+ #if WASM_ENABLE_AOT != 0
533
+ uint32 aot_code_size;
534
+ #endif
535
+ } WASMModuleMemConsumption;
536
+
537
+ typedef struct WASMModuleInstMemConsumption {
538
+ uint64 total_size;
539
+ uint32 module_inst_struct_size;
540
+ uint32 app_heap_size;
541
+ uint64 memories_size;
542
+ uint32 tables_size;
543
+ uint32 globals_size;
544
+ uint32 functions_size;
545
+ uint32 exports_size;
546
+ } WASMModuleInstMemConsumption;
547
+
548
+ #if WASM_ENABLE_LIBC_WASI != 0
549
+ #if WASM_ENABLE_UVWASI == 0
550
+ typedef struct WASIContext {
551
+ struct fd_table *curfds;
552
+ struct fd_prestats *prestats;
553
+ struct argv_environ_values *argv_environ;
554
+ struct addr_pool *addr_pool;
555
+ char *ns_lookup_buf;
556
+ char **ns_lookup_list;
557
+ char *argv_buf;
558
+ char **argv_list;
559
+ char *env_buf;
560
+ char **env_list;
561
+ uint32_t exit_code;
562
+ } WASIContext;
563
+ #else
564
+ typedef struct WASIContext {
565
+ uvwasi_t uvwasi;
566
+ uint32_t exit_code;
567
+ } WASIContext;
568
+ #endif
569
+ #endif
570
+
571
+ #if WASM_ENABLE_MULTI_MODULE != 0
572
+ typedef struct WASMRegisteredModule {
573
+ bh_list_link l;
574
+ /* point to a string pool */
575
+ const char *module_name;
576
+ WASMModuleCommon *module;
577
+ /* to store the original module file buffer address */
578
+ uint8 *orig_file_buf;
579
+ uint32 orig_file_buf_size;
580
+ } WASMRegisteredModule;
581
+ #endif
582
+
583
+ typedef package_type_t PackageType;
584
+ typedef wasm_section_t WASMSection, AOTSection;
585
+
586
+ #if WASM_ENABLE_JIT != 0
587
+ typedef struct LLVMJITOptions {
588
+ uint32 opt_level;
589
+ uint32 size_level;
590
+ uint32 segue_flags;
591
+ bool quick_invoke_c_api_import;
592
+ } LLVMJITOptions;
593
+ #endif
594
+
595
+ #ifdef OS_ENABLE_HW_BOUND_CHECK
596
+ /* Signal info passing to interp/aot signal handler */
597
+ typedef struct WASMSignalInfo {
598
+ WASMExecEnv *exec_env_tls;
599
+ #ifndef BH_PLATFORM_WINDOWS
600
+ void *sig_addr;
601
+ #else
602
+ EXCEPTION_POINTERS *exce_info;
603
+ #endif
604
+ } WASMSignalInfo;
605
+
606
+ /* Set exec_env of thread local storage */
607
+ void
608
+ wasm_runtime_set_exec_env_tls(WASMExecEnv *exec_env);
609
+
610
+ /* Get exec_env of thread local storage */
611
+ WASMExecEnv *
612
+ wasm_runtime_get_exec_env_tls(void);
613
+ #endif
614
+
615
+ struct InstantiationArgs2 {
616
+ InstantiationArgs v1;
617
+ };
618
+
619
+ /* See wasm_export.h for description */
620
+ WASM_RUNTIME_API_EXTERN bool
621
+ wasm_runtime_init(void);
622
+
623
+ /* Internal API */
624
+ RunningMode
625
+ wasm_runtime_get_default_running_mode(void);
626
+
627
+ #if WASM_ENABLE_JIT != 0
628
+ /* Internal API */
629
+ LLVMJITOptions *
630
+ wasm_runtime_get_llvm_jit_options(void);
631
+ #endif
632
+
633
+ #if WASM_ENABLE_GC != 0
634
+ /* Internal API */
635
+ uint32
636
+ wasm_runtime_get_gc_heap_size_default(void);
637
+ #endif
638
+
639
+ /* See wasm_export.h for description */
640
+ WASM_RUNTIME_API_EXTERN bool
641
+ wasm_runtime_full_init(RuntimeInitArgs *init_args);
642
+
643
+ /* See wasm_export.h for description */
644
+ WASM_RUNTIME_API_EXTERN bool
645
+ wasm_runtime_is_running_mode_supported(RunningMode running_mode);
646
+
647
+ /* See wasm_export.h for description */
648
+ WASM_RUNTIME_API_EXTERN bool
649
+ wasm_runtime_set_default_running_mode(RunningMode running_mode);
650
+
651
+ /* See wasm_export.h for description */
652
+ WASM_RUNTIME_API_EXTERN void
653
+ wasm_runtime_destroy(void);
654
+
655
+ /* See wasm_export.h for description */
656
+ WASM_RUNTIME_API_EXTERN PackageType
657
+ get_package_type(const uint8 *buf, uint32 size);
658
+
659
+ /* See wasm_export.h for description */
660
+ WASM_RUNTIME_API_EXTERN bool
661
+ wasm_runtime_is_xip_file(const uint8 *buf, uint32 size);
662
+
663
+ /* See wasm_export.h for description */
664
+ WASM_RUNTIME_API_EXTERN WASMModuleCommon *
665
+ wasm_runtime_load(uint8 *buf, uint32 size, char *error_buf,
666
+ uint32 error_buf_size);
667
+
668
+ /* See wasm_export.h for description */
669
+ WASM_RUNTIME_API_EXTERN WASMModuleCommon *
670
+ wasm_runtime_load_from_sections(WASMSection *section_list, bool is_aot,
671
+ char *error_buf, uint32 error_buf_size);
672
+
673
+ /* See wasm_export.h for description */
674
+ WASM_RUNTIME_API_EXTERN void
675
+ wasm_runtime_unload(WASMModuleCommon *module);
676
+
677
+ /* Internal API */
678
+ uint32
679
+ wasm_runtime_get_max_mem(uint32 max_memory_pages, uint32 module_init_page_count,
680
+ uint32 module_max_page_count);
681
+
682
+ /* Internal API */
683
+ WASMModuleInstanceCommon *
684
+ wasm_runtime_instantiate_internal(WASMModuleCommon *module,
685
+ WASMModuleInstanceCommon *parent,
686
+ WASMExecEnv *exec_env_main, uint32 stack_size,
687
+ uint32 heap_size, uint32 max_memory_pages,
688
+ char *error_buf, uint32 error_buf_size);
689
+
690
+ /* Internal API */
691
+ void
692
+ wasm_runtime_deinstantiate_internal(WASMModuleInstanceCommon *module_inst,
693
+ bool is_sub_inst);
694
+
695
+ /* See wasm_export.h for description */
696
+ WASM_RUNTIME_API_EXTERN WASMModuleInstanceCommon *
697
+ wasm_runtime_instantiate(WASMModuleCommon *module, uint32 default_stack_size,
698
+ uint32 host_managed_heap_size, char *error_buf,
699
+ uint32 error_buf_size);
700
+
701
+ /* See wasm_export.h for description */
702
+ WASM_RUNTIME_API_EXTERN WASMModuleInstanceCommon *
703
+ wasm_runtime_instantiate_ex(WASMModuleCommon *module,
704
+ const InstantiationArgs *args, char *error_buf,
705
+ uint32 error_buf_size);
706
+
707
+ /* See wasm_export.h for description */
708
+ WASM_RUNTIME_API_EXTERN
709
+ bool
710
+ wasm_runtime_instantiation_args_create(struct InstantiationArgs2 **p);
711
+
712
+ /* See wasm_export.h for description */
713
+ WASM_RUNTIME_API_EXTERN
714
+ void
715
+ wasm_runtime_instantiation_args_destroy(struct InstantiationArgs2 *p);
716
+
717
+ /* See wasm_export.h for description */
718
+ WASM_RUNTIME_API_EXTERN
719
+ void
720
+ wasm_runtime_instantiation_args_set_default_stack_size(
721
+ struct InstantiationArgs2 *p, uint32 v);
722
+
723
+ /* See wasm_export.h for description */
724
+ WASM_RUNTIME_API_EXTERN
725
+ void
726
+ wasm_runtime_instantiation_args_set_host_managed_heap_size(
727
+ struct InstantiationArgs2 *p, uint32 v);
728
+
729
+ /* See wasm_export.h for description */
730
+ WASM_RUNTIME_API_EXTERN
731
+ void
732
+ wasm_runtime_instantiation_args_set_max_memory_pages(
733
+ struct InstantiationArgs2 *p, uint32 v);
734
+
735
+ /* See wasm_export.h for description */
736
+ WASM_RUNTIME_API_EXTERN WASMModuleInstanceCommon *
737
+ wasm_runtime_instantiate_ex2(WASMModuleCommon *module,
738
+ const struct InstantiationArgs2 *args,
739
+ char *error_buf, uint32 error_buf_size);
740
+
741
+ /* See wasm_export.h for description */
742
+ WASM_RUNTIME_API_EXTERN bool
743
+ wasm_runtime_set_running_mode(wasm_module_inst_t module_inst,
744
+ RunningMode running_mode);
745
+
746
+ /* See wasm_export.h for description */
747
+ WASM_RUNTIME_API_EXTERN RunningMode
748
+ wasm_runtime_get_running_mode(wasm_module_inst_t module_inst);
749
+
750
+ /* See wasm_export.h for description */
751
+ WASM_RUNTIME_API_EXTERN void
752
+ wasm_runtime_deinstantiate(WASMModuleInstanceCommon *module_inst);
753
+
754
+ /* See wasm_export.h for description */
755
+ WASM_RUNTIME_API_EXTERN WASMModuleCommon *
756
+ wasm_runtime_get_module(WASMModuleInstanceCommon *module_inst);
757
+
758
+ /* See wasm_export.h for description */
759
+ WASM_RUNTIME_API_EXTERN WASMFunctionInstanceCommon *
760
+ wasm_runtime_lookup_function(WASMModuleInstanceCommon *const module_inst,
761
+ const char *name);
762
+
763
+ /* Internal API */
764
+ WASMFuncType *
765
+ wasm_runtime_get_function_type(const WASMFunctionInstanceCommon *function,
766
+ uint32 module_type);
767
+
768
+ /* Internal API: function instance of table 0 element elem_index, or NULL if
769
+ the index is out of range, the element is null or it is not a function
770
+ reference */
771
+ WASMFunctionInstanceCommon *
772
+ wasm_runtime_get_table_func_inst(WASMModuleInstanceCommon *const module_inst,
773
+ uint32 elem_index);
774
+
775
+ /* See wasm_export.h for description */
776
+ WASM_RUNTIME_API_EXTERN uint32
777
+ wasm_func_get_param_count(WASMFunctionInstanceCommon *const func_inst,
778
+ WASMModuleInstanceCommon *const module_inst);
779
+
780
+ /* See wasm_export.h for description */
781
+ WASM_RUNTIME_API_EXTERN uint32
782
+ wasm_func_get_result_count(WASMFunctionInstanceCommon *const func_inst,
783
+ WASMModuleInstanceCommon *const module_inst);
784
+
785
+ /* See wasm_export.h for description */
786
+ WASM_RUNTIME_API_EXTERN void
787
+ wasm_func_get_param_types(WASMFunctionInstanceCommon *const func_inst,
788
+ WASMModuleInstanceCommon *const module_inst,
789
+ wasm_valkind_t *param_types);
790
+
791
+ /* See wasm_export.h for description */
792
+ WASM_RUNTIME_API_EXTERN void
793
+ wasm_func_get_result_types(WASMFunctionInstanceCommon *const func_inst,
794
+ WASMModuleInstanceCommon *const module_inst,
795
+ wasm_valkind_t *result_types);
796
+
797
+ /* See wasm_export.h for description */
798
+ WASM_RUNTIME_API_EXTERN WASMExecEnv *
799
+ wasm_runtime_create_exec_env(WASMModuleInstanceCommon *module_inst,
800
+ uint32 stack_size);
801
+
802
+ /* See wasm_export.h for description */
803
+ WASM_RUNTIME_API_EXTERN void
804
+ wasm_runtime_destroy_exec_env(WASMExecEnv *exec_env);
805
+
806
+ #if WASM_ENABLE_COPY_CALL_STACK != 0
807
+ WASM_RUNTIME_API_EXTERN uint32_t
808
+ wasm_copy_callstack(const wasm_exec_env_t exec_env, WASMCApiFrame *buffer,
809
+ const uint32 length, const uint32 skip_n, char *error_buf,
810
+ uint32 error_buf_size);
811
+ #endif // WASM_ENABLE_COPY_CALL_STACK
812
+
813
+ /* See wasm_export.h for description */
814
+ WASM_RUNTIME_API_EXTERN WASMModuleInstanceCommon *
815
+ wasm_runtime_get_module_inst(WASMExecEnv *exec_env);
816
+
817
+ /* See wasm_export.h for description */
818
+ WASM_RUNTIME_API_EXTERN void
819
+ wasm_runtime_set_module_inst(WASMExecEnv *exec_env,
820
+ WASMModuleInstanceCommon *const module_inst);
821
+
822
+ /* See wasm_export.h for description */
823
+ WASM_RUNTIME_API_EXTERN void *
824
+ wasm_runtime_get_function_attachment(WASMExecEnv *exec_env);
825
+
826
+ /* See wasm_export.h for description */
827
+ WASM_RUNTIME_API_EXTERN void
828
+ wasm_runtime_set_user_data(WASMExecEnv *exec_env, void *user_data);
829
+
830
+ /* See wasm_export.h for description */
831
+ WASM_RUNTIME_API_EXTERN void *
832
+ wasm_runtime_get_user_data(WASMExecEnv *exec_env);
833
+
834
+ /* See wasm_export.h for description */
835
+ WASM_RUNTIME_API_EXTERN void
836
+ wasm_runtime_set_native_stack_boundary(WASMExecEnv *exec_env,
837
+ uint8 *native_stack_boundary);
838
+
839
+ #if WASM_ENABLE_INSTRUCTION_METERING != 0
840
+ /* See wasm_export.h for description */
841
+ WASM_RUNTIME_API_EXTERN void
842
+ wasm_runtime_set_instruction_count_limit(WASMExecEnv *exec_env,
843
+ int instructions_to_execute);
844
+ #endif
845
+
846
+ #if WASM_CONFIGURABLE_BOUNDS_CHECKS != 0
847
+ /* See wasm_export.h for description */
848
+ WASM_RUNTIME_API_EXTERN
849
+ void
850
+ wasm_runtime_set_bounds_checks(WASMModuleInstanceCommon *module_inst,
851
+ bool enable);
852
+
853
+ /* See wasm_export.h for description */
854
+ WASM_RUNTIME_API_EXTERN bool
855
+ wasm_runtime_is_bounds_checks_enabled(WASMModuleInstanceCommon *module_inst);
856
+ #endif
857
+
858
+ #ifdef OS_ENABLE_HW_BOUND_CHECK
859
+ /* Access exception check guard page to trigger the signal handler */
860
+ void
861
+ wasm_runtime_access_exce_check_guard_page();
862
+ #endif
863
+
864
+ /* See wasm_export.h for description */
865
+ WASM_RUNTIME_API_EXTERN bool
866
+ wasm_runtime_call_wasm(WASMExecEnv *exec_env,
867
+ WASMFunctionInstanceCommon *function, uint32 argc,
868
+ uint32 argv[]);
869
+
870
+ WASM_RUNTIME_API_EXTERN bool
871
+ wasm_runtime_call_wasm_a(WASMExecEnv *exec_env,
872
+ WASMFunctionInstanceCommon *function,
873
+ uint32 num_results, wasm_val_t *results,
874
+ uint32 num_args, wasm_val_t *args);
875
+
876
+ WASM_RUNTIME_API_EXTERN bool
877
+ wasm_runtime_call_wasm_v(WASMExecEnv *exec_env,
878
+ WASMFunctionInstanceCommon *function,
879
+ uint32 num_results, wasm_val_t *results,
880
+ uint32 num_args, ...);
881
+
882
+ /* See wasm_export.h for description */
883
+ WASM_RUNTIME_API_EXTERN bool
884
+ wasm_runtime_call_indirect(WASMExecEnv *exec_env, uint32 element_index,
885
+ uint32 argc, uint32 argv[]);
886
+
887
+ #if WASM_ENABLE_DEBUG_INTERP != 0
888
+ /* See wasm_export.h for description */
889
+ WASM_RUNTIME_API_EXTERN uint32
890
+ wasm_runtime_start_debug_instance_with_port(WASMExecEnv *exec_env,
891
+ int32_t port);
892
+
893
+ /* See wasm_export.h for description */
894
+ WASM_RUNTIME_API_EXTERN uint32
895
+ wasm_runtime_start_debug_instance(WASMExecEnv *exec_env);
896
+ #endif
897
+
898
+ bool
899
+ wasm_runtime_create_exec_env_singleton(WASMModuleInstanceCommon *module_inst);
900
+
901
+ /* See wasm_export.h for description */
902
+ WASM_RUNTIME_API_EXTERN WASMExecEnv *
903
+ wasm_runtime_get_exec_env_singleton(WASMModuleInstanceCommon *module_inst);
904
+
905
+ /* See wasm_export.h for description */
906
+ WASM_RUNTIME_API_EXTERN bool
907
+ wasm_application_execute_main(WASMModuleInstanceCommon *module_inst, int32 argc,
908
+ char *argv[]);
909
+
910
+ /* See wasm_export.h for description */
911
+ WASM_RUNTIME_API_EXTERN bool
912
+ wasm_application_execute_func(WASMModuleInstanceCommon *module_inst,
913
+ const char *name, int32 argc, char *argv[]);
914
+
915
+ /* See wasm_export.h for description */
916
+ WASM_RUNTIME_API_EXTERN void
917
+ wasm_runtime_set_exception(WASMModuleInstanceCommon *module,
918
+ const char *exception);
919
+
920
+ /* See wasm_export.h for description */
921
+ WASM_RUNTIME_API_EXTERN const char *
922
+ wasm_runtime_get_exception(WASMModuleInstanceCommon *module);
923
+
924
+ /* See wasm_export.h for description */
925
+ WASM_RUNTIME_API_EXTERN void
926
+ wasm_runtime_clear_exception(WASMModuleInstanceCommon *module_inst);
927
+
928
+ /* See wasm_export.h for description */
929
+ WASM_RUNTIME_API_EXTERN void
930
+ wasm_runtime_terminate(WASMModuleInstanceCommon *module);
931
+
932
+ /* Internal API */
933
+ void
934
+ wasm_runtime_set_custom_data_internal(WASMModuleInstanceCommon *module_inst,
935
+ void *custom_data);
936
+
937
+ /* See wasm_export.h for description */
938
+ WASM_RUNTIME_API_EXTERN void
939
+ wasm_runtime_set_custom_data(WASMModuleInstanceCommon *module_inst,
940
+ void *custom_data);
941
+
942
+ /* See wasm_export.h for description */
943
+ WASM_RUNTIME_API_EXTERN void *
944
+ wasm_runtime_get_custom_data(WASMModuleInstanceCommon *module_inst);
945
+
946
+ /* Internal API */
947
+ uint64
948
+ wasm_runtime_module_malloc_internal(WASMModuleInstanceCommon *module_inst,
949
+ WASMExecEnv *exec_env, uint64 size,
950
+ void **p_native_addr);
951
+
952
+ /* Internal API */
953
+ uint64
954
+ wasm_runtime_module_realloc_internal(WASMModuleInstanceCommon *module_inst,
955
+ WASMExecEnv *exec_env, uint64 ptr,
956
+ uint64 size, void **p_native_addr);
957
+
958
+ /* Internal API */
959
+ void
960
+ wasm_runtime_module_free_internal(WASMModuleInstanceCommon *module_inst,
961
+ WASMExecEnv *exec_env, uint64 ptr);
962
+
963
+ /* See wasm_export.h for description */
964
+ WASM_RUNTIME_API_EXTERN uint64
965
+ wasm_runtime_module_malloc(WASMModuleInstanceCommon *module_inst, uint64 size,
966
+ void **p_native_addr);
967
+
968
+ /* See wasm_export.h for description */
969
+ WASM_RUNTIME_API_EXTERN void
970
+ wasm_runtime_module_free(WASMModuleInstanceCommon *module_inst, uint64 ptr);
971
+
972
+ /* See wasm_export.h for description */
973
+ WASM_RUNTIME_API_EXTERN uint64
974
+ wasm_runtime_module_dup_data(WASMModuleInstanceCommon *module_inst,
975
+ const char *src, uint64 size);
976
+
977
+ /* See wasm_export.h for description */
978
+ WASM_RUNTIME_API_EXTERN bool
979
+ wasm_runtime_validate_app_addr(WASMModuleInstanceCommon *module_inst,
980
+ uint64 app_offset, uint64 size);
981
+
982
+ /* See wasm_export.h for description */
983
+ WASM_RUNTIME_API_EXTERN bool
984
+ wasm_runtime_validate_app_str_addr(WASMModuleInstanceCommon *module_inst,
985
+ uint64 app_str_offset);
986
+
987
+ /* See wasm_export.h for description */
988
+ WASM_RUNTIME_API_EXTERN bool
989
+ wasm_runtime_validate_native_addr(WASMModuleInstanceCommon *module_inst,
990
+ void *native_ptr, uint64 size);
991
+
992
+ /* See wasm_export.h for description */
993
+ WASM_RUNTIME_API_EXTERN void *
994
+ wasm_runtime_addr_app_to_native(WASMModuleInstanceCommon *module_inst,
995
+ uint64 app_offset);
996
+
997
+ /* See wasm_export.h for description */
998
+ WASM_RUNTIME_API_EXTERN uint64
999
+ wasm_runtime_addr_native_to_app(WASMModuleInstanceCommon *module_inst,
1000
+ void *native_ptr);
1001
+
1002
+ /* See wasm_export.h for description */
1003
+ WASM_RUNTIME_API_EXTERN bool
1004
+ wasm_runtime_get_app_addr_range(WASMModuleInstanceCommon *module_inst,
1005
+ uint64 app_offset, uint64 *p_app_start_offset,
1006
+ uint64 *p_app_end_offset);
1007
+
1008
+ /* See wasm_export.h for description */
1009
+ WASM_RUNTIME_API_EXTERN bool
1010
+ wasm_runtime_get_native_addr_range(WASMModuleInstanceCommon *module_inst,
1011
+ uint8 *native_ptr,
1012
+ uint8 **p_native_start_addr,
1013
+ uint8 **p_native_end_addr);
1014
+
1015
+ /* See wasm_export.h for description */
1016
+ WASM_RUNTIME_API_EXTERN const uint8 *
1017
+ wasm_runtime_get_custom_section(WASMModuleCommon *const module_comm,
1018
+ const char *name, uint32 *len);
1019
+
1020
+ #if WASM_ENABLE_MULTI_MODULE != 0
1021
+ WASM_RUNTIME_API_EXTERN void
1022
+ wasm_runtime_set_module_reader(const module_reader reader,
1023
+ const module_destroyer destroyer);
1024
+
1025
+ module_reader
1026
+ wasm_runtime_get_module_reader(void);
1027
+
1028
+ module_destroyer
1029
+ wasm_runtime_get_module_destroyer(void);
1030
+
1031
+ bool
1032
+ wasm_runtime_register_module_internal(const char *module_name,
1033
+ WASMModuleCommon *module,
1034
+ uint8 *orig_file_buf,
1035
+ uint32 orig_file_buf_size,
1036
+ char *error_buf, uint32 error_buf_size);
1037
+
1038
+ void
1039
+ wasm_runtime_unregister_module(const WASMModuleCommon *module);
1040
+
1041
+ WASMModuleCommon *
1042
+ wasm_runtime_find_module_registered(const char *module_name);
1043
+
1044
+ bool
1045
+ wasm_runtime_add_loading_module(const char *module_name, char *error_buf,
1046
+ uint32 error_buf_size);
1047
+
1048
+ void
1049
+ wasm_runtime_delete_loading_module(const char *module_name);
1050
+
1051
+ bool
1052
+ wasm_runtime_is_loading_module(const char *module_name);
1053
+
1054
+ void
1055
+ wasm_runtime_destroy_loading_module_list(void);
1056
+
1057
+ WASMModuleCommon *
1058
+ wasm_runtime_search_sub_module(const WASMModuleCommon *parent_module,
1059
+ const char *sub_module_name);
1060
+
1061
+ bool
1062
+ wasm_runtime_register_sub_module(const WASMModuleCommon *parent_module,
1063
+ const char *sub_module_name,
1064
+ WASMModuleCommon *sub_module);
1065
+
1066
+ WASMModuleCommon *
1067
+ wasm_runtime_load_depended_module(const WASMModuleCommon *parent_module,
1068
+ const char *sub_module_name, char *error_buf,
1069
+ uint32 error_buf_size);
1070
+
1071
+ bool
1072
+ wasm_runtime_sub_module_instantiate(WASMModuleCommon *module,
1073
+ WASMModuleInstanceCommon *module_inst,
1074
+ uint32 stack_size, uint32 heap_size,
1075
+ uint32 max_memory_pages, char *error_buf,
1076
+ uint32 error_buf_size);
1077
+ void
1078
+ wasm_runtime_sub_module_deinstantiate(WASMModuleInstanceCommon *module_inst);
1079
+ #endif
1080
+
1081
+ #if WASM_ENABLE_LIBC_WASI != 0 || WASM_ENABLE_MULTI_MODULE != 0
1082
+ WASMExport *
1083
+ loader_find_export(const WASMModuleCommon *module, const char *module_name,
1084
+ const char *field_name, uint8 export_kind, char *error_buf,
1085
+ uint32 error_buf_size);
1086
+ #endif /* WASM_ENABLE_MULTI_MODULE */
1087
+
1088
+ bool
1089
+ wasm_runtime_is_built_in_module(const char *module_name);
1090
+
1091
+ #if WASM_ENABLE_THREAD_MGR != 0
1092
+ bool
1093
+ wasm_exec_env_get_aux_stack(WASMExecEnv *exec_env, uint64 *start_offset,
1094
+ uint32 *size);
1095
+
1096
+ bool
1097
+ wasm_exec_env_set_aux_stack(WASMExecEnv *exec_env, uint64 start_offset,
1098
+ uint32 size);
1099
+ #endif
1100
+
1101
+ #if WASM_ENABLE_LIBC_WASI != 0
1102
+ WASM_RUNTIME_API_EXTERN void
1103
+ wasm_runtime_set_wasi_args_ex(WASMModuleCommon *module, const char *dir_list[],
1104
+ uint32 dir_count, const char *map_dir_list[],
1105
+ uint32 map_dir_count, const char *env_list[],
1106
+ uint32 env_count, char *argv[], int argc,
1107
+ int64 stdinfd, int64 stdoutfd, int64 stderrfd);
1108
+
1109
+ /* See wasm_export.h for description */
1110
+ WASM_RUNTIME_API_EXTERN void
1111
+ wasm_runtime_set_wasi_args(WASMModuleCommon *module, const char *dir_list[],
1112
+ uint32 dir_count, const char *map_dir_list[],
1113
+ uint32 map_dir_count, const char *env_list[],
1114
+ uint32 env_count, char *argv[], int argc);
1115
+
1116
+ /* See wasm_export.h for description */
1117
+ WASM_RUNTIME_API_EXTERN bool
1118
+ wasm_runtime_is_wasi_mode(WASMModuleInstanceCommon *module_inst);
1119
+
1120
+ /* See wasm_export.h for description */
1121
+ WASM_RUNTIME_API_EXTERN WASMFunctionInstanceCommon *
1122
+ wasm_runtime_lookup_wasi_start_function(WASMModuleInstanceCommon *module_inst);
1123
+
1124
+ /* See wasm_export.h for description */
1125
+ WASM_RUNTIME_API_EXTERN uint32_t
1126
+ wasm_runtime_get_wasi_exit_code(WASMModuleInstanceCommon *module_inst);
1127
+
1128
+ bool
1129
+ wasm_runtime_init_wasi(WASMModuleInstanceCommon *module_inst,
1130
+ const char *dir_list[], uint32 dir_count,
1131
+ const char *map_dir_list[], uint32 map_dir_count,
1132
+ const char *env[], uint32 env_count,
1133
+ const char *addr_pool[], uint32 addr_pool_size,
1134
+ const char *ns_lookup_pool[], uint32 ns_lookup_pool_size,
1135
+ char *argv[], uint32 argc, os_raw_file_handle stdinfd,
1136
+ os_raw_file_handle stdoutfd, os_raw_file_handle stderrfd,
1137
+ char *error_buf, uint32 error_buf_size);
1138
+
1139
+ void
1140
+ wasm_runtime_destroy_wasi(WASMModuleInstanceCommon *module_inst);
1141
+
1142
+ void
1143
+ wasm_runtime_set_wasi_ctx(WASMModuleInstanceCommon *module_inst,
1144
+ WASIContext *wasi_ctx);
1145
+
1146
+ WASIContext *
1147
+ wasm_runtime_get_wasi_ctx(WASMModuleInstanceCommon *module_inst);
1148
+
1149
+ WASM_RUNTIME_API_EXTERN void
1150
+ wasm_runtime_set_wasi_addr_pool(wasm_module_t module, const char *addr_pool[],
1151
+ uint32 addr_pool_size);
1152
+
1153
+ WASM_RUNTIME_API_EXTERN void
1154
+ wasm_runtime_set_wasi_ns_lookup_pool(wasm_module_t module,
1155
+ const char *ns_lookup_pool[],
1156
+ uint32 ns_lookup_pool_size);
1157
+ #endif /* end of WASM_ENABLE_LIBC_WASI */
1158
+
1159
+ #if WASM_ENABLE_GC != 0
1160
+ void
1161
+ wasm_runtime_set_gc_heap_handle(WASMModuleInstanceCommon *module_inst,
1162
+ void *gc_heap_handle);
1163
+
1164
+ void *
1165
+ wasm_runtime_get_gc_heap_handle(WASMModuleInstanceCommon *module_inst);
1166
+ #endif
1167
+
1168
+ #if WASM_ENABLE_REF_TYPES != 0
1169
+ /* See wasm_export.h for description */
1170
+ WASM_RUNTIME_API_EXTERN bool
1171
+ wasm_externref_obj2ref(WASMModuleInstanceCommon *module_inst, void *extern_obj,
1172
+ uint32 *p_externref_idx);
1173
+
1174
+ /* See wasm_export.h for description */
1175
+ WASM_RUNTIME_API_EXTERN bool
1176
+ wasm_externref_ref2obj(uint32 externref_idx, void **p_extern_obj);
1177
+
1178
+ /* See wasm_export.h for description */
1179
+ WASM_RUNTIME_API_EXTERN bool
1180
+ wasm_externref_retain(uint32 externref_idx);
1181
+
1182
+ /**
1183
+ * Reclaim the externref objects/indexes which are not used by
1184
+ * module instance
1185
+ */
1186
+ void
1187
+ wasm_externref_reclaim(WASMModuleInstanceCommon *module_inst);
1188
+
1189
+ /**
1190
+ * Cleanup the externref objects/indexes of the module instance
1191
+ */
1192
+ void
1193
+ wasm_externref_cleanup(WASMModuleInstanceCommon *module_inst);
1194
+ #endif /* end of WASM_ENABLE_REF_TYPES */
1195
+
1196
+ #if WASM_ENABLE_DUMP_CALL_STACK != 0
1197
+ /**
1198
+ * @brief Internal implementation for dumping or printing callstack line
1199
+ *
1200
+ * @note if dump_or_print is true, then print to stdout directly;
1201
+ * if dump_or_print is false, but *buf is NULL, then return the length of the
1202
+ * line;
1203
+ * if dump_or_print is false, and *buf is not NULL, then dump content to
1204
+ * the memory pointed by *buf, and adjust *buf and *len according to actual
1205
+ * bytes dumped, and return the actual dumped length
1206
+ *
1207
+ * @param line_buf current line to dump or print
1208
+ * @param dump_or_print whether to print to stdout or dump to buf
1209
+ * @param buf [INOUT] pointer to the buffer
1210
+ * @param len [INOUT] pointer to remaining length
1211
+ * @return bytes printed to stdout or dumped to buf
1212
+ */
1213
+ uint32
1214
+ wasm_runtime_dump_line_buf_impl(const char *line_buf, bool dump_or_print,
1215
+ char **buf, uint32 *len);
1216
+ #endif /* end of WASM_ENABLE_DUMP_CALL_STACK != 0 */
1217
+
1218
+ /* Get module of the current exec_env */
1219
+ WASMModuleCommon *
1220
+ wasm_exec_env_get_module(WASMExecEnv *exec_env);
1221
+
1222
+ /* See wasm_export.h for description */
1223
+ WASM_RUNTIME_API_EXTERN bool
1224
+ wasm_runtime_register_natives(const char *module_name,
1225
+ NativeSymbol *native_symbols,
1226
+ uint32 n_native_symbols);
1227
+
1228
+ /* See wasm_export.h for description */
1229
+ WASM_RUNTIME_API_EXTERN bool
1230
+ wasm_runtime_register_natives_raw(const char *module_name,
1231
+ NativeSymbol *native_symbols,
1232
+ uint32 n_native_symbols);
1233
+
1234
+ /* See wasm_export.h for description */
1235
+ WASM_RUNTIME_API_EXTERN bool
1236
+ wasm_runtime_unregister_natives(const char *module_name,
1237
+ NativeSymbol *native_symbols);
1238
+
1239
+ /* See wasm_export.h for description */
1240
+ WASM_RUNTIME_API_EXTERN void *
1241
+ wasm_runtime_create_context_key(void (*dtor)(WASMModuleInstanceCommon *inst,
1242
+ void *ctx));
1243
+
1244
+ /* See wasm_export.h for description */
1245
+ WASM_RUNTIME_API_EXTERN void
1246
+ wasm_runtime_destroy_context_key(void *key);
1247
+
1248
+ /* See wasm_export.h for description */
1249
+ WASM_RUNTIME_API_EXTERN void
1250
+ wasm_runtime_set_context(WASMModuleInstanceCommon *inst, void *key, void *ctx);
1251
+ /* See wasm_export.h for description */
1252
+ WASM_RUNTIME_API_EXTERN void
1253
+ wasm_runtime_set_context_spread(WASMModuleInstanceCommon *inst, void *key,
1254
+ void *ctx);
1255
+ /* See wasm_export.h for description */
1256
+ WASM_RUNTIME_API_EXTERN void *
1257
+ wasm_runtime_get_context(WASMModuleInstanceCommon *inst, void *key);
1258
+
1259
+ bool
1260
+ wasm_runtime_invoke_native(WASMExecEnv *exec_env, void *func_ptr,
1261
+ const WASMFuncType *func_type, const char *signature,
1262
+ void *attachment, uint32 *argv, uint32 argc,
1263
+ uint32 *ret);
1264
+
1265
+ bool
1266
+ wasm_runtime_invoke_native_raw(WASMExecEnv *exec_env, void *func_ptr,
1267
+ const WASMFuncType *func_type,
1268
+ const char *signature, void *attachment,
1269
+ uint32 *argv, uint32 argc, uint32 *ret);
1270
+
1271
+ void
1272
+ wasm_runtime_read_v128(const uint8 *bytes, uint64 *ret1, uint64 *ret2);
1273
+
1274
+ void
1275
+ wasm_runtime_dump_module_mem_consumption(const WASMModuleCommon *module);
1276
+
1277
+ void
1278
+ wasm_runtime_dump_module_inst_mem_consumption(
1279
+ const WASMModuleInstanceCommon *module_inst);
1280
+
1281
+ void
1282
+ wasm_runtime_dump_exec_env_mem_consumption(const WASMExecEnv *exec_env);
1283
+
1284
+ bool
1285
+ wasm_runtime_get_table_elem_type(const WASMModuleCommon *module_comm,
1286
+ uint32 table_idx, uint8 *out_elem_type,
1287
+ #if WASM_ENABLE_GC != 0
1288
+ WASMRefType **out_ref_type,
1289
+ #endif
1290
+ uint32 *out_min_size, uint32 *out_max_size);
1291
+
1292
+ bool
1293
+ wasm_runtime_get_table_inst_elem_type(
1294
+ const WASMModuleInstanceCommon *module_inst_comm, uint32 table_idx,
1295
+ uint8 *out_elem_type,
1296
+ #if WASM_ENABLE_GC != 0
1297
+ WASMRefType **out_ref_type,
1298
+ #endif
1299
+ uint32 *out_min_size, uint32 *out_max_size);
1300
+
1301
+ bool
1302
+ wasm_runtime_get_export_func_type(const WASMModuleCommon *module_comm,
1303
+ const WASMExport *export_,
1304
+ WASMFuncType **out);
1305
+
1306
+ bool
1307
+ wasm_runtime_get_export_global_type(const WASMModuleCommon *module_comm,
1308
+ const WASMExport *export_,
1309
+ uint8 *out_val_type, bool *out_mutability);
1310
+
1311
+ bool
1312
+ wasm_runtime_get_export_memory_type(const WASMModuleCommon *module_comm,
1313
+ const WASMExport *export_,
1314
+ uint32 *out_min_page, uint32 *out_max_page);
1315
+
1316
+ bool
1317
+ wasm_runtime_get_export_table_type(const WASMModuleCommon *module_comm,
1318
+ const WASMExport *export_,
1319
+ uint8 *out_elem_type,
1320
+ #if WASM_ENABLE_GC != 0
1321
+ WASMRefType **out_ref_type,
1322
+ #endif
1323
+ uint32 *out_min_size, uint32 *out_max_size);
1324
+
1325
+ bool
1326
+ wasm_runtime_invoke_c_api_native(WASMModuleInstanceCommon *module_inst,
1327
+ void *func_ptr, WASMFuncType *func_type,
1328
+ uint32 argc, uint32 *argv, bool with_env,
1329
+ void *wasm_c_api_env);
1330
+
1331
+ struct CApiFuncImport;
1332
+ /* A quick version of wasm_runtime_invoke_c_api_native to directly invoke
1333
+ wasm-c-api import function from jitted code to improve performance */
1334
+ bool
1335
+ wasm_runtime_quick_invoke_c_api_native(WASMModuleInstanceCommon *module_inst,
1336
+ struct CApiFuncImport *c_api_import,
1337
+ wasm_val_t *params, uint32 param_count,
1338
+ wasm_val_t *results,
1339
+ uint32 result_count);
1340
+
1341
+ void
1342
+ wasm_runtime_show_app_heap_corrupted_prompt(void);
1343
+
1344
+ #if WASM_ENABLE_LOAD_CUSTOM_SECTION != 0
1345
+ void
1346
+ wasm_runtime_destroy_custom_sections(WASMCustomSection *section_list);
1347
+ #endif
1348
+
1349
+ WASM_RUNTIME_API_EXTERN bool
1350
+ wasm_runtime_is_import_func_linked(const char *module_name,
1351
+ const char *func_name);
1352
+
1353
+ WASM_RUNTIME_API_EXTERN bool
1354
+ wasm_runtime_is_import_global_linked(const char *module_name,
1355
+ const char *global_name);
1356
+
1357
+ WASM_RUNTIME_API_EXTERN bool
1358
+ wasm_runtime_begin_blocking_op(WASMExecEnv *exec_env);
1359
+
1360
+ WASM_RUNTIME_API_EXTERN void
1361
+ wasm_runtime_end_blocking_op(WASMExecEnv *exec_env);
1362
+
1363
+ void
1364
+ wasm_runtime_interrupt_blocking_op(WASMExecEnv *exec_env);
1365
+
1366
+ WASM_RUNTIME_API_EXTERN bool
1367
+ wasm_runtime_detect_native_stack_overflow(WASMExecEnv *exec_env);
1368
+
1369
+ WASM_RUNTIME_API_EXTERN bool
1370
+ wasm_runtime_detect_native_stack_overflow_size(WASMExecEnv *exec_env,
1371
+ uint32 requested_size);
1372
+
1373
+ WASM_RUNTIME_API_EXTERN bool
1374
+ wasm_runtime_is_underlying_binary_freeable(WASMModuleCommon *const module);
1375
+
1376
+ #if WASM_ENABLE_LINUX_PERF != 0
1377
+ bool
1378
+ wasm_runtime_get_linux_perf(void);
1379
+
1380
+ void
1381
+ wasm_runtime_set_linux_perf(bool flag);
1382
+ #endif
1383
+
1384
+ #if WASM_ENABLE_SHARED_HEAP != 0
1385
+ bool
1386
+ wasm_runtime_check_and_update_last_used_shared_heap(
1387
+ WASMModuleInstanceCommon *module_inst, uintptr_t app_offset, size_t bytes,
1388
+ uintptr_t *shared_heap_start_off_p, uintptr_t *shared_heap_end_off_p,
1389
+ uint8 **shared_heap_base_addr_adj_p, bool is_memory64);
1390
+ #endif
1391
+
1392
+ #ifdef __cplusplus
1393
+ }
1394
+ #endif
1395
+
1396
+ #endif /* end of _WASM_COMMON_H */