wasm_runtime.h 20 KB

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