wasm_runtime.h 20 KB

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