wasm_runtime_common.h 38 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192
  1. /*
  2. * Copyright (C) 2019 Intel Corporation. All rights reserved.
  3. * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. */
  5. #ifndef _WASM_COMMON_H
  6. #define _WASM_COMMON_H
  7. #include "bh_platform.h"
  8. #include "bh_common.h"
  9. #include "wasm_exec_env.h"
  10. #include "wasm_native.h"
  11. #include "../include/wasm_export.h"
  12. #include "../interpreter/wasm.h"
  13. #if WASM_ENABLE_GC != 0
  14. #include "gc/gc_object.h"
  15. #endif
  16. #if WASM_ENABLE_LIBC_WASI != 0
  17. #if WASM_ENABLE_UVWASI == 0
  18. #include "posix.h"
  19. #else
  20. #include "uvwasi.h"
  21. #endif
  22. #endif
  23. #ifdef __cplusplus
  24. extern "C" {
  25. #endif
  26. /* Internal use for setting default running mode */
  27. #define Mode_Default 0
  28. #if WASM_CPU_SUPPORTS_UNALIGNED_ADDR_ACCESS != 0
  29. #define PUT_I64_TO_ADDR(addr, value) \
  30. do { \
  31. *(int64 *)(addr) = (int64)(value); \
  32. } while (0)
  33. #define PUT_F64_TO_ADDR(addr, value) \
  34. do { \
  35. *(float64 *)(addr) = (float64)(value); \
  36. } while (0)
  37. #define PUT_REF_TO_ADDR(addr, value) \
  38. do { \
  39. *(void **)(addr) = (void *)(value); \
  40. } while (0)
  41. #define GET_I64_FROM_ADDR(addr) (*(int64 *)(addr))
  42. #define GET_F64_FROM_ADDR(addr) (*(float64 *)(addr))
  43. #define GET_REF_FROM_ADDR(addr) (*(void **)(addr))
  44. /* For STORE opcodes */
  45. #define STORE_I64 PUT_I64_TO_ADDR
  46. static inline void
  47. STORE_U32(void *addr, uint32_t value)
  48. {
  49. *(uint32_t *)(addr) = (uint32_t)(value);
  50. }
  51. static inline void
  52. STORE_U16(void *addr, uint16_t value)
  53. {
  54. *(uint16_t *)(addr) = (uint16_t)(value);
  55. }
  56. static inline void
  57. STORE_U8(void *addr, uint8_t value)
  58. {
  59. *(uint8 *)addr = value;
  60. }
  61. /* For LOAD opcodes */
  62. #define LOAD_I64(addr) (*(int64 *)(addr))
  63. #define LOAD_F64(addr) (*(float64 *)(addr))
  64. #define LOAD_I32(addr) (*(int32 *)(addr))
  65. #define LOAD_U32(addr) (*(uint32 *)(addr))
  66. #define LOAD_I16(addr) (*(int16 *)(addr))
  67. #define LOAD_U16(addr) (*(uint16 *)(addr))
  68. #define STORE_PTR(addr, ptr) \
  69. do { \
  70. *(void **)addr = (void *)ptr; \
  71. } while (0)
  72. #else /* WASM_CPU_SUPPORTS_UNALIGNED_ADDR_ACCESS != 0 */
  73. #define PUT_I64_TO_ADDR(addr, value) \
  74. do { \
  75. uint32 *addr_u32 = (uint32 *)(addr); \
  76. union { \
  77. int64 val; \
  78. uint32 parts[2]; \
  79. } u; \
  80. u.val = (int64)(value); \
  81. addr_u32[0] = u.parts[0]; \
  82. addr_u32[1] = u.parts[1]; \
  83. } while (0)
  84. #define PUT_F64_TO_ADDR(addr, value) \
  85. do { \
  86. uint32 *addr_u32 = (uint32 *)(addr); \
  87. union { \
  88. float64 val; \
  89. uint32 parts[2]; \
  90. } u; \
  91. u.val = (value); \
  92. addr_u32[0] = u.parts[0]; \
  93. addr_u32[1] = u.parts[1]; \
  94. } while (0)
  95. #if UINTPTR_MAX == UINT64_MAX
  96. #define PUT_REF_TO_ADDR(addr, value) \
  97. do { \
  98. uint32 *addr_u32 = (uint32 *)(addr); \
  99. union { \
  100. void *val; \
  101. uint32 parts[2]; \
  102. } u; \
  103. u.val = (void *)(value); \
  104. addr_u32[0] = u.parts[0]; \
  105. addr_u32[1] = u.parts[1]; \
  106. } while (0)
  107. #else
  108. #define PUT_REF_TO_ADDR(addr, value) \
  109. do { \
  110. *(void **)(addr) = (void *)(value); \
  111. } while (0)
  112. #endif
  113. static inline int64
  114. GET_I64_FROM_ADDR(uint32 *addr)
  115. {
  116. union {
  117. int64 val;
  118. uint32 parts[2];
  119. } u;
  120. u.parts[0] = addr[0];
  121. u.parts[1] = addr[1];
  122. return u.val;
  123. }
  124. static inline float64
  125. GET_F64_FROM_ADDR(uint32 *addr)
  126. {
  127. union {
  128. float64 val;
  129. uint32 parts[2];
  130. } u;
  131. u.parts[0] = addr[0];
  132. u.parts[1] = addr[1];
  133. return u.val;
  134. }
  135. #if UINTPTR_MAX == UINT64_MAX
  136. static inline void *
  137. GET_REF_FROM_ADDR(uint32 *addr)
  138. {
  139. union {
  140. void *val;
  141. uint32 parts[2];
  142. } u;
  143. u.parts[0] = addr[0];
  144. u.parts[1] = addr[1];
  145. return u.val;
  146. }
  147. #else
  148. #define GET_REF_FROM_ADDR(addr) (*(void **)(addr))
  149. #endif
  150. /* For STORE opcodes */
  151. #define STORE_I64(addr, value) \
  152. do { \
  153. uintptr_t addr_ = (uintptr_t)(addr); \
  154. union { \
  155. int64 val; \
  156. uint32 u32[2]; \
  157. uint16 u16[4]; \
  158. uint8 u8[8]; \
  159. } u; \
  160. if ((addr_ & (uintptr_t)7) == 0) \
  161. *(int64 *)(addr) = (int64)(value); \
  162. else { \
  163. u.val = (int64)(value); \
  164. if ((addr_ & (uintptr_t)3) == 0) { \
  165. ((uint32 *)(addr))[0] = u.u32[0]; \
  166. ((uint32 *)(addr))[1] = u.u32[1]; \
  167. } \
  168. else if ((addr_ & (uintptr_t)1) == 0) { \
  169. ((uint16 *)(addr))[0] = u.u16[0]; \
  170. ((uint16 *)(addr))[1] = u.u16[1]; \
  171. ((uint16 *)(addr))[2] = u.u16[2]; \
  172. ((uint16 *)(addr))[3] = u.u16[3]; \
  173. } \
  174. else { \
  175. int32 t; \
  176. for (t = 0; t < 8; t++) \
  177. ((uint8 *)(addr))[t] = u.u8[t]; \
  178. } \
  179. } \
  180. } while (0)
  181. static inline void
  182. STORE_U32(void *addr, uint32_t value)
  183. {
  184. uintptr_t addr_ = (uintptr_t)(addr);
  185. union {
  186. uint32_t val;
  187. uint16_t u16[2];
  188. uint8_t u8[4];
  189. } u;
  190. if ((addr_ & (uintptr_t)3) == 0)
  191. *(uint32_t *)(addr) = (uint32_t)(value);
  192. else {
  193. u.val = (uint32_t)(value);
  194. if ((addr_ & (uintptr_t)1) == 0) {
  195. ((uint16_t *)(addr))[0] = u.u16[0];
  196. ((uint16_t *)(addr))[1] = u.u16[1];
  197. }
  198. else {
  199. ((uint8_t *)(addr))[0] = u.u8[0];
  200. ((uint8_t *)(addr))[1] = u.u8[1];
  201. ((uint8_t *)(addr))[2] = u.u8[2];
  202. ((uint8_t *)(addr))[3] = u.u8[3];
  203. }
  204. }
  205. }
  206. static inline void
  207. STORE_U8(void *addr, uint8_t value)
  208. {
  209. *(uint8 *)addr = value;
  210. }
  211. static inline void
  212. STORE_U16(void *addr, uint16_t value)
  213. {
  214. union {
  215. uint16_t val;
  216. uint8_t u8[2];
  217. } u;
  218. u.val = (uint16_t)(value);
  219. ((uint8_t *)(addr))[0] = u.u8[0];
  220. ((uint8_t *)(addr))[1] = u.u8[1];
  221. }
  222. /* For LOAD opcodes */
  223. static inline int64
  224. LOAD_I64(void *addr)
  225. {
  226. uintptr_t addr1 = (uintptr_t)addr;
  227. union {
  228. int64 val;
  229. uint32 u32[2];
  230. uint16 u16[4];
  231. uint8 u8[8];
  232. } u;
  233. if ((addr1 & (uintptr_t)7) == 0)
  234. return *(int64 *)addr;
  235. if ((addr1 & (uintptr_t)3) == 0) {
  236. u.u32[0] = ((uint32 *)addr)[0];
  237. u.u32[1] = ((uint32 *)addr)[1];
  238. }
  239. else if ((addr1 & (uintptr_t)1) == 0) {
  240. u.u16[0] = ((uint16 *)addr)[0];
  241. u.u16[1] = ((uint16 *)addr)[1];
  242. u.u16[2] = ((uint16 *)addr)[2];
  243. u.u16[3] = ((uint16 *)addr)[3];
  244. }
  245. else {
  246. int32 t;
  247. for (t = 0; t < 8; t++)
  248. u.u8[t] = ((uint8 *)addr)[t];
  249. }
  250. return u.val;
  251. }
  252. static inline float64
  253. LOAD_F64(void *addr)
  254. {
  255. uintptr_t addr1 = (uintptr_t)addr;
  256. union {
  257. float64 val;
  258. uint32 u32[2];
  259. uint16 u16[4];
  260. uint8 u8[8];
  261. } u;
  262. if ((addr1 & (uintptr_t)7) == 0)
  263. return *(float64 *)addr;
  264. if ((addr1 & (uintptr_t)3) == 0) {
  265. u.u32[0] = ((uint32 *)addr)[0];
  266. u.u32[1] = ((uint32 *)addr)[1];
  267. }
  268. else if ((addr1 & (uintptr_t)1) == 0) {
  269. u.u16[0] = ((uint16 *)addr)[0];
  270. u.u16[1] = ((uint16 *)addr)[1];
  271. u.u16[2] = ((uint16 *)addr)[2];
  272. u.u16[3] = ((uint16 *)addr)[3];
  273. }
  274. else {
  275. int32 t;
  276. for (t = 0; t < 8; t++)
  277. u.u8[t] = ((uint8 *)addr)[t];
  278. }
  279. return u.val;
  280. }
  281. static inline int32
  282. LOAD_I32(void *addr)
  283. {
  284. uintptr_t addr1 = (uintptr_t)addr;
  285. union {
  286. int32 val;
  287. uint16 u16[2];
  288. uint8 u8[4];
  289. } u;
  290. if ((addr1 & (uintptr_t)3) == 0)
  291. return *(int32 *)addr;
  292. if ((addr1 & (uintptr_t)1) == 0) {
  293. u.u16[0] = ((uint16 *)addr)[0];
  294. u.u16[1] = ((uint16 *)addr)[1];
  295. }
  296. else {
  297. u.u8[0] = ((uint8 *)addr)[0];
  298. u.u8[1] = ((uint8 *)addr)[1];
  299. u.u8[2] = ((uint8 *)addr)[2];
  300. u.u8[3] = ((uint8 *)addr)[3];
  301. }
  302. return u.val;
  303. }
  304. static inline int16
  305. LOAD_I16(void *addr)
  306. {
  307. uintptr_t addr1 = (uintptr_t)addr;
  308. union {
  309. int16 val;
  310. uint8 u8[2];
  311. } u;
  312. if ((addr1 & (uintptr_t)1)) {
  313. u.u8[0] = ((uint8 *)addr)[0];
  314. u.u8[1] = ((uint8 *)addr)[1];
  315. return u.val;
  316. }
  317. return *(int16 *)addr;
  318. }
  319. #define LOAD_U32(addr) ((uint32)LOAD_I32(addr))
  320. #define LOAD_U16(addr) ((uint16)LOAD_I16(addr))
  321. #if UINTPTR_MAX == UINT32_MAX
  322. #define STORE_PTR(addr, ptr) STORE_U32(addr, (uintptr_t)ptr)
  323. #elif UINTPTR_MAX == UINT64_MAX
  324. #define STORE_PTR(addr, ptr) STORE_I64(addr, (uintptr_t)ptr)
  325. #endif
  326. #endif /* WASM_CPU_SUPPORTS_UNALIGNED_ADDR_ACCESS != 0 */
  327. #if WASM_ENABLE_SHARED_MEMORY != 0
  328. #define SHARED_MEMORY_LOCK(memory) shared_memory_lock(memory)
  329. #define SHARED_MEMORY_UNLOCK(memory) shared_memory_unlock(memory)
  330. #else
  331. #define SHARED_MEMORY_LOCK(memory) (void)0
  332. #define SHARED_MEMORY_UNLOCK(memory) (void)0
  333. #endif
  334. typedef struct WASMModuleCommon {
  335. /* Module type, for module loaded from WASM bytecode binary,
  336. this field is Wasm_Module_Bytecode, and this structure should
  337. be treated as WASMModule structure;
  338. for module loaded from AOT binary, this field is
  339. Wasm_Module_AoT, and this structure should be treated as
  340. AOTModule structure. */
  341. uint32 module_type;
  342. /* The following uint8[1] member is a dummy just to indicate
  343. some module_type dependent members follow.
  344. Typically it should be accessed by casting to the corresponding
  345. actual module_type dependent structure, not via this member. */
  346. uint8 module_data[1];
  347. } WASMModuleCommon;
  348. typedef struct WASMModuleInstanceCommon {
  349. /* Module instance type, for module instance loaded from WASM
  350. bytecode binary, this field is Wasm_Module_Bytecode, and this
  351. structure should be treated as WASMModuleInstance structure;
  352. for module instance loaded from AOT binary, this field is
  353. Wasm_Module_AoT, and this structure should be treated as
  354. AOTModuleInstance structure. */
  355. uint32 module_type;
  356. /* The following uint8[1] member is a dummy just to indicate
  357. some module_type dependent members follow.
  358. Typically it should be accessed by casting to the corresponding
  359. actual module_type dependent structure, not via this member. */
  360. uint8 module_inst_data[1];
  361. } WASMModuleInstanceCommon;
  362. typedef struct WASMModuleMemConsumption {
  363. uint32 total_size;
  364. uint32 module_struct_size;
  365. uint32 types_size;
  366. uint32 imports_size;
  367. uint32 functions_size;
  368. uint32 tables_size;
  369. uint32 memories_size;
  370. uint32 globals_size;
  371. uint32 exports_size;
  372. uint32 table_segs_size;
  373. uint32 data_segs_size;
  374. uint32 const_strs_size;
  375. #if WASM_ENABLE_AOT != 0
  376. uint32 aot_code_size;
  377. #endif
  378. } WASMModuleMemConsumption;
  379. typedef struct WASMModuleInstMemConsumption {
  380. uint32 total_size;
  381. uint32 module_inst_struct_size;
  382. uint32 memories_size;
  383. uint32 app_heap_size;
  384. uint32 tables_size;
  385. uint32 globals_size;
  386. uint32 functions_size;
  387. uint32 exports_size;
  388. } WASMModuleInstMemConsumption;
  389. #if WASM_ENABLE_LIBC_WASI != 0
  390. #if WASM_ENABLE_UVWASI == 0
  391. typedef struct WASIContext {
  392. struct fd_table *curfds;
  393. struct fd_prestats *prestats;
  394. struct argv_environ_values *argv_environ;
  395. struct addr_pool *addr_pool;
  396. char *ns_lookup_buf;
  397. char **ns_lookup_list;
  398. char *argv_buf;
  399. char **argv_list;
  400. char *env_buf;
  401. char **env_list;
  402. uint32_t exit_code;
  403. } WASIContext;
  404. #else
  405. typedef struct WASIContext {
  406. uvwasi_t uvwasi;
  407. uint32_t exit_code;
  408. } WASIContext;
  409. #endif
  410. #endif
  411. #if WASM_ENABLE_MULTI_MODULE != 0
  412. typedef struct WASMRegisteredModule {
  413. bh_list_link l;
  414. /* point to a string pool */
  415. const char *module_name;
  416. WASMModuleCommon *module;
  417. /* to store the original module file buffer address */
  418. uint8 *orig_file_buf;
  419. uint32 orig_file_buf_size;
  420. } WASMRegisteredModule;
  421. #endif
  422. typedef package_type_t PackageType;
  423. typedef wasm_section_t WASMSection, AOTSection;
  424. typedef struct wasm_frame_t {
  425. /* wasm_instance_t */
  426. void *instance;
  427. uint32 module_offset;
  428. uint32 func_index;
  429. uint32 func_offset;
  430. const char *func_name_wp;
  431. uint32 *sp;
  432. uint8 *frame_ref;
  433. uint32 *lp;
  434. } WASMCApiFrame;
  435. #if WASM_ENABLE_JIT != 0
  436. typedef struct LLVMJITOptions {
  437. uint32 opt_level;
  438. uint32 size_level;
  439. uint32 segue_flags;
  440. bool quick_invoke_c_api_import;
  441. } LLVMJITOptions;
  442. #endif
  443. #ifdef OS_ENABLE_HW_BOUND_CHECK
  444. /* Signal info passing to interp/aot signal handler */
  445. typedef struct WASMSignalInfo {
  446. WASMExecEnv *exec_env_tls;
  447. #ifndef BH_PLATFORM_WINDOWS
  448. void *sig_addr;
  449. #else
  450. EXCEPTION_POINTERS *exce_info;
  451. #endif
  452. } WASMSignalInfo;
  453. /* Set exec_env of thread local storage */
  454. void
  455. wasm_runtime_set_exec_env_tls(WASMExecEnv *exec_env);
  456. /* Get exec_env of thread local storage */
  457. WASMExecEnv *
  458. wasm_runtime_get_exec_env_tls(void);
  459. #endif
  460. /* See wasm_export.h for description */
  461. WASM_RUNTIME_API_EXTERN bool
  462. wasm_runtime_init(void);
  463. /* Internal API */
  464. RunningMode
  465. wasm_runtime_get_default_running_mode(void);
  466. #if WASM_ENABLE_JIT != 0
  467. /* Internal API */
  468. LLVMJITOptions *
  469. wasm_runtime_get_llvm_jit_options(void);
  470. #endif
  471. #if WASM_ENABLE_GC != 0
  472. /* Internal API */
  473. uint32
  474. wasm_runtime_get_gc_heap_size_default(void);
  475. #endif
  476. /* See wasm_export.h for description */
  477. WASM_RUNTIME_API_EXTERN bool
  478. wasm_runtime_full_init(RuntimeInitArgs *init_args);
  479. /* See wasm_export.h for description */
  480. WASM_RUNTIME_API_EXTERN bool
  481. wasm_runtime_is_running_mode_supported(RunningMode running_mode);
  482. /* See wasm_export.h for description */
  483. WASM_RUNTIME_API_EXTERN bool
  484. wasm_runtime_set_default_running_mode(RunningMode running_mode);
  485. /* See wasm_export.h for description */
  486. WASM_RUNTIME_API_EXTERN void
  487. wasm_runtime_destroy(void);
  488. /* See wasm_export.h for description */
  489. WASM_RUNTIME_API_EXTERN PackageType
  490. get_package_type(const uint8 *buf, uint32 size);
  491. /* See wasm_export.h for description */
  492. WASM_RUNTIME_API_EXTERN bool
  493. wasm_runtime_is_xip_file(const uint8 *buf, uint32 size);
  494. /* See wasm_export.h for description */
  495. WASM_RUNTIME_API_EXTERN WASMModuleCommon *
  496. wasm_runtime_load(uint8 *buf, uint32 size, char *error_buf,
  497. uint32 error_buf_size);
  498. /* See wasm_export.h for description */
  499. WASM_RUNTIME_API_EXTERN WASMModuleCommon *
  500. wasm_runtime_load_from_sections(WASMSection *section_list, bool is_aot,
  501. char *error_buf, uint32 error_buf_size);
  502. /* See wasm_export.h for description */
  503. WASM_RUNTIME_API_EXTERN void
  504. wasm_runtime_unload(WASMModuleCommon *module);
  505. /* Internal API */
  506. WASMModuleInstanceCommon *
  507. wasm_runtime_instantiate_internal(WASMModuleCommon *module,
  508. WASMModuleInstanceCommon *parent,
  509. WASMExecEnv *exec_env_main, uint32 stack_size,
  510. uint32 heap_size, char *error_buf,
  511. uint32 error_buf_size);
  512. /* Internal API */
  513. void
  514. wasm_runtime_deinstantiate_internal(WASMModuleInstanceCommon *module_inst,
  515. bool is_sub_inst);
  516. /* See wasm_export.h for description */
  517. WASM_RUNTIME_API_EXTERN WASMModuleInstanceCommon *
  518. wasm_runtime_instantiate(WASMModuleCommon *module, uint32 default_stack_size,
  519. uint32 host_managed_heap_size, char *error_buf,
  520. uint32 error_buf_size);
  521. /* See wasm_export.h for description */
  522. WASM_RUNTIME_API_EXTERN bool
  523. wasm_runtime_set_running_mode(wasm_module_inst_t module_inst,
  524. RunningMode running_mode);
  525. /* See wasm_export.h for description */
  526. WASM_RUNTIME_API_EXTERN RunningMode
  527. wasm_runtime_get_running_mode(wasm_module_inst_t module_inst);
  528. /* See wasm_export.h for description */
  529. WASM_RUNTIME_API_EXTERN void
  530. wasm_runtime_deinstantiate(WASMModuleInstanceCommon *module_inst);
  531. /* See wasm_export.h for description */
  532. WASM_RUNTIME_API_EXTERN WASMModuleCommon *
  533. wasm_runtime_get_module(WASMModuleInstanceCommon *module_inst);
  534. /* See wasm_export.h for description */
  535. WASM_RUNTIME_API_EXTERN WASMFunctionInstanceCommon *
  536. wasm_runtime_lookup_function(WASMModuleInstanceCommon *const module_inst,
  537. const char *name, const char *signature);
  538. /* Internal API */
  539. WASMFuncType *
  540. wasm_runtime_get_function_type(const WASMFunctionInstanceCommon *function,
  541. uint32 module_type);
  542. /* See wasm_export.h for description */
  543. WASM_RUNTIME_API_EXTERN uint32
  544. wasm_func_get_param_count(WASMFunctionInstanceCommon *const func_inst,
  545. WASMModuleInstanceCommon *const module_inst);
  546. /* See wasm_export.h for description */
  547. WASM_RUNTIME_API_EXTERN uint32
  548. wasm_func_get_result_count(WASMFunctionInstanceCommon *const func_inst,
  549. WASMModuleInstanceCommon *const module_inst);
  550. /* See wasm_export.h for description */
  551. WASM_RUNTIME_API_EXTERN void
  552. wasm_func_get_param_types(WASMFunctionInstanceCommon *const func_inst,
  553. WASMModuleInstanceCommon *const module_inst,
  554. wasm_valkind_t *param_types);
  555. /* See wasm_export.h for description */
  556. WASM_RUNTIME_API_EXTERN void
  557. wasm_func_get_result_types(WASMFunctionInstanceCommon *const func_inst,
  558. WASMModuleInstanceCommon *const module_inst,
  559. wasm_valkind_t *result_types);
  560. /* See wasm_export.h for description */
  561. WASM_RUNTIME_API_EXTERN WASMExecEnv *
  562. wasm_runtime_create_exec_env(WASMModuleInstanceCommon *module_inst,
  563. uint32 stack_size);
  564. /* See wasm_export.h for description */
  565. WASM_RUNTIME_API_EXTERN void
  566. wasm_runtime_destroy_exec_env(WASMExecEnv *exec_env);
  567. /* See wasm_export.h for description */
  568. WASM_RUNTIME_API_EXTERN WASMModuleInstanceCommon *
  569. wasm_runtime_get_module_inst(WASMExecEnv *exec_env);
  570. /* See wasm_export.h for description */
  571. WASM_RUNTIME_API_EXTERN void
  572. wasm_runtime_set_module_inst(WASMExecEnv *exec_env,
  573. WASMModuleInstanceCommon *const module_inst);
  574. /* See wasm_export.h for description */
  575. WASM_RUNTIME_API_EXTERN void *
  576. wasm_runtime_get_function_attachment(WASMExecEnv *exec_env);
  577. /* See wasm_export.h for description */
  578. WASM_RUNTIME_API_EXTERN void
  579. wasm_runtime_set_user_data(WASMExecEnv *exec_env, void *user_data);
  580. /* See wasm_export.h for description */
  581. WASM_RUNTIME_API_EXTERN void *
  582. wasm_runtime_get_user_data(WASMExecEnv *exec_env);
  583. #if WASM_CONFIGURABLE_BOUNDS_CHECKS != 0
  584. /* See wasm_export.h for description */
  585. WASM_RUNTIME_API_EXTERN void
  586. wasm_runtime_set_bounds_checks(WASMModuleInstanceCommon *module_inst,
  587. bool enable);
  588. /* See wasm_export.h for description */
  589. WASM_RUNTIME_API_EXTERN bool
  590. wasm_runtime_is_bounds_checks_enabled(WASMModuleInstanceCommon *module_inst);
  591. #endif
  592. #ifdef OS_ENABLE_HW_BOUND_CHECK
  593. /* Access exception check guard page to trigger the signal handler */
  594. void
  595. wasm_runtime_access_exce_check_guard_page();
  596. #endif
  597. /* See wasm_export.h for description */
  598. WASM_RUNTIME_API_EXTERN bool
  599. wasm_runtime_call_wasm(WASMExecEnv *exec_env,
  600. WASMFunctionInstanceCommon *function, uint32 argc,
  601. uint32 argv[]);
  602. WASM_RUNTIME_API_EXTERN bool
  603. wasm_runtime_call_wasm_a(WASMExecEnv *exec_env,
  604. WASMFunctionInstanceCommon *function,
  605. uint32 num_results, wasm_val_t *results,
  606. uint32 num_args, wasm_val_t *args);
  607. WASM_RUNTIME_API_EXTERN bool
  608. wasm_runtime_call_wasm_v(WASMExecEnv *exec_env,
  609. WASMFunctionInstanceCommon *function,
  610. uint32 num_results, wasm_val_t *results,
  611. uint32 num_args, ...);
  612. /* See wasm_export.h for description */
  613. WASM_RUNTIME_API_EXTERN bool
  614. wasm_runtime_call_indirect(WASMExecEnv *exec_env, uint32 element_index,
  615. uint32 argc, uint32 argv[]);
  616. #if WASM_ENABLE_DEBUG_INTERP != 0
  617. /* See wasm_export.h for description */
  618. WASM_RUNTIME_API_EXTERN uint32
  619. wasm_runtime_start_debug_instance_with_port(WASMExecEnv *exec_env,
  620. int32_t port);
  621. /* See wasm_export.h for description */
  622. WASM_RUNTIME_API_EXTERN uint32
  623. wasm_runtime_start_debug_instance(WASMExecEnv *exec_env);
  624. #endif
  625. bool
  626. wasm_runtime_create_exec_env_singleton(WASMModuleInstanceCommon *module_inst);
  627. /* See wasm_export.h for description */
  628. WASM_RUNTIME_API_EXTERN WASMExecEnv *
  629. wasm_runtime_get_exec_env_singleton(WASMModuleInstanceCommon *module_inst);
  630. /* See wasm_export.h for description */
  631. WASM_RUNTIME_API_EXTERN bool
  632. wasm_application_execute_main(WASMModuleInstanceCommon *module_inst, int32 argc,
  633. char *argv[]);
  634. /* See wasm_export.h for description */
  635. WASM_RUNTIME_API_EXTERN bool
  636. wasm_application_execute_func(WASMModuleInstanceCommon *module_inst,
  637. const char *name, int32 argc, char *argv[]);
  638. /* See wasm_export.h for description */
  639. WASM_RUNTIME_API_EXTERN void
  640. wasm_runtime_set_exception(WASMModuleInstanceCommon *module,
  641. const char *exception);
  642. /* See wasm_export.h for description */
  643. WASM_RUNTIME_API_EXTERN const char *
  644. wasm_runtime_get_exception(WASMModuleInstanceCommon *module);
  645. /* See wasm_export.h for description */
  646. WASM_RUNTIME_API_EXTERN void
  647. wasm_runtime_clear_exception(WASMModuleInstanceCommon *module_inst);
  648. /* See wasm_export.h for description */
  649. WASM_RUNTIME_API_EXTERN void
  650. wasm_runtime_terminate(WASMModuleInstanceCommon *module);
  651. /* Internal API */
  652. void
  653. wasm_runtime_set_custom_data_internal(WASMModuleInstanceCommon *module_inst,
  654. void *custom_data);
  655. /* See wasm_export.h for description */
  656. WASM_RUNTIME_API_EXTERN void
  657. wasm_runtime_set_custom_data(WASMModuleInstanceCommon *module_inst,
  658. void *custom_data);
  659. /* See wasm_export.h for description */
  660. WASM_RUNTIME_API_EXTERN void *
  661. wasm_runtime_get_custom_data(WASMModuleInstanceCommon *module_inst);
  662. /* Internal API */
  663. uint32
  664. wasm_runtime_module_malloc_internal(WASMModuleInstanceCommon *module_inst,
  665. WASMExecEnv *exec_env, uint32 size,
  666. void **p_native_addr);
  667. /* Internal API */
  668. uint32
  669. wasm_runtime_module_realloc_internal(WASMModuleInstanceCommon *module_inst,
  670. WASMExecEnv *exec_env, uint32 ptr,
  671. uint32 size, void **p_native_addr);
  672. /* Internal API */
  673. void
  674. wasm_runtime_module_free_internal(WASMModuleInstanceCommon *module_inst,
  675. WASMExecEnv *exec_env, uint32 ptr);
  676. /* See wasm_export.h for description */
  677. WASM_RUNTIME_API_EXTERN uint32
  678. wasm_runtime_module_malloc(WASMModuleInstanceCommon *module_inst, uint32 size,
  679. void **p_native_addr);
  680. /* See wasm_export.h for description */
  681. WASM_RUNTIME_API_EXTERN void
  682. wasm_runtime_module_free(WASMModuleInstanceCommon *module_inst, uint32 ptr);
  683. /* See wasm_export.h for description */
  684. WASM_RUNTIME_API_EXTERN uint32
  685. wasm_runtime_module_dup_data(WASMModuleInstanceCommon *module_inst,
  686. const char *src, uint32 size);
  687. /* See wasm_export.h for description */
  688. WASM_RUNTIME_API_EXTERN bool
  689. wasm_runtime_validate_app_addr(WASMModuleInstanceCommon *module_inst,
  690. uint32 app_offset, uint32 size);
  691. /* See wasm_export.h for description */
  692. WASM_RUNTIME_API_EXTERN bool
  693. wasm_runtime_validate_app_str_addr(WASMModuleInstanceCommon *module_inst,
  694. uint32 app_str_offset);
  695. /* See wasm_export.h for description */
  696. WASM_RUNTIME_API_EXTERN bool
  697. wasm_runtime_validate_native_addr(WASMModuleInstanceCommon *module_inst,
  698. void *native_ptr, uint32 size);
  699. /* See wasm_export.h for description */
  700. WASM_RUNTIME_API_EXTERN void *
  701. wasm_runtime_addr_app_to_native(WASMModuleInstanceCommon *module_inst,
  702. uint32 app_offset);
  703. /* See wasm_export.h for description */
  704. WASM_RUNTIME_API_EXTERN uint32
  705. wasm_runtime_addr_native_to_app(WASMModuleInstanceCommon *module_inst,
  706. void *native_ptr);
  707. /* See wasm_export.h for description */
  708. WASM_RUNTIME_API_EXTERN bool
  709. wasm_runtime_get_app_addr_range(WASMModuleInstanceCommon *module_inst,
  710. uint32 app_offset, uint32 *p_app_start_offset,
  711. uint32 *p_app_end_offset);
  712. /* See wasm_export.h for description */
  713. WASM_RUNTIME_API_EXTERN bool
  714. wasm_runtime_get_native_addr_range(WASMModuleInstanceCommon *module_inst,
  715. uint8 *native_ptr,
  716. uint8 **p_native_start_addr,
  717. uint8 **p_native_end_addr);
  718. /* See wasm_export.h for description */
  719. WASM_RUNTIME_API_EXTERN const uint8 *
  720. wasm_runtime_get_custom_section(WASMModuleCommon *const module_comm,
  721. const char *name, uint32 *len);
  722. #if WASM_ENABLE_MULTI_MODULE != 0
  723. WASM_RUNTIME_API_EXTERN void
  724. wasm_runtime_set_module_reader(const module_reader reader,
  725. const module_destroyer destroyer);
  726. module_reader
  727. wasm_runtime_get_module_reader();
  728. module_destroyer
  729. wasm_runtime_get_module_destroyer();
  730. bool
  731. wasm_runtime_register_module_internal(const char *module_name,
  732. WASMModuleCommon *module,
  733. uint8 *orig_file_buf,
  734. uint32 orig_file_buf_size,
  735. char *error_buf, uint32 error_buf_size);
  736. void
  737. wasm_runtime_unregister_module(const WASMModuleCommon *module);
  738. WASMModuleCommon *
  739. wasm_runtime_find_module_registered(const char *module_name);
  740. bool
  741. wasm_runtime_add_loading_module(const char *module_name, char *error_buf,
  742. uint32 error_buf_size);
  743. void
  744. wasm_runtime_delete_loading_module(const char *module_name);
  745. bool
  746. wasm_runtime_is_loading_module(const char *module_name);
  747. void
  748. wasm_runtime_destroy_loading_module_list();
  749. WASMModuleCommon *
  750. wasm_runtime_search_sub_module(const WASMModuleCommon *parent_module,
  751. const char *sub_module_name);
  752. bool
  753. wasm_runtime_register_sub_module(const WASMModuleCommon *parent_module,
  754. const char *sub_module_name,
  755. WASMModuleCommon *sub_module);
  756. WASMModuleCommon *
  757. wasm_runtime_load_depended_module(const WASMModuleCommon *parent_module,
  758. const char *sub_module_name, char *error_buf,
  759. uint32 error_buf_size);
  760. bool
  761. wasm_runtime_sub_module_instantiate(WASMModuleCommon *module,
  762. WASMModuleInstanceCommon *module_inst,
  763. uint32 stack_size, uint32 heap_size,
  764. char *error_buf, uint32 error_buf_size);
  765. void
  766. wasm_runtime_sub_module_deinstantiate(WASMModuleInstanceCommon *module_inst);
  767. #endif
  768. #if WASM_ENABLE_LIBC_WASI != 0 || WASM_ENABLE_MULTI_MODULE != 0
  769. WASMExport *
  770. loader_find_export(const WASMModuleCommon *module, const char *module_name,
  771. const char *field_name, uint8 export_kind, char *error_buf,
  772. uint32 error_buf_size);
  773. #endif /* WASM_ENALBE_MULTI_MODULE */
  774. bool
  775. wasm_runtime_is_built_in_module(const char *module_name);
  776. #if WASM_ENABLE_THREAD_MGR != 0
  777. bool
  778. wasm_exec_env_get_aux_stack(WASMExecEnv *exec_env, uint32 *start_offset,
  779. uint32 *size);
  780. bool
  781. wasm_exec_env_set_aux_stack(WASMExecEnv *exec_env, uint32 start_offset,
  782. uint32 size);
  783. #endif
  784. #if WASM_ENABLE_LIBC_WASI != 0
  785. WASM_RUNTIME_API_EXTERN void
  786. wasm_runtime_set_wasi_args_ex(WASMModuleCommon *module, const char *dir_list[],
  787. uint32 dir_count, const char *map_dir_list[],
  788. uint32 map_dir_count, const char *env_list[],
  789. uint32 env_count, char *argv[], int argc,
  790. int64 stdinfd, int64 stdoutfd, int64 stderrfd);
  791. /* See wasm_export.h for description */
  792. WASM_RUNTIME_API_EXTERN void
  793. wasm_runtime_set_wasi_args(WASMModuleCommon *module, const char *dir_list[],
  794. uint32 dir_count, const char *map_dir_list[],
  795. uint32 map_dir_count, const char *env_list[],
  796. uint32 env_count, char *argv[], int argc);
  797. /* See wasm_export.h for description */
  798. WASM_RUNTIME_API_EXTERN bool
  799. wasm_runtime_is_wasi_mode(WASMModuleInstanceCommon *module_inst);
  800. /* See wasm_export.h for description */
  801. WASM_RUNTIME_API_EXTERN WASMFunctionInstanceCommon *
  802. wasm_runtime_lookup_wasi_start_function(WASMModuleInstanceCommon *module_inst);
  803. /* See wasm_export.h for description */
  804. WASM_RUNTIME_API_EXTERN uint32_t
  805. wasm_runtime_get_wasi_exit_code(WASMModuleInstanceCommon *module_inst);
  806. bool
  807. wasm_runtime_init_wasi(WASMModuleInstanceCommon *module_inst,
  808. const char *dir_list[], uint32 dir_count,
  809. const char *map_dir_list[], uint32 map_dir_count,
  810. const char *env[], uint32 env_count,
  811. const char *addr_pool[], uint32 addr_pool_size,
  812. const char *ns_lookup_pool[], uint32 ns_lookup_pool_size,
  813. char *argv[], uint32 argc, os_raw_file_handle stdinfd,
  814. os_raw_file_handle stdoutfd, os_raw_file_handle stderrfd,
  815. char *error_buf, uint32 error_buf_size);
  816. void
  817. wasm_runtime_destroy_wasi(WASMModuleInstanceCommon *module_inst);
  818. void
  819. wasm_runtime_set_wasi_ctx(WASMModuleInstanceCommon *module_inst,
  820. WASIContext *wasi_ctx);
  821. WASIContext *
  822. wasm_runtime_get_wasi_ctx(WASMModuleInstanceCommon *module_inst);
  823. WASM_RUNTIME_API_EXTERN void
  824. wasm_runtime_set_wasi_addr_pool(wasm_module_t module, const char *addr_pool[],
  825. uint32 addr_pool_size);
  826. WASM_RUNTIME_API_EXTERN void
  827. wasm_runtime_set_wasi_ns_lookup_pool(wasm_module_t module,
  828. const char *ns_lookup_pool[],
  829. uint32 ns_lookup_pool_size);
  830. #endif /* end of WASM_ENABLE_LIBC_WASI */
  831. #if WASM_ENABLE_GC != 0
  832. void
  833. wasm_runtime_set_gc_heap_handle(WASMModuleInstanceCommon *module_inst,
  834. void *gc_heap_handle);
  835. void *
  836. wasm_runtime_get_gc_heap_handle(WASMModuleInstanceCommon *module_inst);
  837. #endif
  838. #if WASM_ENABLE_REF_TYPES != 0
  839. /* See wasm_export.h for description */
  840. WASM_RUNTIME_API_EXTERN bool
  841. wasm_externref_obj2ref(WASMModuleInstanceCommon *module_inst, void *extern_obj,
  842. uint32 *p_externref_idx);
  843. /* See wasm_export.h for description */
  844. WASM_RUNTIME_API_EXTERN bool
  845. wasm_externref_ref2obj(uint32 externref_idx, void **p_extern_obj);
  846. /* See wasm_export.h for description */
  847. WASM_RUNTIME_API_EXTERN bool
  848. wasm_externref_retain(uint32 externref_idx);
  849. /**
  850. * Reclaim the externref objects/indexes which are not used by
  851. * module instance
  852. */
  853. void
  854. wasm_externref_reclaim(WASMModuleInstanceCommon *module_inst);
  855. /**
  856. * Cleanup the externref objects/indexes of the module instance
  857. */
  858. void
  859. wasm_externref_cleanup(WASMModuleInstanceCommon *module_inst);
  860. #endif /* end of WASM_ENABLE_REF_TYPES */
  861. #if WASM_ENABLE_DUMP_CALL_STACK != 0
  862. /**
  863. * @brief Internal implementation for dumping or printing callstack line
  864. *
  865. * @note if dump_or_print is true, then print to stdout directly;
  866. * if dump_or_print is false, but *buf is NULL, then return the length of the
  867. * line;
  868. * if dump_or_print is false, and *buf is not NULL, then dump content to
  869. * the memory pointed by *buf, and adjust *buf and *len according to actual
  870. * bytes dumped, and return the actual dumped length
  871. *
  872. * @param line_buf current line to dump or print
  873. * @param dump_or_print whether to print to stdout or dump to buf
  874. * @param buf [INOUT] pointer to the buffer
  875. * @param len [INOUT] pointer to remaining length
  876. * @return bytes printed to stdout or dumped to buf
  877. */
  878. uint32
  879. wasm_runtime_dump_line_buf_impl(const char *line_buf, bool dump_or_print,
  880. char **buf, uint32 *len);
  881. #endif /* end of WASM_ENABLE_DUMP_CALL_STACK != 0 */
  882. /* Get module of the current exec_env */
  883. WASMModuleCommon *
  884. wasm_exec_env_get_module(WASMExecEnv *exec_env);
  885. /* See wasm_export.h for description */
  886. WASM_RUNTIME_API_EXTERN bool
  887. wasm_runtime_register_natives(const char *module_name,
  888. NativeSymbol *native_symbols,
  889. uint32 n_native_symbols);
  890. /* See wasm_export.h for description */
  891. WASM_RUNTIME_API_EXTERN bool
  892. wasm_runtime_register_natives_raw(const char *module_name,
  893. NativeSymbol *native_symbols,
  894. uint32 n_native_symbols);
  895. /* See wasm_export.h for description */
  896. WASM_RUNTIME_API_EXTERN bool
  897. wasm_runtime_unregister_natives(const char *module_name,
  898. NativeSymbol *native_symbols);
  899. /* See wasm_export.h for description */
  900. WASM_RUNTIME_API_EXTERN void *
  901. wasm_runtime_create_context_key(void (*dtor)(WASMModuleInstanceCommon *inst,
  902. void *ctx));
  903. /* See wasm_export.h for description */
  904. WASM_RUNTIME_API_EXTERN void
  905. wasm_runtime_destroy_context_key(void *key);
  906. /* See wasm_export.h for description */
  907. WASM_RUNTIME_API_EXTERN void
  908. wasm_runtime_set_context(WASMModuleInstanceCommon *inst, void *key, void *ctx);
  909. /* See wasm_export.h for description */
  910. WASM_RUNTIME_API_EXTERN void
  911. wasm_runtime_set_context_spread(WASMModuleInstanceCommon *inst, void *key,
  912. void *ctx);
  913. /* See wasm_export.h for description */
  914. WASM_RUNTIME_API_EXTERN void *
  915. wasm_runtime_get_context(WASMModuleInstanceCommon *inst, void *key);
  916. bool
  917. wasm_runtime_invoke_native(WASMExecEnv *exec_env, void *func_ptr,
  918. const WASMFuncType *func_type, const char *signature,
  919. void *attachment, uint32 *argv, uint32 argc,
  920. uint32 *ret);
  921. bool
  922. wasm_runtime_invoke_native_raw(WASMExecEnv *exec_env, void *func_ptr,
  923. const WASMFuncType *func_type,
  924. const char *signature, void *attachment,
  925. uint32 *argv, uint32 argc, uint32 *ret);
  926. void
  927. wasm_runtime_read_v128(const uint8 *bytes, uint64 *ret1, uint64 *ret2);
  928. void
  929. wasm_runtime_dump_module_mem_consumption(const WASMModuleCommon *module);
  930. void
  931. wasm_runtime_dump_module_inst_mem_consumption(
  932. const WASMModuleInstanceCommon *module_inst);
  933. void
  934. wasm_runtime_dump_exec_env_mem_consumption(const WASMExecEnv *exec_env);
  935. bool
  936. wasm_runtime_get_table_elem_type(const WASMModuleCommon *module_comm,
  937. uint32 table_idx, uint8 *out_elem_type,
  938. #if WASM_ENABLE_GC != 0
  939. WASMRefType **out_ref_type,
  940. #endif
  941. uint32 *out_min_size, uint32 *out_max_size);
  942. bool
  943. wasm_runtime_get_table_inst_elem_type(
  944. const WASMModuleInstanceCommon *module_inst_comm, uint32 table_idx,
  945. uint8 *out_elem_type,
  946. #if WASM_ENABLE_GC != 0
  947. WASMRefType **out_ref_type,
  948. #endif
  949. uint32 *out_min_size, uint32 *out_max_size);
  950. bool
  951. wasm_runtime_get_export_func_type(const WASMModuleCommon *module_comm,
  952. const WASMExport *export_,
  953. WASMFuncType **out);
  954. bool
  955. wasm_runtime_get_export_global_type(const WASMModuleCommon *module_comm,
  956. const WASMExport *export_,
  957. uint8 *out_val_type, bool *out_mutability);
  958. bool
  959. wasm_runtime_get_export_memory_type(const WASMModuleCommon *module_comm,
  960. const WASMExport *export_,
  961. uint32 *out_min_page, uint32 *out_max_page);
  962. bool
  963. wasm_runtime_get_export_table_type(const WASMModuleCommon *module_comm,
  964. const WASMExport *export_,
  965. uint8 *out_elem_type,
  966. #if WASM_ENABLE_GC != 0
  967. WASMRefType **out_ref_type,
  968. #endif
  969. uint32 *out_min_size, uint32 *out_max_size);
  970. bool
  971. wasm_runtime_invoke_c_api_native(WASMModuleInstanceCommon *module_inst,
  972. void *func_ptr, WASMFuncType *func_type,
  973. uint32 argc, uint32 *argv, bool with_env,
  974. void *wasm_c_api_env);
  975. struct CApiFuncImport;
  976. /* A quick version of wasm_runtime_invoke_c_api_native to directly invoke
  977. wasm-c-api import function from jitted code to improve performance */
  978. bool
  979. wasm_runtime_quick_invoke_c_api_native(WASMModuleInstanceCommon *module_inst,
  980. struct CApiFuncImport *c_api_import,
  981. wasm_val_t *params, uint32 param_count,
  982. wasm_val_t *results,
  983. uint32 result_count);
  984. void
  985. wasm_runtime_show_app_heap_corrupted_prompt();
  986. #if WASM_ENABLE_LOAD_CUSTOM_SECTION != 0
  987. void
  988. wasm_runtime_destroy_custom_sections(WASMCustomSection *section_list);
  989. #endif
  990. WASM_RUNTIME_API_EXTERN bool
  991. wasm_runtime_is_import_func_linked(const char *module_name,
  992. const char *func_name);
  993. WASM_RUNTIME_API_EXTERN bool
  994. wasm_runtime_is_import_global_linked(const char *module_name,
  995. const char *global_name);
  996. WASM_RUNTIME_API_EXTERN bool
  997. wasm_runtime_begin_blocking_op(WASMExecEnv *exec_env);
  998. WASM_RUNTIME_API_EXTERN void
  999. wasm_runtime_end_blocking_op(WASMExecEnv *exec_env);
  1000. void
  1001. wasm_runtime_interrupt_blocking_op(WASMExecEnv *exec_env);
  1002. #if WASM_ENABLE_LINUX_PERF != 0
  1003. bool
  1004. wasm_runtime_get_linux_perf(void);
  1005. void
  1006. wasm_runtime_set_linux_perf(bool flag);
  1007. #endif
  1008. #ifdef __cplusplus
  1009. }
  1010. #endif
  1011. #endif /* end of _WASM_COMMON_H */