wasm_runtime.h 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638
  1. /*
  2. * Copyright (C) 2019 Intel Corporation. All rights reserved.
  3. * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. */
  5. #ifndef _WASM_RUNTIME_H
  6. #define _WASM_RUNTIME_H
  7. #include "wasm.h"
  8. #include "bh_hashmap.h"
  9. #include "../common/wasm_runtime_common.h"
  10. #include "../common/wasm_exec_env.h"
  11. #ifdef __cplusplus
  12. extern "C" {
  13. #endif
  14. typedef struct WASMModuleInstance WASMModuleInstance;
  15. typedef struct WASMFunctionInstance WASMFunctionInstance;
  16. typedef struct WASMMemoryInstance WASMMemoryInstance;
  17. typedef struct WASMTableInstance WASMTableInstance;
  18. typedef struct WASMGlobalInstance WASMGlobalInstance;
  19. /**
  20. * When LLVM JIT, WAMR compiler or AOT is enabled, we should ensure that
  21. * some offsets of the same field in the interpreter module instance and
  22. * aot module instance are the same, so that the LLVM JITed/AOTed code
  23. * can smoothly access the interpreter module instance.
  24. * Same for the memory instance and table instance.
  25. * We use the macro DefPointer to define some related pointer fields.
  26. */
  27. #if (WASM_ENABLE_JIT != 0 || WASM_ENABLE_WAMR_COMPILER != 0 \
  28. || WASM_ENABLE_AOT != 0) \
  29. && UINTPTR_MAX == UINT32_MAX
  30. /* Add u32 padding if LLVM JIT, WAMR compiler or AOT is enabled on
  31. 32-bit platform */
  32. #define DefPointer(type, field) \
  33. type field; \
  34. uint32 field##_padding
  35. #else
  36. #define DefPointer(type, field) type field
  37. #endif
  38. typedef enum WASMExceptionID {
  39. EXCE_UNREACHABLE = 0,
  40. EXCE_OUT_OF_MEMORY,
  41. EXCE_OUT_OF_BOUNDS_MEMORY_ACCESS,
  42. EXCE_INTEGER_OVERFLOW,
  43. EXCE_INTEGER_DIVIDE_BY_ZERO,
  44. EXCE_INVALID_CONVERSION_TO_INTEGER,
  45. EXCE_INVALID_FUNCTION_TYPE_INDEX,
  46. EXCE_INVALID_FUNCTION_INDEX,
  47. EXCE_UNDEFINED_ELEMENT,
  48. EXCE_UNINITIALIZED_ELEMENT,
  49. EXCE_CALL_UNLINKED_IMPORT_FUNC,
  50. EXCE_NATIVE_STACK_OVERFLOW,
  51. EXCE_UNALIGNED_ATOMIC,
  52. EXCE_AUX_STACK_OVERFLOW,
  53. EXCE_AUX_STACK_UNDERFLOW,
  54. EXCE_OUT_OF_BOUNDS_TABLE_ACCESS,
  55. EXCE_OPERAND_STACK_OVERFLOW,
  56. #if WASM_ENABLE_FAST_JIT != 0
  57. EXCE_FAILED_TO_COMPILE_FAST_JIT_FUNC,
  58. #endif
  59. EXCE_ALREADY_THROWN,
  60. EXCE_NUM,
  61. } WASMExceptionID;
  62. typedef union {
  63. uint64 u64;
  64. uint32 u32[2];
  65. } MemBound;
  66. struct WASMMemoryInstance {
  67. /* Module type */
  68. uint32 module_type;
  69. /* Shared memory flag */
  70. bool is_shared;
  71. /* Number bytes per page */
  72. uint32 num_bytes_per_page;
  73. /* Current page count */
  74. uint32 cur_page_count;
  75. /* Maximum page count */
  76. uint32 max_page_count;
  77. /* Memory data size */
  78. uint32 memory_data_size;
  79. /**
  80. * Memory data begin address, Note:
  81. * the app-heap might be inserted in to the linear memory,
  82. * when memory is re-allocated, the heap data and memory data
  83. * must be copied to new memory also
  84. */
  85. DefPointer(uint8 *, memory_data);
  86. /* Memory data end address */
  87. DefPointer(uint8 *, memory_data_end);
  88. /* Heap data base address */
  89. DefPointer(uint8 *, heap_data);
  90. /* Heap data end address */
  91. DefPointer(uint8 *, heap_data_end);
  92. /* The heap created */
  93. DefPointer(void *, heap_handle);
  94. #if WASM_ENABLE_FAST_JIT != 0 || WASM_ENABLE_JIT != 0 \
  95. || WASM_ENABLE_WAMR_COMPILER != 0 || WASM_ENABLE_AOT != 0
  96. MemBound mem_bound_check_1byte;
  97. MemBound mem_bound_check_2bytes;
  98. MemBound mem_bound_check_4bytes;
  99. MemBound mem_bound_check_8bytes;
  100. MemBound mem_bound_check_16bytes;
  101. #endif
  102. };
  103. struct WASMTableInstance {
  104. /* Current size */
  105. uint32 cur_size;
  106. /* Maximum size */
  107. uint32 max_size;
  108. /* Table elements */
  109. uint32 elems[1];
  110. };
  111. struct WASMGlobalInstance {
  112. /* value type, VALUE_TYPE_I32/I64/F32/F64 */
  113. uint8 type;
  114. /* mutable or constant */
  115. bool is_mutable;
  116. /* data offset to base_addr of WASMMemoryInstance */
  117. uint32 data_offset;
  118. /* initial value */
  119. WASMValue initial_value;
  120. #if WASM_ENABLE_MULTI_MODULE != 0
  121. /* just for import, keep the reference here */
  122. WASMModuleInstance *import_module_inst;
  123. WASMGlobalInstance *import_global_inst;
  124. #endif
  125. };
  126. struct WASMFunctionInstance {
  127. /* whether it is import function or WASM function */
  128. bool is_import_func;
  129. /* parameter count */
  130. uint16 param_count;
  131. /* local variable count, 0 for import function */
  132. uint16 local_count;
  133. /* cell num of parameters */
  134. uint16 param_cell_num;
  135. /* cell num of return type */
  136. uint16 ret_cell_num;
  137. /* cell num of local variables, 0 for import function */
  138. uint16 local_cell_num;
  139. #if WASM_ENABLE_FAST_INTERP != 0
  140. /* cell num of consts */
  141. uint16 const_cell_num;
  142. #endif
  143. uint16 *local_offsets;
  144. /* parameter types */
  145. uint8 *param_types;
  146. /* local types, NULL for import function */
  147. uint8 *local_types;
  148. union {
  149. WASMFunctionImport *func_import;
  150. WASMFunction *func;
  151. } u;
  152. #if WASM_ENABLE_MULTI_MODULE != 0
  153. WASMModuleInstance *import_module_inst;
  154. WASMFunctionInstance *import_func_inst;
  155. #endif
  156. #if WASM_ENABLE_PERF_PROFILING != 0
  157. /* total execution time */
  158. uint64 total_exec_time;
  159. /* total execution count */
  160. uint32 total_exec_cnt;
  161. #endif
  162. };
  163. typedef struct WASMExportFuncInstance {
  164. char *name;
  165. WASMFunctionInstance *function;
  166. } WASMExportFuncInstance;
  167. typedef struct WASMExportGlobInstance {
  168. char *name;
  169. WASMGlobalInstance *global;
  170. } WASMExportGlobInstance;
  171. typedef struct WASMExportTabInstance {
  172. char *name;
  173. WASMTableInstance *table;
  174. } WASMExportTabInstance;
  175. typedef struct WASMExportMemInstance {
  176. char *name;
  177. WASMMemoryInstance *memory;
  178. } WASMExportMemInstance;
  179. /* wasm-c-api import function info */
  180. typedef struct CApiFuncImport {
  181. /* host func pointer after linked */
  182. void *func_ptr_linked;
  183. /* whether the host func has env argument */
  184. bool with_env_arg;
  185. /* the env argument of the host func */
  186. void *env_arg;
  187. } CApiFuncImport;
  188. /* Extra info of WASM module instance for interpreter/jit mode */
  189. typedef struct WASMModuleInstanceExtra {
  190. WASMGlobalInstance *globals;
  191. WASMFunctionInstance *functions;
  192. uint32 global_count;
  193. uint32 function_count;
  194. WASMFunctionInstance *start_function;
  195. WASMFunctionInstance *malloc_function;
  196. WASMFunctionInstance *free_function;
  197. WASMFunctionInstance *retain_function;
  198. CApiFuncImport *c_api_func_imports;
  199. #if WASM_ENABLE_SHARED_MEMORY != 0
  200. /* lock for shared memory atomic operations */
  201. korp_mutex mem_lock;
  202. bool mem_lock_inited;
  203. #endif
  204. #if WASM_ENABLE_MULTI_MODULE != 0
  205. bh_list sub_module_inst_list_head;
  206. bh_list *sub_module_inst_list;
  207. /* linked table instances of import table instances */
  208. WASMTableInstance **table_insts_linked;
  209. #endif
  210. #if WASM_ENABLE_MEMORY_PROFILING != 0
  211. uint32 max_aux_stack_used;
  212. #endif
  213. #if WASM_ENABLE_DEBUG_INTERP != 0 \
  214. || (WASM_ENABLE_FAST_JIT != 0 && WASM_ENABLE_JIT \
  215. && WASM_ENABLE_LAZY_JIT != 0)
  216. WASMModuleInstance *next;
  217. #endif
  218. } WASMModuleInstanceExtra;
  219. struct AOTFuncPerfProfInfo;
  220. struct WASMModuleInstance {
  221. /* Module instance type, for module instance loaded from
  222. WASM bytecode binary, this field is Wasm_Module_Bytecode;
  223. for module instance loaded from AOT file, this field is
  224. Wasm_Module_AoT, and this structure should be treated as
  225. AOTModuleInstance structure. */
  226. uint32 module_type;
  227. uint32 memory_count;
  228. DefPointer(WASMMemoryInstance **, memories);
  229. /* global and table info */
  230. uint32 global_data_size;
  231. uint32 table_count;
  232. DefPointer(uint8 *, global_data);
  233. /* For AOTModuleInstance, it denotes `AOTTableInstance *` */
  234. DefPointer(WASMTableInstance **, tables);
  235. /* import func ptrs + llvm jit func ptrs */
  236. DefPointer(void **, func_ptrs);
  237. /* function type indexes */
  238. DefPointer(uint32 *, func_type_indexes);
  239. uint32 export_func_count;
  240. uint32 export_global_count;
  241. uint32 export_memory_count;
  242. uint32 export_table_count;
  243. /* For AOTModuleInstance, it denotes `AOTFunctionInstance *` */
  244. DefPointer(WASMExportFuncInstance *, export_functions);
  245. DefPointer(WASMExportGlobInstance *, export_globals);
  246. DefPointer(WASMExportMemInstance *, export_memories);
  247. DefPointer(WASMExportTabInstance *, export_tables);
  248. /* The exception buffer of wasm interpreter for current thread. */
  249. char cur_exception[128];
  250. /* The WASM module or AOT module, for AOTModuleInstance,
  251. it denotes `AOTModule *` */
  252. DefPointer(WASMModule *, module);
  253. #if WASM_ENABLE_LIBC_WASI
  254. /* WASI context */
  255. DefPointer(WASIContext *, wasi_ctx);
  256. #else
  257. DefPointer(void *, wasi_ctx);
  258. #endif
  259. DefPointer(WASMExecEnv *, exec_env_singleton);
  260. /* Array of function pointers to import functions,
  261. not available in AOTModuleInstance */
  262. DefPointer(void **, import_func_ptrs);
  263. /* Array of function pointers to fast jit functions,
  264. not available in AOTModuleInstance */
  265. DefPointer(void **, fast_jit_func_ptrs);
  266. /* The custom data that can be set/get by wasm_{get|set}_custom_data */
  267. DefPointer(void *, custom_data);
  268. /* Stack frames, used in call stack dump and perf profiling */
  269. DefPointer(Vector *, frames);
  270. /* Function performance profiling info list, only available
  271. in AOTModuleInstance */
  272. DefPointer(struct AOTFuncPerfProfInfo *, func_perf_profilings);
  273. /* WASM/AOT module extra info, for AOTModuleInstance,
  274. it denotes `AOTModuleInstanceExtra *` */
  275. DefPointer(WASMModuleInstanceExtra *, e);
  276. /* Default WASM operand stack size */
  277. uint32 default_wasm_stack_size;
  278. uint32 reserved[3];
  279. /*
  280. * +------------------------------+ <-- memories
  281. * | WASMMemoryInstance[mem_count], mem_count is always 1 for LLVM JIT/AOT
  282. * +------------------------------+ <-- global_data
  283. * | global data
  284. * +------------------------------+ <-- tables
  285. * | WASMTableInstance[table_count]
  286. * +------------------------------+ <-- e
  287. * | WASMModuleInstanceExtra
  288. * +------------------------------+
  289. */
  290. union {
  291. uint64 _make_it_8_byte_aligned_;
  292. WASMMemoryInstance memory_instances[1];
  293. uint8 bytes[1];
  294. } global_table_data;
  295. };
  296. struct WASMInterpFrame;
  297. typedef struct WASMInterpFrame WASMRuntimeFrame;
  298. #if WASM_ENABLE_MULTI_MODULE != 0
  299. typedef struct WASMSubModInstNode {
  300. bh_list_link l;
  301. /* point to a string pool */
  302. const char *module_name;
  303. WASMModuleInstance *module_inst;
  304. } WASMSubModInstNode;
  305. #endif
  306. /**
  307. * Return the code block of a function.
  308. *
  309. * @param func the WASM function instance
  310. *
  311. * @return the code block of the function
  312. */
  313. static inline uint8 *
  314. wasm_get_func_code(WASMFunctionInstance *func)
  315. {
  316. #if WASM_ENABLE_FAST_INTERP == 0
  317. return func->is_import_func ? NULL : func->u.func->code;
  318. #else
  319. return func->is_import_func ? NULL : func->u.func->code_compiled;
  320. #endif
  321. }
  322. /**
  323. * Return the code block end of a function.
  324. *
  325. * @param func the WASM function instance
  326. *
  327. * @return the code block end of the function
  328. */
  329. static inline uint8 *
  330. wasm_get_func_code_end(WASMFunctionInstance *func)
  331. {
  332. #if WASM_ENABLE_FAST_INTERP == 0
  333. return func->is_import_func ? NULL
  334. : func->u.func->code + func->u.func->code_size;
  335. #else
  336. return func->is_import_func
  337. ? NULL
  338. : func->u.func->code_compiled + func->u.func->code_compiled_size;
  339. #endif
  340. }
  341. WASMModule *
  342. wasm_load(uint8 *buf, uint32 size, char *error_buf, uint32 error_buf_size);
  343. WASMModule *
  344. wasm_load_from_sections(WASMSection *section_list, char *error_buf,
  345. uint32 error_buf_size);
  346. void
  347. wasm_unload(WASMModule *module);
  348. WASMModuleInstance *
  349. wasm_instantiate(WASMModule *module, bool is_sub_inst, uint32 stack_size,
  350. uint32 heap_size, char *error_buf, uint32 error_buf_size);
  351. void
  352. wasm_dump_perf_profiling(const WASMModuleInstance *module_inst);
  353. void
  354. wasm_deinstantiate(WASMModuleInstance *module_inst, bool is_sub_inst);
  355. WASMFunctionInstance *
  356. wasm_lookup_function(const WASMModuleInstance *module_inst, const char *name,
  357. const char *signature);
  358. #if WASM_ENABLE_MULTI_MODULE != 0
  359. WASMGlobalInstance *
  360. wasm_lookup_global(const WASMModuleInstance *module_inst, const char *name);
  361. WASMMemoryInstance *
  362. wasm_lookup_memory(const WASMModuleInstance *module_inst, const char *name);
  363. WASMTableInstance *
  364. wasm_lookup_table(const WASMModuleInstance *module_inst, const char *name);
  365. #endif
  366. bool
  367. wasm_call_function(WASMExecEnv *exec_env, WASMFunctionInstance *function,
  368. unsigned argc, uint32 argv[]);
  369. bool
  370. wasm_create_exec_env_and_call_function(WASMModuleInstance *module_inst,
  371. WASMFunctionInstance *function,
  372. unsigned argc, uint32 argv[]);
  373. void
  374. wasm_set_exception(WASMModuleInstance *module, const char *exception);
  375. void
  376. wasm_set_exception_with_id(WASMModuleInstance *module_inst, uint32 id);
  377. const char *
  378. wasm_get_exception(WASMModuleInstance *module);
  379. uint32
  380. wasm_module_malloc(WASMModuleInstance *module_inst, uint32 size,
  381. void **p_native_addr);
  382. uint32
  383. wasm_module_realloc(WASMModuleInstance *module_inst, uint32 ptr, uint32 size,
  384. void **p_native_addr);
  385. void
  386. wasm_module_free(WASMModuleInstance *module_inst, uint32 ptr);
  387. uint32
  388. wasm_module_dup_data(WASMModuleInstance *module_inst, const char *src,
  389. uint32 size);
  390. /**
  391. * Check whether the app address and the buf is inside the linear memory,
  392. * and convert the app address into native address
  393. */
  394. bool
  395. wasm_check_app_addr_and_convert(WASMModuleInstance *module_inst, bool is_str,
  396. uint32 app_buf_addr, uint32 app_buf_size,
  397. void **p_native_addr);
  398. WASMMemoryInstance *
  399. wasm_get_default_memory(WASMModuleInstance *module_inst);
  400. bool
  401. wasm_enlarge_memory(WASMModuleInstance *module_inst, uint32 inc_page_count);
  402. bool
  403. wasm_call_indirect(WASMExecEnv *exec_env, uint32 tbl_idx, uint32 elem_idx,
  404. uint32 argc, uint32 argv[]);
  405. #if WASM_ENABLE_THREAD_MGR != 0
  406. bool
  407. wasm_set_aux_stack(WASMExecEnv *exec_env, uint32 start_offset, uint32 size);
  408. bool
  409. wasm_get_aux_stack(WASMExecEnv *exec_env, uint32 *start_offset, uint32 *size);
  410. #endif
  411. void
  412. wasm_get_module_mem_consumption(const WASMModule *module,
  413. WASMModuleMemConsumption *mem_conspn);
  414. void
  415. wasm_get_module_inst_mem_consumption(const WASMModuleInstance *module,
  416. WASMModuleInstMemConsumption *mem_conspn);
  417. #if WASM_ENABLE_REF_TYPES != 0
  418. static inline bool
  419. wasm_elem_is_active(uint32 mode)
  420. {
  421. return (mode & 0x1) == 0x0;
  422. }
  423. static inline bool
  424. wasm_elem_is_passive(uint32 mode)
  425. {
  426. return (mode & 0x1) == 0x1;
  427. }
  428. static inline bool
  429. wasm_elem_is_declarative(uint32 mode)
  430. {
  431. return (mode & 0x3) == 0x3;
  432. }
  433. bool
  434. wasm_enlarge_table(WASMModuleInstance *module_inst, uint32 table_idx,
  435. uint32 inc_entries, uint32 init_val);
  436. #endif /* WASM_ENABLE_REF_TYPES != 0 */
  437. static inline WASMTableInstance *
  438. wasm_get_table_inst(const WASMModuleInstance *module_inst, uint32 tbl_idx)
  439. {
  440. /* careful, it might be a table in another module */
  441. WASMTableInstance *tbl_inst = module_inst->tables[tbl_idx];
  442. #if WASM_ENABLE_MULTI_MODULE != 0
  443. if (tbl_idx < module_inst->module->import_table_count
  444. && module_inst->e->table_insts_linked[tbl_idx]) {
  445. tbl_inst = module_inst->e->table_insts_linked[tbl_idx];
  446. }
  447. #endif
  448. bh_assert(tbl_inst);
  449. return tbl_inst;
  450. }
  451. #if WASM_ENABLE_DUMP_CALL_STACK != 0
  452. bool
  453. wasm_interp_create_call_stack(struct WASMExecEnv *exec_env);
  454. /**
  455. * @brief Dump wasm call stack or get the size
  456. *
  457. * @param exec_env the execution environment
  458. * @param print whether to print to stdout or not
  459. * @param buf buffer to store the dumped content
  460. * @param len length of the buffer
  461. *
  462. * @return when print is true, return the bytes printed out to stdout; when
  463. * print is false and buf is NULL, return the size required to store the
  464. * callstack content; when print is false and buf is not NULL, return the size
  465. * dumped to the buffer, 0 means error and data in buf may be invalid
  466. */
  467. uint32
  468. wasm_interp_dump_call_stack(struct WASMExecEnv *exec_env, bool print, char *buf,
  469. uint32 len);
  470. #endif
  471. const uint8 *
  472. wasm_loader_get_custom_section(WASMModule *module, const char *name,
  473. uint32 *len);
  474. #if WASM_ENABLE_FAST_JIT != 0 || WASM_ENABLE_JIT != 0 \
  475. || WASM_ENABLE_WAMR_COMPILER != 0
  476. void
  477. jit_set_exception_with_id(WASMModuleInstance *module_inst, uint32 id);
  478. /**
  479. * Check whether the app address and the buf is inside the linear memory,
  480. * and convert the app address into native address
  481. */
  482. bool
  483. jit_check_app_addr_and_convert(WASMModuleInstance *module_inst, bool is_str,
  484. uint32 app_buf_addr, uint32 app_buf_size,
  485. void **p_native_addr);
  486. #endif /* end of WASM_ENABLE_FAST_JIT != 0 || WASM_ENABLE_JIT != 0 \
  487. || WASM_ENABLE_WAMR_COMPILER != 0 */
  488. #if WASM_ENABLE_FAST_JIT != 0
  489. bool
  490. fast_jit_call_indirect(WASMExecEnv *exec_env, uint32 tbl_idx, uint32 elem_idx,
  491. uint32 type_idx, uint32 argc, uint32 *argv);
  492. bool
  493. fast_jit_invoke_native(WASMExecEnv *exec_env, uint32 func_idx,
  494. struct WASMInterpFrame *prev_frame);
  495. #endif
  496. #if WASM_ENABLE_JIT != 0 || WASM_ENABLE_WAMR_COMPILER != 0
  497. bool
  498. llvm_jit_call_indirect(WASMExecEnv *exec_env, uint32 tbl_idx, uint32 elem_idx,
  499. uint32 argc, uint32 *argv);
  500. bool
  501. llvm_jit_invoke_native(WASMExecEnv *exec_env, uint32 func_idx, uint32 argc,
  502. uint32 *argv);
  503. #if WASM_ENABLE_BULK_MEMORY != 0
  504. bool
  505. llvm_jit_memory_init(WASMModuleInstance *module_inst, uint32 seg_index,
  506. uint32 offset, uint32 len, uint32 dst);
  507. bool
  508. llvm_jit_data_drop(WASMModuleInstance *module_inst, uint32 seg_index);
  509. #endif
  510. #if WASM_ENABLE_REF_TYPES != 0
  511. void
  512. llvm_jit_drop_table_seg(WASMModuleInstance *module_inst, uint32 tbl_seg_idx);
  513. void
  514. llvm_jit_table_init(WASMModuleInstance *module_inst, uint32 tbl_idx,
  515. uint32 tbl_seg_idx, uint32 length, uint32 src_offset,
  516. uint32 dst_offset);
  517. void
  518. llvm_jit_table_copy(WASMModuleInstance *module_inst, uint32 src_tbl_idx,
  519. uint32 dst_tbl_idx, uint32 length, uint32 src_offset,
  520. uint32 dst_offset);
  521. void
  522. llvm_jit_table_fill(WASMModuleInstance *module_inst, uint32 tbl_idx,
  523. uint32 length, uint32 val, uint32 data_offset);
  524. uint32
  525. llvm_jit_table_grow(WASMModuleInstance *module_inst, uint32 tbl_idx,
  526. uint32 inc_entries, uint32 init_val);
  527. #endif
  528. #if WASM_ENABLE_DUMP_CALL_STACK != 0 || WASM_ENABLE_PERF_PROFILING != 0
  529. bool
  530. llvm_jit_alloc_frame(WASMExecEnv *exec_env, uint32 func_index);
  531. void
  532. llvm_jit_free_frame(WASMExecEnv *exec_env);
  533. #endif
  534. #endif /* end of WASM_ENABLE_JIT != 0 || WASM_ENABLE_WAMR_COMPILER != 0 */
  535. #if WASM_ENABLE_LIBC_WASI != 0 && WASM_ENABLE_MULTI_MODULE != 0
  536. void
  537. wasm_propagate_wasi_args(WASMModule *module);
  538. #endif
  539. #ifdef __cplusplus
  540. }
  541. #endif
  542. #endif /* end of _WASM_RUNTIME_H */