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,912 @@
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_RUNTIME_H
7
+ #define _WASM_RUNTIME_H
8
+
9
+ #include "wasm.h"
10
+ #include "bh_atomic.h"
11
+ #include "bh_bitmap.h"
12
+ #include "bh_hashmap.h"
13
+ #include "../common/wasm_runtime_common.h"
14
+ #include "../common/wasm_exec_env.h"
15
+
16
+ #ifdef __cplusplus
17
+ extern "C" {
18
+ #endif
19
+
20
+ #define EXCEPTION_BUF_LEN 128
21
+
22
+ typedef struct WASMModuleInstance WASMModuleInstance;
23
+ typedef struct WASMFunctionInstance WASMFunctionInstance;
24
+ typedef struct WASMMemoryInstance WASMMemoryInstance;
25
+ typedef struct WASMTableInstance WASMTableInstance;
26
+ typedef struct WASMGlobalInstance WASMGlobalInstance;
27
+ #if WASM_ENABLE_TAGS != 0
28
+ typedef struct WASMTagInstance WASMTagInstance;
29
+ #endif
30
+
31
+ /**
32
+ * When LLVM JIT, WAMR compiler or AOT is enabled, we should ensure that
33
+ * some offsets of the same field in the interpreter module instance and
34
+ * aot module instance are the same, so that the LLVM JITed/AOTed code
35
+ * can smoothly access the interpreter module instance.
36
+ * Same for the memory instance and table instance.
37
+ * We use the macro DefPointer to define some related pointer fields.
38
+ */
39
+ #if (WASM_ENABLE_JIT != 0 || WASM_ENABLE_WAMR_COMPILER != 0 \
40
+ || WASM_ENABLE_AOT != 0) \
41
+ && UINTPTR_MAX == UINT32_MAX
42
+ /* Add u32 padding if LLVM JIT, WAMR compiler or AOT is enabled on
43
+ 32-bit platform */
44
+ #define DefPointer(type, field) \
45
+ type field; \
46
+ uint32 field##_padding
47
+ #else
48
+ #define DefPointer(type, field) type field
49
+ #endif
50
+
51
+ typedef enum WASMExceptionID {
52
+ EXCE_UNREACHABLE = 0,
53
+ EXCE_OUT_OF_MEMORY,
54
+ EXCE_OUT_OF_BOUNDS_MEMORY_ACCESS,
55
+ EXCE_INTEGER_OVERFLOW,
56
+ EXCE_INTEGER_DIVIDE_BY_ZERO,
57
+ EXCE_INVALID_CONVERSION_TO_INTEGER,
58
+ EXCE_INVALID_FUNCTION_TYPE_INDEX,
59
+ EXCE_INVALID_FUNCTION_INDEX,
60
+ EXCE_UNDEFINED_ELEMENT,
61
+ EXCE_UNINITIALIZED_ELEMENT,
62
+ EXCE_CALL_UNLINKED_IMPORT_FUNC,
63
+ EXCE_NATIVE_STACK_OVERFLOW,
64
+ EXCE_UNALIGNED_ATOMIC,
65
+ EXCE_AUX_STACK_OVERFLOW,
66
+ EXCE_AUX_STACK_UNDERFLOW,
67
+ EXCE_OUT_OF_BOUNDS_TABLE_ACCESS,
68
+ EXCE_OPERAND_STACK_OVERFLOW,
69
+ EXCE_FAILED_TO_COMPILE_FAST_JIT_FUNC,
70
+ /* GC related exceptions */
71
+ EXCE_NULL_FUNC_OBJ,
72
+ EXCE_NULL_STRUCT_OBJ,
73
+ EXCE_NULL_ARRAY_OBJ,
74
+ EXCE_NULL_I31_OBJ,
75
+ EXCE_NULL_REFERENCE,
76
+ EXCE_FAILED_TO_CREATE_RTT_TYPE,
77
+ EXCE_FAILED_TO_CREATE_STRUCT_OBJ,
78
+ EXCE_FAILED_TO_CREATE_ARRAY_OBJ,
79
+ EXCE_FAILED_TO_CREATE_EXTERNREF_OBJ,
80
+ EXCE_CAST_FAILURE,
81
+ EXCE_ARRAY_IDX_OOB,
82
+ EXCE_FAILED_TO_CREATE_STRING,
83
+ EXCE_FAILED_TO_CREATE_STRINGREF,
84
+ EXCE_FAILED_TO_CREATE_STRINGVIEW,
85
+ EXCE_FAILED_TO_ENCODE_STRING,
86
+ EXCE_ALREADY_THROWN,
87
+ EXCE_NUM,
88
+ } WASMExceptionID;
89
+
90
+ typedef union {
91
+ uint64 u64;
92
+ uint32 u32[2];
93
+ } MemBound;
94
+
95
+ typedef struct WASMSharedHeap {
96
+ /* The global shared heap list maintained in runtime, used for runtime
97
+ * destroy */
98
+ DefPointer(struct WASMSharedHeap *, next);
99
+ /* The logical shared heap chain the shared heap in */
100
+ DefPointer(struct WASMSharedHeap *, chain_next);
101
+ /* Will be null if shared heap is created from pre allocated memory chunk
102
+ * and don't need to dynamic malloc and free */
103
+ DefPointer(void *, heap_handle);
104
+ DefPointer(uint8 *, base_addr);
105
+ uint64 size;
106
+ uint64 start_off_mem64;
107
+ uint64 start_off_mem32;
108
+ /* The number of wasm apps it attached to, for a shared heap chain, only the
109
+ * list head need to maintain the valid attached_count */
110
+ uint8 attached_count;
111
+ } WASMSharedHeap;
112
+
113
+ struct WASMMemoryInstance {
114
+ /* Module type */
115
+ uint32 module_type;
116
+
117
+ /* Whether the memory is shared */
118
+ uint8 is_shared_memory;
119
+
120
+ /* Whether the memory has 64-bit memory addresses */
121
+ uint8 is_memory64;
122
+
123
+ /* Reference count of the memory instance:
124
+ 0: non-shared memory, > 0: shared memory */
125
+ bh_atomic_16_t ref_count;
126
+
127
+ /* Four-byte paddings to ensure the layout of WASMMemoryInstance is the same
128
+ * in both 64-bit and 32-bit */
129
+ uint8 _paddings[4];
130
+
131
+ /* Number bytes per page */
132
+ uint32 num_bytes_per_page;
133
+ /* Current page count */
134
+ uint32 cur_page_count;
135
+ /* Maximum page count */
136
+ uint32 max_page_count;
137
+ /* Memory data size */
138
+ uint64 memory_data_size;
139
+ /**
140
+ * Memory data begin address, Note:
141
+ * the app-heap might be inserted in to the linear memory,
142
+ * when memory is re-allocated, the heap data and memory data
143
+ * must be copied to new memory also
144
+ */
145
+ DefPointer(uint8 *, memory_data);
146
+ /* Memory data end address */
147
+ DefPointer(uint8 *, memory_data_end);
148
+
149
+ /* Heap data base address */
150
+ DefPointer(uint8 *, heap_data);
151
+ /* Heap data end address */
152
+ DefPointer(uint8 *, heap_data_end);
153
+ /* The heap created */
154
+ DefPointer(void *, heap_handle);
155
+ /* TODO: use it to replace the g_shared_memory_lock */
156
+ DefPointer(korp_mutex *, memory_lock);
157
+
158
+ #if WASM_ENABLE_FAST_JIT != 0 || WASM_ENABLE_JIT != 0 \
159
+ || WASM_ENABLE_WAMR_COMPILER != 0 || WASM_ENABLE_AOT != 0
160
+ MemBound mem_bound_check_1byte;
161
+ MemBound mem_bound_check_2bytes;
162
+ MemBound mem_bound_check_4bytes;
163
+ MemBound mem_bound_check_8bytes;
164
+ MemBound mem_bound_check_16bytes;
165
+ #endif
166
+ };
167
+
168
+ /* WASMTableInstance is used to represent table instance in
169
+ * runtime, to compute the table element address with index
170
+ * we need to know the element type and the element ref type.
171
+ * For pointer type, it's 32-bit or 64-bit, align up to 8 bytes
172
+ * to simplify the computation.
173
+ * And each struct member should be 4-byte or 8-byte aligned.
174
+ */
175
+ struct WASMTableInstance {
176
+ /* The element type */
177
+ uint8 elem_type;
178
+ uint8 is_table64;
179
+ uint8 __padding__[6];
180
+ union {
181
+ #if WASM_ENABLE_GC != 0
182
+ WASMRefType *elem_ref_type;
183
+ #endif
184
+ uint64 __padding__;
185
+ } elem_ref_type;
186
+ /* Current size */
187
+ uint32 cur_size;
188
+ /* Maximum size */
189
+ uint32 max_size;
190
+ /* Table elements */
191
+ table_elem_type_t elems[1];
192
+ };
193
+
194
+ struct WASMGlobalInstance {
195
+ /* value type, VALUE_TYPE_I32/I64/F32/F64 */
196
+ uint8 type;
197
+ /* mutable or constant */
198
+ bool is_mutable;
199
+ /* data offset to the address of initial_value, started from the end of
200
+ * WASMMemoryInstance(start of WASMGlobalInstance)*/
201
+ uint32 data_offset;
202
+ /* initial value */
203
+ WASMValue initial_value;
204
+ #if WASM_ENABLE_GC != 0
205
+ WASMRefType *ref_type;
206
+ #endif
207
+ #if WASM_ENABLE_MULTI_MODULE != 0
208
+ /* just for import, keep the reference here */
209
+ WASMModuleInstance *import_module_inst;
210
+ WASMGlobalInstance *import_global_inst;
211
+ #endif
212
+ };
213
+
214
+ struct WASMFunctionInstance {
215
+ /* whether it is import function or WASM function */
216
+ bool is_import_func;
217
+ /* parameter count */
218
+ uint16 param_count;
219
+ /* local variable count, 0 for import function */
220
+ uint16 local_count;
221
+ /* cell num of parameters */
222
+ uint16 param_cell_num;
223
+ /* cell num of return type */
224
+ uint16 ret_cell_num;
225
+ /* cell num of local variables, 0 for import function */
226
+ uint16 local_cell_num;
227
+ #if WASM_ENABLE_FAST_INTERP != 0
228
+ /* cell num of consts */
229
+ uint16 const_cell_num;
230
+ #endif
231
+ uint16 *local_offsets;
232
+ /* parameter types */
233
+ uint8 *param_types;
234
+ /* local types, NULL for import function */
235
+ uint8 *local_types;
236
+ union {
237
+ WASMFunctionImport *func_import;
238
+ WASMFunction *func;
239
+ } u;
240
+ #if WASM_ENABLE_MULTI_MODULE != 0
241
+ WASMModuleInstance *import_module_inst;
242
+ WASMFunctionInstance *import_func_inst;
243
+ #endif
244
+ #if WASM_ENABLE_PERF_PROFILING != 0
245
+ /* total execution time */
246
+ uint64 total_exec_time;
247
+ /* total execution count */
248
+ uint32 total_exec_cnt;
249
+ /* children execution time */
250
+ uint64 children_exec_time;
251
+ #endif
252
+ };
253
+
254
+ #if WASM_ENABLE_TAGS != 0
255
+ struct WASMTagInstance {
256
+ bool is_import_tag;
257
+ /* tag attribute */
258
+ uint8 attribute;
259
+ /* tag type index */
260
+ uint32 type;
261
+ union {
262
+ WASMTagImport *tag_import;
263
+ WASMTag *tag;
264
+ } u;
265
+
266
+ #if WASM_ENABLE_MULTI_MODULE != 0
267
+ WASMModuleInstance *import_module_inst;
268
+ WASMTagInstance *import_tag_inst;
269
+ #endif
270
+ };
271
+ #endif
272
+
273
+ #if WASM_ENABLE_EXCE_HANDLING != 0
274
+ #define INVALID_TAGINDEX ((uint32)0xFFFFFFFF)
275
+ #define SET_INVALID_TAGINDEX(tag) (tag = INVALID_TAGINDEX)
276
+ #define IS_INVALID_TAGINDEX(tag) ((tag & INVALID_TAGINDEX) == INVALID_TAGINDEX)
277
+ #endif
278
+ typedef struct WASMExportFuncInstance {
279
+ char *name;
280
+ WASMFunctionInstance *function;
281
+ } WASMExportFuncInstance;
282
+
283
+ typedef struct WASMExportGlobInstance {
284
+ char *name;
285
+ WASMGlobalInstance *global;
286
+ } WASMExportGlobInstance;
287
+
288
+ typedef struct WASMExportTabInstance {
289
+ char *name;
290
+ WASMTableInstance *table;
291
+ } WASMExportTabInstance;
292
+
293
+ typedef struct WASMExportMemInstance {
294
+ char *name;
295
+ WASMMemoryInstance *memory;
296
+ } WASMExportMemInstance;
297
+
298
+ #if WASM_ENABLE_TAGS != 0
299
+ typedef struct WASMExportTagInstance {
300
+ char *name;
301
+ WASMTagInstance *tag;
302
+ } WASMExportTagInstance;
303
+ #endif
304
+
305
+ /* wasm-c-api import function info */
306
+ typedef struct CApiFuncImport {
307
+ /* host func pointer after linked */
308
+ void *func_ptr_linked;
309
+ /* whether the host func has env argument */
310
+ bool with_env_arg;
311
+ /* the env argument of the host func */
312
+ void *env_arg;
313
+ } CApiFuncImport;
314
+
315
+ /* The common part of WASMModuleInstanceExtra and AOTModuleInstanceExtra */
316
+ typedef struct WASMModuleInstanceExtraCommon {
317
+ #if WASM_ENABLE_MODULE_INST_CONTEXT != 0
318
+ void *contexts[WASM_MAX_INSTANCE_CONTEXTS];
319
+ #endif
320
+ #if WASM_CONFIGURABLE_BOUNDS_CHECKS != 0
321
+ /* Disable bounds checks or not */
322
+ bool disable_bounds_checks;
323
+ #endif
324
+ #if WASM_ENABLE_BULK_MEMORY != 0
325
+ bh_bitmap *data_dropped;
326
+ #endif
327
+ #if WASM_ENABLE_REF_TYPES != 0
328
+ bh_bitmap *elem_dropped;
329
+ #endif
330
+
331
+ #if WASM_ENABLE_GC != 0
332
+ /* The gc heap memory pool */
333
+ uint8 *gc_heap_pool;
334
+ /* The gc heap created */
335
+ void *gc_heap_handle;
336
+ #endif
337
+ } WASMModuleInstanceExtraCommon;
338
+
339
+ /* Extra info of WASM module instance for interpreter/jit mode */
340
+ typedef struct WASMModuleInstanceExtra {
341
+ WASMModuleInstanceExtraCommon common;
342
+
343
+ WASMGlobalInstance *globals;
344
+ WASMFunctionInstance *functions;
345
+
346
+ uint32 global_count;
347
+ uint32 function_count;
348
+
349
+ WASMFunctionInstance *start_function;
350
+ WASMFunctionInstance *malloc_function;
351
+ WASMFunctionInstance *free_function;
352
+ WASMFunctionInstance *retain_function;
353
+
354
+ RunningMode running_mode;
355
+
356
+ #if WASM_ENABLE_MULTI_MODULE != 0
357
+ bh_list sub_module_inst_list_head;
358
+ bh_list *sub_module_inst_list;
359
+ /* linked table instances of import table instances */
360
+ WASMTableInstance **table_insts_linked;
361
+ #endif
362
+
363
+ #if WASM_ENABLE_TAGS != 0
364
+ uint32 tag_count;
365
+ uint32 export_tag_count;
366
+ WASMTagInstance *tags;
367
+ WASMExportTagInstance *export_tags;
368
+ void **import_tag_ptrs;
369
+ #endif
370
+
371
+ #if WASM_ENABLE_MEMORY_PROFILING != 0
372
+ uint32 max_aux_stack_used;
373
+ #endif
374
+
375
+ #if WASM_ENABLE_SHARED_HEAP != 0
376
+ /*
377
+ * Adjusted shared heap based addr to simple the calculation
378
+ * in the aot code. The value is:
379
+ * shared_heap->base_addr - shared_heap->start_off
380
+ */
381
+ uint8 *shared_heap_base_addr_adj;
382
+ MemBound shared_heap_start_off;
383
+ MemBound shared_heap_end_off;
384
+ WASMSharedHeap *shared_heap;
385
+ #endif
386
+
387
+ #if WASM_ENABLE_DEBUG_INTERP != 0 \
388
+ || (WASM_ENABLE_FAST_JIT != 0 && WASM_ENABLE_JIT != 0 \
389
+ && WASM_ENABLE_LAZY_JIT != 0)
390
+ WASMModuleInstance *next;
391
+ #endif
392
+ } WASMModuleInstanceExtra;
393
+
394
+ struct AOTFuncPerfProfInfo;
395
+
396
+ struct WASMModuleInstance {
397
+ /* Module instance type, for module instance loaded from
398
+ WASM bytecode binary, this field is Wasm_Module_Bytecode;
399
+ for module instance loaded from AOT file, this field is
400
+ Wasm_Module_AoT, and this structure should be treated as
401
+ AOTModuleInstance structure. */
402
+ uint32 module_type;
403
+
404
+ uint32 memory_count;
405
+ DefPointer(WASMMemoryInstance **, memories);
406
+
407
+ /* global and table info */
408
+ uint32 global_data_size;
409
+ uint32 table_count;
410
+ DefPointer(uint8 *, global_data);
411
+ /* For AOTModuleInstance, it denotes `AOTTableInstance *` */
412
+ DefPointer(WASMTableInstance **, tables);
413
+
414
+ /* import func ptrs + llvm jit func ptrs */
415
+ DefPointer(void **, func_ptrs);
416
+
417
+ /* function type indexes */
418
+ DefPointer(uint32 *, func_type_indexes);
419
+
420
+ uint32 export_func_count;
421
+ uint32 export_global_count;
422
+ uint32 export_memory_count;
423
+ uint32 export_table_count;
424
+ /* For AOTModuleInstance, it denotes `AOTFunctionInstance *` */
425
+ DefPointer(WASMExportFuncInstance *, export_functions);
426
+ DefPointer(WASMExportGlobInstance *, export_globals);
427
+ DefPointer(WASMExportMemInstance *, export_memories);
428
+ DefPointer(WASMExportTabInstance *, export_tables);
429
+
430
+ /* The exception buffer of wasm interpreter for current thread. */
431
+ char cur_exception[EXCEPTION_BUF_LEN];
432
+
433
+ /* The WASM module or AOT module, for AOTModuleInstance,
434
+ it denotes `AOTModule *` */
435
+ DefPointer(WASMModule *, module);
436
+
437
+ DefPointer(WASMExecEnv *, exec_env_singleton);
438
+ /* Array of function pointers to import functions,
439
+ not available in AOTModuleInstance */
440
+ DefPointer(void **, import_func_ptrs);
441
+ /* Array of function pointers to fast jit functions,
442
+ not available in AOTModuleInstance:
443
+ Only when the multi-tier JIT macros are all enabled and the running
444
+ mode of current module instance is set to Mode_Fast_JIT, runtime
445
+ will allocate new memory for it, otherwise it always points to the
446
+ module->fast_jit_func_ptrs */
447
+ DefPointer(void **, fast_jit_func_ptrs);
448
+ /* The custom data that can be set/get by wasm_{get|set}_custom_data */
449
+ DefPointer(void *, custom_data);
450
+ /* Stack frames, used in call stack dump and perf profiling */
451
+ DefPointer(Vector *, frames);
452
+ /* Function performance profiling info list, only available
453
+ in AOTModuleInstance */
454
+ DefPointer(struct AOTFuncPerfProfInfo *, func_perf_profilings);
455
+ DefPointer(CApiFuncImport *, c_api_func_imports);
456
+ /* Pointer to the exec env currently used */
457
+ DefPointer(WASMExecEnv *, cur_exec_env);
458
+ /* WASM/AOT module extra info, for AOTModuleInstance,
459
+ it denotes `AOTModuleInstanceExtra *` */
460
+ DefPointer(WASMModuleInstanceExtra *, e);
461
+
462
+ /* Default WASM operand stack size */
463
+ uint32 default_wasm_stack_size;
464
+ uint32 reserved[7];
465
+
466
+ /*
467
+ * +------------------------------+ <-- memories
468
+ * | WASMMemoryInstance[mem_count], mem_count is always 1 for LLVM JIT/AOT
469
+ * +------------------------------+ <-- global_data
470
+ * | global data
471
+ * +------------------------------+ <-- tables
472
+ * | WASMTableInstance[table_count]
473
+ * +------------------------------+ <-- e
474
+ * | WASMModuleInstanceExtra
475
+ * +------------------------------+
476
+ */
477
+ union {
478
+ uint64 _make_it_8_byte_aligned_;
479
+ WASMMemoryInstance memory_instances[1];
480
+ uint8 bytes[1];
481
+ } global_table_data;
482
+ };
483
+
484
+ struct WASMInterpFrame;
485
+ typedef struct WASMInterpFrame WASMRuntimeFrame;
486
+
487
+ #if WASM_ENABLE_MULTI_MODULE != 0
488
+ typedef struct WASMSubModInstNode {
489
+ bh_list_link l;
490
+ /* point to a string pool */
491
+ const char *module_name;
492
+ WASMModuleInstance *module_inst;
493
+ } WASMSubModInstNode;
494
+ #endif
495
+
496
+ /**
497
+ * Return the code block of a function.
498
+ *
499
+ * @param func the WASM function instance
500
+ *
501
+ * @return the code block of the function
502
+ */
503
+ static inline uint8 *
504
+ wasm_get_func_code(WASMFunctionInstance *func)
505
+ {
506
+ #if WASM_ENABLE_FAST_INTERP == 0
507
+ return func->is_import_func ? NULL : func->u.func->code;
508
+ #else
509
+ return func->is_import_func ? NULL : func->u.func->code_compiled;
510
+ #endif
511
+ }
512
+
513
+ /**
514
+ * Return the code block end of a function.
515
+ *
516
+ * @param func the WASM function instance
517
+ *
518
+ * @return the code block end of the function
519
+ */
520
+ static inline uint8 *
521
+ wasm_get_func_code_end(WASMFunctionInstance *func)
522
+ {
523
+ #if WASM_ENABLE_FAST_INTERP == 0
524
+ return func->is_import_func ? NULL
525
+ : func->u.func->code + func->u.func->code_size;
526
+ #else
527
+ return func->is_import_func
528
+ ? NULL
529
+ : func->u.func->code_compiled + func->u.func->code_compiled_size;
530
+ #endif
531
+ }
532
+
533
+ WASMModule *
534
+ wasm_load(uint8 *buf, uint32 size,
535
+ #if WASM_ENABLE_MULTI_MODULE != 0
536
+ bool main_module,
537
+ #endif
538
+ const LoadArgs *args, char *error_buf, uint32 error_buf_size);
539
+
540
+ WASMModule *
541
+ wasm_load_from_sections(WASMSection *section_list, char *error_buf,
542
+ uint32 error_buf_size);
543
+
544
+ void
545
+ wasm_unload(WASMModule *module);
546
+
547
+ bool
548
+ wasm_resolve_symbols(WASMModule *module);
549
+
550
+ bool
551
+ wasm_resolve_import_func(const WASMModule *module,
552
+ WASMFunctionImport *function);
553
+
554
+ WASMModuleInstance *
555
+ wasm_instantiate(WASMModule *module, WASMModuleInstance *parent,
556
+ WASMExecEnv *exec_env_main, uint32 stack_size,
557
+ uint32 heap_size, uint32 max_memory_pages, char *error_buf,
558
+ uint32 error_buf_size);
559
+
560
+ void
561
+ wasm_dump_perf_profiling(const WASMModuleInstance *module_inst);
562
+
563
+ double
564
+ wasm_summarize_wasm_execute_time(const WASMModuleInstance *inst);
565
+
566
+ double
567
+ wasm_get_wasm_func_exec_time(const WASMModuleInstance *inst,
568
+ const char *func_name);
569
+
570
+ void
571
+ wasm_deinstantiate(WASMModuleInstance *module_inst, bool is_sub_inst);
572
+
573
+ bool
574
+ wasm_set_running_mode(WASMModuleInstance *module_inst,
575
+ RunningMode running_mode);
576
+
577
+ WASMFunctionInstance *
578
+ wasm_lookup_function(const WASMModuleInstance *module_inst, const char *name);
579
+
580
+ WASMMemoryInstance *
581
+ wasm_lookup_memory(const WASMModuleInstance *module_inst, const char *name);
582
+
583
+ #if WASM_ENABLE_MULTI_MODULE != 0
584
+ WASMGlobalInstance *
585
+ wasm_lookup_global(const WASMModuleInstance *module_inst, const char *name);
586
+
587
+ WASMTableInstance *
588
+ wasm_lookup_table(const WASMModuleInstance *module_inst, const char *name);
589
+
590
+ #if WASM_ENABLE_TAGS != 0
591
+ WASMTagInstance *
592
+ wasm_lookup_tag(const WASMModuleInstance *module_inst, const char *name,
593
+ const char *signature);
594
+ #endif
595
+
596
+ #endif
597
+
598
+ bool
599
+ wasm_call_function(WASMExecEnv *exec_env, WASMFunctionInstance *function,
600
+ unsigned argc, uint32 argv[]);
601
+
602
+ void
603
+ wasm_set_exception(WASMModuleInstance *module, const char *exception);
604
+
605
+ void
606
+ wasm_set_exception_with_id(WASMModuleInstance *module_inst, uint32 id);
607
+
608
+ const char *
609
+ wasm_get_exception(WASMModuleInstance *module);
610
+
611
+ /**
612
+ * @brief Copy exception in buffer passed as parameter. Thread-safe version of
613
+ * `wasm_get_exception()`
614
+ * @note Buffer size must be no smaller than EXCEPTION_BUF_LEN
615
+ * @return true if exception found
616
+ */
617
+ bool
618
+ wasm_copy_exception(WASMModuleInstance *module_inst, char *exception_buf);
619
+
620
+ uint64
621
+ wasm_module_malloc_internal(WASMModuleInstance *module_inst,
622
+ WASMExecEnv *exec_env, uint64 size,
623
+ void **p_native_addr);
624
+
625
+ uint64
626
+ wasm_module_realloc_internal(WASMModuleInstance *module_inst,
627
+ WASMExecEnv *exec_env, uint64 ptr, uint64 size,
628
+ void **p_native_addr);
629
+
630
+ void
631
+ wasm_module_free_internal(WASMModuleInstance *module_inst,
632
+ WASMExecEnv *exec_env, uint64 ptr);
633
+
634
+ uint64
635
+ wasm_module_malloc(WASMModuleInstance *module_inst, uint64 size,
636
+ void **p_native_addr);
637
+
638
+ uint64
639
+ wasm_module_realloc(WASMModuleInstance *module_inst, uint64 ptr, uint64 size,
640
+ void **p_native_addr);
641
+
642
+ void
643
+ wasm_module_free(WASMModuleInstance *module_inst, uint64 ptr);
644
+
645
+ uint64
646
+ wasm_module_dup_data(WASMModuleInstance *module_inst, const char *src,
647
+ uint64 size);
648
+
649
+ /**
650
+ * Check whether the app address and the buf is inside the linear memory,
651
+ * and convert the app address into native address
652
+ */
653
+ bool
654
+ wasm_check_app_addr_and_convert(WASMModuleInstance *module_inst, bool is_str,
655
+ uint64 app_buf_addr, uint64 app_buf_size,
656
+ void **p_native_addr);
657
+
658
+ WASMMemoryInstance *
659
+ wasm_get_default_memory(WASMModuleInstance *module_inst);
660
+
661
+ WASMMemoryInstance *
662
+ wasm_get_memory_with_idx(WASMModuleInstance *module_inst, uint32 index);
663
+
664
+ bool
665
+ wasm_enlarge_memory(WASMModuleInstance *module_inst, uint32 inc_page_count);
666
+
667
+ bool
668
+ wasm_enlarge_memory_with_idx(WASMModuleInstance *module_inst,
669
+ uint32 inc_page_count, uint32 memidx);
670
+
671
+ bool
672
+ wasm_call_indirect(WASMExecEnv *exec_env, uint32 tbl_idx, uint32 elem_idx,
673
+ uint32 argc, uint32 argv[]);
674
+
675
+ #if WASM_ENABLE_THREAD_MGR != 0
676
+ bool
677
+ wasm_set_aux_stack(WASMExecEnv *exec_env, uint64 start_offset, uint32 size);
678
+
679
+ bool
680
+ wasm_get_aux_stack(WASMExecEnv *exec_env, uint64 *start_offset, uint32 *size);
681
+ #endif
682
+
683
+ void
684
+ wasm_get_module_mem_consumption(const WASMModule *module,
685
+ WASMModuleMemConsumption *mem_conspn);
686
+
687
+ void
688
+ wasm_get_module_inst_mem_consumption(const WASMModuleInstance *module,
689
+ WASMModuleInstMemConsumption *mem_conspn);
690
+
691
+ #if WASM_ENABLE_REF_TYPES != 0 || WASM_ENABLE_GC != 0
692
+ static inline bool
693
+ wasm_elem_is_active(uint32 mode)
694
+ {
695
+ return (mode & 0x1) == 0x0;
696
+ }
697
+
698
+ static inline bool
699
+ wasm_elem_is_passive(uint32 mode)
700
+ {
701
+ return (mode & 0x1) == 0x1;
702
+ }
703
+
704
+ static inline bool
705
+ wasm_elem_is_declarative(uint32 mode)
706
+ {
707
+ return (mode & 0x3) == 0x3;
708
+ }
709
+
710
+ bool
711
+ wasm_enlarge_table(WASMModuleInstance *module_inst, uint32 table_idx,
712
+ uint32 inc_entries, table_elem_type_t init_val);
713
+ #endif /* WASM_ENABLE_REF_TYPES != 0 || WASM_ENABLE_GC != 0 */
714
+
715
+ #if WASM_ENABLE_GC != 0
716
+ void *
717
+ wasm_create_func_obj(WASMModuleInstance *module_inst, uint32 func_idx,
718
+ bool throw_exce, char *error_buf, uint32 error_buf_size);
719
+
720
+ bool
721
+ wasm_traverse_gc_rootset(WASMExecEnv *exec_env, void *heap);
722
+
723
+ #endif
724
+
725
+ static inline WASMTableInstance *
726
+ wasm_get_table_inst(const WASMModuleInstance *module_inst, uint32 tbl_idx)
727
+ {
728
+ /* careful, it might be a table in another module */
729
+ WASMTableInstance *tbl_inst = module_inst->tables[tbl_idx];
730
+ #if WASM_ENABLE_MULTI_MODULE != 0
731
+ if (tbl_idx < module_inst->module->import_table_count
732
+ && module_inst->e->table_insts_linked[tbl_idx]) {
733
+ tbl_inst = module_inst->e->table_insts_linked[tbl_idx];
734
+ }
735
+ #endif
736
+ bh_assert(tbl_inst);
737
+ return tbl_inst;
738
+ }
739
+
740
+ #if WASM_ENABLE_DUMP_CALL_STACK != 0
741
+
742
+ #if WASM_ENABLE_COPY_CALL_STACK != 0
743
+ uint32
744
+ wasm_interp_copy_callstack(WASMExecEnv *exec_env, WASMCApiFrame *buffer,
745
+ uint32 length, uint32 skip_n, char *error_buf,
746
+ uint32_t error_buf_size);
747
+ #endif // WASM_ENABLE_COPY_CALL_STACK
748
+
749
+ bool
750
+ wasm_interp_create_call_stack(struct WASMExecEnv *exec_env);
751
+
752
+ /**
753
+ * @brief Dump wasm call stack or get the size
754
+ *
755
+ * @param exec_env the execution environment
756
+ * @param print whether to print to stdout or not
757
+ * @param buf buffer to store the dumped content
758
+ * @param len length of the buffer
759
+ *
760
+ * @return when print is true, return the bytes printed out to stdout; when
761
+ * print is false and buf is NULL, return the size required to store the
762
+ * callstack content; when print is false and buf is not NULL, return the size
763
+ * dumped to the buffer, 0 means error and data in buf may be invalid
764
+ */
765
+ uint32
766
+ wasm_interp_dump_call_stack(struct WASMExecEnv *exec_env, bool print, char *buf,
767
+ uint32 len);
768
+ #endif
769
+
770
+ const uint8 *
771
+ wasm_loader_get_custom_section(WASMModule *module, const char *name,
772
+ uint32 *len);
773
+
774
+ #if WASM_ENABLE_FAST_JIT != 0 || WASM_ENABLE_JIT != 0 \
775
+ || WASM_ENABLE_WAMR_COMPILER != 0
776
+ void
777
+ jit_set_exception_with_id(WASMModuleInstance *module_inst, uint32 id);
778
+
779
+ /**
780
+ * Check whether the app address and the buf is inside the linear memory,
781
+ * and convert the app address into native address
782
+ */
783
+ bool
784
+ jit_check_app_addr_and_convert(WASMModuleInstance *module_inst, bool is_str,
785
+ uint64 app_buf_addr, uint64 app_buf_size,
786
+ void **p_native_addr);
787
+ #endif /* end of WASM_ENABLE_FAST_JIT != 0 || WASM_ENABLE_JIT != 0 \
788
+ || WASM_ENABLE_WAMR_COMPILER != 0 */
789
+
790
+ #if WASM_ENABLE_FAST_JIT != 0
791
+ bool
792
+ fast_jit_call_indirect(WASMExecEnv *exec_env, uint32 tbl_idx, uint32 elem_idx,
793
+ uint32 type_idx, uint32 argc, uint32 *argv);
794
+
795
+ bool
796
+ fast_jit_invoke_native(WASMExecEnv *exec_env, uint32 func_idx,
797
+ struct WASMInterpFrame *prev_frame);
798
+ #endif
799
+
800
+ #if WASM_ENABLE_JIT != 0 || WASM_ENABLE_WAMR_COMPILER != 0
801
+ bool
802
+ llvm_jit_call_indirect(WASMExecEnv *exec_env, uint32 tbl_idx, uint32 elem_idx,
803
+ uint32 argc, uint32 *argv);
804
+
805
+ bool
806
+ llvm_jit_invoke_native(WASMExecEnv *exec_env, uint32 func_idx, uint32 argc,
807
+ uint32 *argv);
808
+
809
+ #if WASM_ENABLE_BULK_MEMORY != 0
810
+ bool
811
+ llvm_jit_memory_init(WASMModuleInstance *module_inst, uint32 seg_index,
812
+ uint32 offset, uint32 len, size_t dst);
813
+
814
+ bool
815
+ llvm_jit_data_drop(WASMModuleInstance *module_inst, uint32 seg_index);
816
+ #endif
817
+
818
+ #if WASM_ENABLE_REF_TYPES != 0
819
+ void
820
+ llvm_jit_drop_table_seg(WASMModuleInstance *module_inst, uint32 tbl_seg_idx);
821
+
822
+ void
823
+ llvm_jit_table_init(WASMModuleInstance *module_inst, uint32 tbl_idx,
824
+ uint32 tbl_seg_idx, uint32 length, uint32 src_offset,
825
+ uint32 dst_offset);
826
+
827
+ void
828
+ llvm_jit_table_copy(WASMModuleInstance *module_inst, uint32 src_tbl_idx,
829
+ uint32 dst_tbl_idx, uint32 length, uint32 src_offset,
830
+ uint32 dst_offset);
831
+
832
+ void
833
+ llvm_jit_table_fill(WASMModuleInstance *module_inst, uint32 tbl_idx,
834
+ uint32 length, uintptr_t val, uint32 data_offset);
835
+
836
+ uint32
837
+ llvm_jit_table_grow(WASMModuleInstance *module_inst, uint32 tbl_idx,
838
+ uint32 inc_entries, uintptr_t init_val);
839
+ #endif
840
+
841
+ #if WASM_ENABLE_DUMP_CALL_STACK != 0 || WASM_ENABLE_PERF_PROFILING != 0 \
842
+ || WASM_ENABLE_AOT_STACK_FRAME != 0
843
+ bool
844
+ llvm_jit_alloc_frame(WASMExecEnv *exec_env, uint32 func_index);
845
+
846
+ void
847
+ llvm_jit_free_frame(WASMExecEnv *exec_env);
848
+
849
+ void
850
+ llvm_jit_frame_update_profile_info(WASMExecEnv *exec_env, bool alloc_frame);
851
+ #endif
852
+
853
+ #if WASM_ENABLE_GC != 0
854
+ void *
855
+ llvm_jit_create_func_obj(WASMModuleInstance *module_inst, uint32 func_idx,
856
+ bool throw_exce, char *error_buf,
857
+ uint32 error_buf_size);
858
+
859
+ bool
860
+ llvm_jit_obj_is_instance_of(WASMModuleInstance *module_inst,
861
+ WASMObjectRef gc_obj, uint32 type_index);
862
+
863
+ /* Whether func type1 is one of super types of func type2 */
864
+ bool
865
+ llvm_jit_func_type_is_super_of(WASMModuleInstance *module_inst,
866
+ uint32 type_idx1, uint32 type_idx2);
867
+
868
+ WASMRttTypeRef
869
+ llvm_jit_rtt_type_new(WASMModuleInstance *module_inst, uint32 type_index);
870
+
871
+ bool
872
+ llvm_array_init_with_data(WASMModuleInstance *module_inst, uint32 seg_index,
873
+ uint32 data_seg_offset, WASMArrayObjectRef array_obj,
874
+ uint32 elem_size, uint32 array_len);
875
+ #endif
876
+ #endif /* end of WASM_ENABLE_JIT != 0 || WASM_ENABLE_WAMR_COMPILER != 0 */
877
+
878
+ #if WASM_ENABLE_LIBC_WASI != 0 && WASM_ENABLE_MULTI_MODULE != 0
879
+ void
880
+ wasm_propagate_wasi_args(WASMModule *module);
881
+ #endif
882
+
883
+ #if WASM_ENABLE_THREAD_MGR != 0
884
+ void
885
+ exception_lock(WASMModuleInstance *module_inst);
886
+ void
887
+ exception_unlock(WASMModuleInstance *module_inst);
888
+ #else
889
+ #define exception_lock(module_inst) (void)(module_inst)
890
+ #define exception_unlock(module_inst) (void)(module_inst)
891
+ #endif
892
+
893
+ bool
894
+ wasm_check_utf8_str(const uint8 *str, uint32 len);
895
+
896
+ char *
897
+ wasm_const_str_list_insert(const uint8 *str, uint32 len, WASMModule *module,
898
+ bool is_load_from_file_buf, char *error_buf,
899
+ uint32 error_buf_size);
900
+
901
+ bool
902
+ wasm_set_module_name(WASMModule *module, const char *name, char *error_buf,
903
+ uint32_t error_buf_size);
904
+
905
+ const char *
906
+ wasm_get_module_name(WASMModule *module);
907
+
908
+ #ifdef __cplusplus
909
+ }
910
+ #endif
911
+
912
+ #endif /* end of _WASM_RUNTIME_H */