aot_runtime.h 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734
  1. /*
  2. * Copyright (C) 2019 Intel Corporation. All rights reserved.
  3. * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. */
  5. #ifndef _AOT_RUNTIME_H_
  6. #define _AOT_RUNTIME_H_
  7. #include "bh_platform.h"
  8. #include "../common/wasm_runtime_common.h"
  9. #include "../interpreter/wasm_runtime.h"
  10. #include "../compilation/aot.h"
  11. #if WASM_ENABLE_JIT != 0
  12. #include "../compilation/aot_llvm.h"
  13. #endif
  14. #ifdef __cplusplus
  15. extern "C" {
  16. #endif
  17. typedef enum AOTExceptionID {
  18. EXCE_UNREACHABLE = 0,
  19. EXCE_OUT_OF_MEMORY,
  20. EXCE_OUT_OF_BOUNDS_MEMORY_ACCESS,
  21. EXCE_INTEGER_OVERFLOW,
  22. EXCE_INTEGER_DIVIDE_BY_ZERO,
  23. EXCE_INVALID_CONVERSION_TO_INTEGER,
  24. EXCE_INVALID_FUNCTION_TYPE_INDEX,
  25. EXCE_INVALID_FUNCTION_INDEX,
  26. EXCE_UNDEFINED_ELEMENT,
  27. EXCE_UNINITIALIZED_ELEMENT,
  28. EXCE_CALL_UNLINKED_IMPORT_FUNC,
  29. EXCE_NATIVE_STACK_OVERFLOW,
  30. EXCE_UNALIGNED_ATOMIC,
  31. EXCE_AUX_STACK_OVERFLOW,
  32. EXCE_AUX_STACK_UNDERFLOW,
  33. EXCE_OUT_OF_BOUNDS_TABLE_ACCESS,
  34. EXCE_NUM,
  35. } AOTExceptionID;
  36. typedef enum AOTSectionType {
  37. AOT_SECTION_TYPE_TARGET_INFO = 0,
  38. AOT_SECTION_TYPE_INIT_DATA = 1,
  39. AOT_SECTION_TYPE_TEXT = 2,
  40. AOT_SECTION_TYPE_FUNCTION = 3,
  41. AOT_SECTION_TYPE_EXPORT = 4,
  42. AOT_SECTION_TYPE_RELOCATION = 5,
  43. AOT_SECTION_TYPE_SIGANATURE = 6,
  44. AOT_SECTION_TYPE_CUSTOM = 100,
  45. } AOTSectionType;
  46. typedef enum AOTCustomSectionType {
  47. AOT_CUSTOM_SECTION_NATIVE_SYMBOL = 1,
  48. AOT_CUSTOM_SECTION_ACCESS_CONTROL = 2,
  49. AOT_CUSTOM_SECTION_NAME = 3,
  50. } AOTCustomSectionType;
  51. typedef struct AOTObjectDataSection {
  52. char *name;
  53. uint8 *data;
  54. uint32 size;
  55. } AOTObjectDataSection;
  56. /* Relocation info */
  57. typedef struct AOTRelocation {
  58. uint64 relocation_offset;
  59. int64 relocation_addend;
  60. uint32 relocation_type;
  61. char *symbol_name;
  62. /* index in the symbol offset field */
  63. uint32 symbol_index;
  64. } AOTRelocation;
  65. /* Relocation Group */
  66. typedef struct AOTRelocationGroup {
  67. char *section_name;
  68. /* index in the symbol offset field */
  69. uint32 name_index;
  70. uint32 relocation_count;
  71. AOTRelocation *relocations;
  72. } AOTRelocationGroup;
  73. /* AOT function instance */
  74. typedef struct AOTFunctionInstance {
  75. char *func_name;
  76. uint32 func_index;
  77. bool is_import_func;
  78. union {
  79. struct {
  80. AOTFuncType *func_type;
  81. /* function pointer linked */
  82. void *func_ptr;
  83. } func;
  84. AOTImportFunc *func_import;
  85. } u;
  86. } AOTFunctionInstance;
  87. #if defined(OS_ENABLE_HW_BOUND_CHECK) && defined(BH_PLATFORM_WINDOWS)
  88. /* clang-format off */
  89. typedef struct AOTUnwindInfo {
  90. uint8 Version : 3;
  91. uint8 Flags : 5;
  92. uint8 SizeOfProlog;
  93. uint8 CountOfCodes;
  94. uint8 FrameRegister : 4;
  95. uint8 FrameOffset : 4;
  96. struct {
  97. struct {
  98. uint8 CodeOffset;
  99. uint8 UnwindOp : 4;
  100. uint8 OpInfo : 4;
  101. };
  102. uint16 FrameOffset;
  103. } UnwindCode[1];
  104. } AOTUnwindInfo;
  105. /* clang-format on */
  106. /* size of mov instruction and jmp instruction */
  107. #define PLT_ITEM_SIZE 12
  108. #endif
  109. typedef struct AOTModule {
  110. uint32 module_type;
  111. /* import memories */
  112. uint32 import_memory_count;
  113. AOTImportMemory *import_memories;
  114. /* memory info */
  115. uint32 memory_count;
  116. AOTMemory *memories;
  117. /* init data */
  118. uint32 mem_init_data_count;
  119. AOTMemInitData **mem_init_data_list;
  120. /* native symbol */
  121. void **native_symbol_list;
  122. /* import tables */
  123. uint32 import_table_count;
  124. AOTImportTable *import_tables;
  125. /* tables */
  126. uint32 table_count;
  127. AOTTable *tables;
  128. /* table init data info */
  129. uint32 table_init_data_count;
  130. AOTTableInitData **table_init_data_list;
  131. /* function type info */
  132. uint32 func_type_count;
  133. AOTFuncType **func_types;
  134. /* import global variable info */
  135. uint32 import_global_count;
  136. AOTImportGlobal *import_globals;
  137. /* global variable info */
  138. uint32 global_count;
  139. AOTGlobal *globals;
  140. /* total global variable size */
  141. uint32 global_data_size;
  142. /* import function info */
  143. uint32 import_func_count;
  144. AOTImportFunc *import_funcs;
  145. /* function info */
  146. uint32 func_count;
  147. /* point to AOTed/JITed functions */
  148. void **func_ptrs;
  149. /* function type indexes */
  150. uint32 *func_type_indexes;
  151. /* export info */
  152. uint32 export_count;
  153. AOTExport *exports;
  154. /* start function index, -1 denotes no start function */
  155. uint32 start_func_index;
  156. /* start function, point to AOTed/JITed function */
  157. void *start_function;
  158. uint32 malloc_func_index;
  159. uint32 free_func_index;
  160. uint32 retain_func_index;
  161. /* AOTed code, NULL for JIT mode */
  162. void *code;
  163. uint32 code_size;
  164. /* literal for AOTed code, NULL for JIT mode */
  165. uint8 *literal;
  166. uint32 literal_size;
  167. #if defined(BH_PLATFORM_WINDOWS)
  168. /* extra plt data area for __xmm and __real constants
  169. in Windows platform, NULL for JIT mode */
  170. uint8 *extra_plt_data;
  171. uint32 extra_plt_data_size;
  172. uint32 xmm_plt_count;
  173. uint32 real_plt_count;
  174. uint32 float_plt_count;
  175. #endif
  176. #if defined(OS_ENABLE_HW_BOUND_CHECK) && defined(BH_PLATFORM_WINDOWS)
  177. /* dynamic function table to be added by RtlAddFunctionTable(),
  178. used to unwind the call stack and register exception handler
  179. for AOT functions */
  180. RUNTIME_FUNCTION *rtl_func_table;
  181. bool rtl_func_table_registered;
  182. #endif
  183. /* data sections in AOT object file, including .data, .rodata
  184. * and .rodata.cstN. NULL for JIT mode. */
  185. AOTObjectDataSection *data_sections;
  186. uint32 data_section_count;
  187. /* constant string set */
  188. HashMap *const_str_set;
  189. /* the index of auxiliary __data_end global,
  190. -1 means unexported */
  191. uint32 aux_data_end_global_index;
  192. /* auxiliary __data_end exported by wasm app */
  193. uint32 aux_data_end;
  194. /* the index of auxiliary __heap_base global,
  195. -1 means unexported */
  196. uint32 aux_heap_base_global_index;
  197. /* auxiliary __heap_base exported by wasm app */
  198. uint32 aux_heap_base;
  199. /* the index of auxiliary stack top global,
  200. -1 means unexported */
  201. uint32 aux_stack_top_global_index;
  202. /* auxiliary stack bottom resolved */
  203. uint32 aux_stack_bottom;
  204. /* auxiliary stack size resolved */
  205. uint32 aux_stack_size;
  206. /* is jit mode or not */
  207. bool is_jit_mode;
  208. /* is indirect mode or not */
  209. bool is_indirect_mode;
  210. #if WASM_ENABLE_JIT != 0
  211. WASMModule *wasm_module;
  212. AOTCompContext *comp_ctx;
  213. AOTCompData *comp_data;
  214. #endif
  215. #if WASM_ENABLE_LIBC_WASI != 0
  216. WASIArguments wasi_args;
  217. bool import_wasi_api;
  218. #endif
  219. #if WASM_ENABLE_DEBUG_AOT != 0
  220. void *elf_hdr;
  221. uint32 elf_size;
  222. #endif
  223. #if WASM_ENABLE_CUSTOM_NAME_SECTION != 0
  224. const char **aux_func_names;
  225. uint32 *aux_func_indexes;
  226. uint32 aux_func_name_count;
  227. #endif
  228. } AOTModule;
  229. typedef union {
  230. uint64 _make_it_8_bytes_;
  231. void *ptr;
  232. } AOTPointer;
  233. typedef union {
  234. uint64 u64;
  235. uint32 u32[2];
  236. } MemBound;
  237. typedef struct AOTMemoryInstance {
  238. uint32 module_type;
  239. /* shared memory flag */
  240. bool is_shared;
  241. /* memory space info */
  242. uint32 num_bytes_per_page;
  243. uint32 cur_page_count;
  244. uint32 max_page_count;
  245. uint32 memory_data_size;
  246. AOTPointer memory_data;
  247. AOTPointer memory_data_end;
  248. /* heap space info */
  249. AOTPointer heap_data;
  250. AOTPointer heap_data_end;
  251. AOTPointer heap_handle;
  252. /* boundary check constants for aot code */
  253. MemBound mem_bound_check_1byte;
  254. MemBound mem_bound_check_2bytes;
  255. MemBound mem_bound_check_4bytes;
  256. MemBound mem_bound_check_8bytes;
  257. MemBound mem_bound_check_16bytes;
  258. } AOTMemoryInstance;
  259. typedef struct AOTTableInstance {
  260. uint32 cur_size;
  261. /*
  262. * only grow in the range of [:max_size)
  263. * if the table is growable, max_size equals to its declared maximum size
  264. * otherwise, max_size equals to its declared minimum size
  265. */
  266. uint32 max_size;
  267. /*
  268. * +------------------------------+ <--- data
  269. * | ref.func[] or ref.extern[]
  270. * +------------------------------+
  271. */
  272. uint32 data[1];
  273. } AOTTableInstance;
  274. typedef struct AOTModuleInstance {
  275. uint32 module_type;
  276. /* memories */
  277. uint32 memory_count;
  278. AOTPointer memories;
  279. /* global and table info */
  280. uint32 global_data_size;
  281. /*
  282. * the count of AOTTableInstance.
  283. * it includes imported tables and local tables.
  284. *
  285. * TODO: for now we treate imported table like a local table
  286. */
  287. uint32 table_count;
  288. /* points to global_data */
  289. AOTPointer global_data;
  290. /* points to AOTTableInstance[] */
  291. AOTPointer tables;
  292. /* function pointer array */
  293. AOTPointer func_ptrs;
  294. /* function type indexes */
  295. AOTPointer func_type_indexes;
  296. /* export info */
  297. uint32 export_func_count;
  298. uint32 export_global_count;
  299. uint32 export_mem_count;
  300. uint32 export_tab_count;
  301. AOTPointer export_funcs;
  302. AOTPointer export_globals;
  303. AOTPointer export_memories;
  304. AOTPointer export_tables;
  305. /* The exception buffer for current thread. */
  306. char cur_exception[128];
  307. /* The custom data that can be set/get by
  308. * wasm_runtime_set_custom_data/wasm_runtime_get_custom_data */
  309. AOTPointer custom_data;
  310. /* The AOT module */
  311. AOTPointer aot_module;
  312. /* WASI context */
  313. AOTPointer wasi_ctx;
  314. /* function performance profiling info list */
  315. AOTPointer func_perf_profilings;
  316. AOTPointer exec_env_singleton;
  317. /* others */
  318. uint32 temp_ret;
  319. uint32 llvm_stack;
  320. uint32 default_wasm_stack_size;
  321. uint32 _padding;
  322. /* store stacktrace information */
  323. AOTPointer frames;
  324. /* reserved */
  325. uint32 reserved[6];
  326. /*
  327. * +------------------------------+ <-- memories.ptr
  328. * | #0 AOTMemoryInstance
  329. * +------------------------------+ <-- global_data.ptr
  330. * | global data
  331. * +------------------------------+ <-- tables.ptr
  332. * | AOTTableInstance[table_count]
  333. * +------------------------------+
  334. */
  335. union {
  336. uint64 _make_it_8_byte_aligned_;
  337. AOTMemoryInstance memory_instances[1];
  338. uint8 bytes[1];
  339. } global_table_data;
  340. } AOTModuleInstance;
  341. /* Target info, read from ELF header of object file */
  342. typedef struct AOTTargetInfo {
  343. /* Binary type, elf32l/elf32b/elf64l/elf64b */
  344. uint16 bin_type;
  345. /* ABI type */
  346. uint16 abi_type;
  347. /* Object file type */
  348. uint16 e_type;
  349. /* Architecture */
  350. uint16 e_machine;
  351. /* Object file version */
  352. uint32 e_version;
  353. /* Processor-specific flags */
  354. uint32 e_flags;
  355. /* Reserved */
  356. uint32 reserved;
  357. /* Arch name */
  358. char arch[16];
  359. } AOTTargetInfo;
  360. typedef struct AOTFuncPerfProfInfo {
  361. /* total execution time */
  362. uint64 total_exec_time;
  363. /* total execution count */
  364. uint32 total_exec_cnt;
  365. } AOTFuncPerfProfInfo;
  366. /* AOT auxiliary call stack */
  367. typedef struct AOTFrame {
  368. struct AOTFrame *prev_frame;
  369. uint32 func_index;
  370. #if WASM_ENABLE_PERF_PROFILING != 0
  371. uint64 time_started;
  372. AOTFuncPerfProfInfo *func_perf_prof_info;
  373. #endif
  374. } AOTFrame;
  375. /**
  376. * Load a AOT module from aot file buffer
  377. * @param buf the byte buffer which contains the AOT file data
  378. * @param size the size of the buffer
  379. * @param error_buf output of the error info
  380. * @param error_buf_size the size of the error string
  381. *
  382. * @return return AOT module loaded, NULL if failed
  383. */
  384. AOTModule *
  385. aot_load_from_aot_file(const uint8 *buf, uint32 size, char *error_buf,
  386. uint32 error_buf_size);
  387. /**
  388. * Load a AOT module from a specified AOT section list.
  389. *
  390. * @param section_list the section list which contains each section data
  391. * @param error_buf output of the error info
  392. * @param error_buf_size the size of the error string
  393. *
  394. * @return return AOT module loaded, NULL if failed
  395. */
  396. AOTModule *
  397. aot_load_from_sections(AOTSection *section_list, char *error_buf,
  398. uint32 error_buf_size);
  399. #if WASM_ENABLE_JIT != 0
  400. /**
  401. * Convert WASM module to AOT module
  402. *
  403. * @param wasm_module the WASM module to convert
  404. * @param error_buf output of the error info
  405. * @param error_buf_size the size of the error string
  406. *
  407. * @return return AOT module loaded, NULL if failed
  408. */
  409. AOTModule *
  410. aot_convert_wasm_module(WASMModule *wasm_module, char *error_buf,
  411. uint32 error_buf_size);
  412. #endif
  413. /**
  414. * Unload a AOT module.
  415. *
  416. * @param module the module to be unloaded
  417. */
  418. void
  419. aot_unload(AOTModule *module);
  420. /**
  421. * Instantiate a AOT module.
  422. *
  423. * @param module the AOT module to instantiate
  424. * @param is_sub_inst the flag of sub instance
  425. * @param heap_size the default heap size of the module instance, a heap will
  426. * be created besides the app memory space. Both wasm app and native
  427. * function can allocate memory from the heap. If heap_size is 0, the
  428. * default heap size will be used.
  429. * @param error_buf buffer to output the error info if failed
  430. * @param error_buf_size the size of the error buffer
  431. *
  432. * @return return the instantiated AOT module instance, NULL if failed
  433. */
  434. AOTModuleInstance *
  435. aot_instantiate(AOTModule *module, bool is_sub_inst, uint32 stack_size,
  436. uint32 heap_size, char *error_buf, uint32 error_buf_size);
  437. /**
  438. * Deinstantiate a AOT module instance, destroy the resources.
  439. *
  440. * @param module_inst the AOT module instance to destroy
  441. * @param is_sub_inst the flag of sub instance
  442. */
  443. void
  444. aot_deinstantiate(AOTModuleInstance *module_inst, bool is_sub_inst);
  445. /**
  446. * Lookup an exported function in the AOT module instance.
  447. *
  448. * @param module_inst the module instance
  449. * @param name the name of the function
  450. * @param signature the signature of the function, use "i32"/"i64"/"f32"/"f64"
  451. * to represent the type of i32/i64/f32/f64, e.g. "(i32i64)" "(i32)f32"
  452. *
  453. * @return the function instance found
  454. */
  455. AOTFunctionInstance *
  456. aot_lookup_function(const AOTModuleInstance *module_inst, const char *name,
  457. const char *signature);
  458. /**
  459. * Call the given AOT function of a AOT module instance with
  460. * arguments.
  461. *
  462. * @param exec_env the execution environment
  463. * @param function the function to be called
  464. * @param argc the number of arguments
  465. * @param argv the arguments. If the function method has return value,
  466. * the first (or first two in case 64-bit return value) element of
  467. * argv stores the return value of the called AOT function after this
  468. * function returns.
  469. *
  470. * @return true if success, false otherwise and exception will be thrown,
  471. * the caller can call aot_get_exception to get exception info.
  472. */
  473. bool
  474. aot_call_function(WASMExecEnv *exec_env, AOTFunctionInstance *function,
  475. unsigned argc, uint32 argv[]);
  476. bool
  477. aot_create_exec_env_and_call_function(AOTModuleInstance *module_inst,
  478. AOTFunctionInstance *function,
  479. unsigned argc, uint32 argv[]);
  480. bool
  481. aot_create_exec_env_singleton(AOTModuleInstance *module_inst);
  482. /**
  483. * Set AOT module instance exception with exception string
  484. *
  485. * @param module the AOT module instance
  486. *
  487. * @param exception current exception string
  488. */
  489. void
  490. aot_set_exception(AOTModuleInstance *module_inst, const char *exception);
  491. void
  492. aot_set_exception_with_id(AOTModuleInstance *module_inst, uint32 id);
  493. /**
  494. * Get exception info of the AOT module instance.
  495. *
  496. * @param module_inst the AOT module instance
  497. *
  498. * @return the exception string
  499. */
  500. const char *
  501. aot_get_exception(AOTModuleInstance *module_inst);
  502. /**
  503. * Clear exception info of the AOT module instance.
  504. *
  505. * @param module_inst the AOT module instance
  506. */
  507. void
  508. aot_clear_exception(AOTModuleInstance *module_inst);
  509. uint32
  510. aot_module_malloc(AOTModuleInstance *module_inst, uint32 size,
  511. void **p_native_addr);
  512. uint32
  513. aot_module_realloc(AOTModuleInstance *module_inst, uint32 ptr, uint32 size,
  514. void **p_native_addr);
  515. void
  516. aot_module_free(AOTModuleInstance *module_inst, uint32 ptr);
  517. uint32
  518. aot_module_dup_data(AOTModuleInstance *module_inst, const char *src,
  519. uint32 size);
  520. bool
  521. aot_validate_app_addr(AOTModuleInstance *module_inst, uint32 app_offset,
  522. uint32 size);
  523. bool
  524. aot_validate_native_addr(AOTModuleInstance *module_inst, void *native_ptr,
  525. uint32 size);
  526. void *
  527. aot_addr_app_to_native(AOTModuleInstance *module_inst, uint32 app_offset);
  528. uint32
  529. aot_addr_native_to_app(AOTModuleInstance *module_inst, void *native_ptr);
  530. bool
  531. aot_get_app_addr_range(AOTModuleInstance *module_inst, uint32 app_offset,
  532. uint32 *p_app_start_offset, uint32 *p_app_end_offset);
  533. bool
  534. aot_get_native_addr_range(AOTModuleInstance *module_inst, uint8 *native_ptr,
  535. uint8 **p_native_start_addr,
  536. uint8 **p_native_end_addr);
  537. bool
  538. aot_enlarge_memory(AOTModuleInstance *module_inst, uint32 inc_page_count);
  539. /**
  540. * Compare whether two wasm types are equal according to the indexs
  541. *
  542. * @param module_inst the AOT module instance
  543. * @param type1_idx index of the first wasm type
  544. * @param type2_idx index of the second wasm type
  545. *
  546. * @return true if equal, false otherwise
  547. */
  548. bool
  549. aot_is_wasm_type_equal(AOTModuleInstance *module_inst, uint32 type1_idx,
  550. uint32 type2_idx);
  551. /**
  552. * Invoke native function from aot code
  553. */
  554. bool
  555. aot_invoke_native(WASMExecEnv *exec_env, uint32 func_idx, uint32 argc,
  556. uint32 *argv);
  557. bool
  558. aot_call_indirect(WASMExecEnv *exec_env, uint32 tbl_idx, uint32 table_elem_idx,
  559. uint32 argc, uint32 *argv);
  560. uint32
  561. aot_get_plt_table_size();
  562. void *
  563. aot_memmove(void *dest, const void *src, size_t n);
  564. void *
  565. aot_memset(void *s, int c, size_t n);
  566. #if WASM_ENABLE_BULK_MEMORY != 0
  567. bool
  568. aot_memory_init(AOTModuleInstance *module_inst, uint32 seg_index, uint32 offset,
  569. uint32 len, uint32 dst);
  570. bool
  571. aot_data_drop(AOTModuleInstance *module_inst, uint32 seg_index);
  572. #endif
  573. #if WASM_ENABLE_THREAD_MGR != 0
  574. bool
  575. aot_set_aux_stack(WASMExecEnv *exec_env, uint32 start_offset, uint32 size);
  576. bool
  577. aot_get_aux_stack(WASMExecEnv *exec_env, uint32 *start_offset, uint32 *size);
  578. #endif
  579. #ifdef OS_ENABLE_HW_BOUND_CHECK
  580. bool
  581. aot_signal_init();
  582. void
  583. aot_signal_destroy();
  584. #endif
  585. void
  586. aot_get_module_mem_consumption(const AOTModule *module,
  587. WASMModuleMemConsumption *mem_conspn);
  588. void
  589. aot_get_module_inst_mem_consumption(const AOTModuleInstance *module_inst,
  590. WASMModuleInstMemConsumption *mem_conspn);
  591. #if WASM_ENABLE_REF_TYPES != 0
  592. void
  593. aot_drop_table_seg(AOTModuleInstance *module_inst, uint32 tbl_seg_idx);
  594. void
  595. aot_table_init(AOTModuleInstance *module_inst, uint32 tbl_idx,
  596. uint32 tbl_seg_idx, uint32 length, uint32 src_offset,
  597. uint32 dst_offset);
  598. void
  599. aot_table_copy(AOTModuleInstance *module_inst, uint32 src_tbl_idx,
  600. uint32 dst_tbl_idx, uint32 length, uint32 src_offset,
  601. uint32 dst_offset);
  602. void
  603. aot_table_fill(AOTModuleInstance *module_inst, uint32 tbl_idx, uint32 length,
  604. uint32 val, uint32 data_offset);
  605. uint32
  606. aot_table_grow(AOTModuleInstance *module_inst, uint32 tbl_idx,
  607. uint32 inc_entries, uint32 init_val);
  608. #endif
  609. AOTTableInstance *
  610. aot_next_tbl_inst(const AOTTableInstance *tbl_inst);
  611. bool
  612. aot_alloc_frame(WASMExecEnv *exec_env, uint32 func_index);
  613. void
  614. aot_free_frame(WASMExecEnv *exec_env);
  615. void
  616. aot_dump_call_stack(WASMExecEnv *exec_env);
  617. void
  618. aot_dump_perf_profiling(const AOTModuleInstance *module_inst);
  619. #ifdef __cplusplus
  620. } /* end of extern "C" */
  621. #endif
  622. #endif /* end of _AOT_RUNTIME_H_ */