wasm_application.c 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653
  1. /*
  2. * Copyright (C) 2019 Intel Corporation. All rights reserved.
  3. * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. */
  5. #include "bh_platform.h"
  6. #if WASM_ENABLE_INTERP != 0
  7. #include "../interpreter/wasm_runtime.h"
  8. #endif
  9. #if WASM_ENABLE_AOT != 0
  10. #include "../aot/aot_runtime.h"
  11. #endif
  12. #if WASM_ENABLE_THREAD_MGR != 0
  13. #include "../libraries/thread-mgr/thread_manager.h"
  14. #endif
  15. static void
  16. set_error_buf(char *error_buf, uint32 error_buf_size, const char *string)
  17. {
  18. if (error_buf != NULL)
  19. snprintf(error_buf, error_buf_size, "%s", string);
  20. }
  21. static void *
  22. runtime_malloc(uint64 size, WASMModuleInstanceCommon *module_inst,
  23. char *error_buf, uint32 error_buf_size)
  24. {
  25. void *mem;
  26. if (size >= UINT32_MAX || !(mem = wasm_runtime_malloc((uint32)size))) {
  27. if (module_inst != NULL) {
  28. wasm_runtime_set_exception(module_inst, "allocate memory failed");
  29. }
  30. else if (error_buf != NULL) {
  31. set_error_buf(error_buf, error_buf_size, "allocate memory failed");
  32. }
  33. return NULL;
  34. }
  35. memset(mem, 0, (uint32)size);
  36. return mem;
  37. }
  38. static union {
  39. int a;
  40. char b;
  41. } __ue = { .a = 1 };
  42. #define is_little_endian() (__ue.b == 1)
  43. /**
  44. * Implementation of wasm_application_execute_main()
  45. */
  46. static bool
  47. check_main_func_type(const WASMType *type)
  48. {
  49. if (!(type->param_count == 0 || type->param_count == 2)
  50. || type->result_count > 1) {
  51. LOG_ERROR(
  52. "WASM execute application failed: invalid main function type.\n");
  53. return false;
  54. }
  55. if (type->param_count == 2
  56. && !(type->types[0] == VALUE_TYPE_I32
  57. && type->types[1] == VALUE_TYPE_I32)) {
  58. LOG_ERROR(
  59. "WASM execute application failed: invalid main function type.\n");
  60. return false;
  61. }
  62. if (type->result_count
  63. && type->types[type->param_count] != VALUE_TYPE_I32) {
  64. LOG_ERROR(
  65. "WASM execute application failed: invalid main function type.\n");
  66. return false;
  67. }
  68. return true;
  69. }
  70. static bool
  71. execute_main(WASMModuleInstanceCommon *module_inst, int32 argc, char *argv[])
  72. {
  73. WASMFunctionInstanceCommon *func;
  74. WASMType *func_type = NULL;
  75. WASMExecEnv *exec_env = NULL;
  76. uint32 argc1 = 0, argv1[2] = { 0 };
  77. uint32 total_argv_size = 0;
  78. uint64 total_size;
  79. uint32 argv_buf_offset = 0;
  80. int32 i;
  81. char *argv_buf, *p, *p_end;
  82. uint32 *argv_offsets, module_type;
  83. bool ret, is_import_func = true;
  84. exec_env = wasm_runtime_get_exec_env_singleton(module_inst);
  85. if (!exec_env) {
  86. wasm_runtime_set_exception(module_inst,
  87. "create singleton exec_env failed");
  88. return false;
  89. }
  90. #if WASM_ENABLE_LIBC_WASI != 0
  91. /* In wasi mode, we should call the function named "_start"
  92. which initializes the wasi envrionment and then calls
  93. the actual main function. Directly calling main function
  94. may cause exception thrown. */
  95. if ((func = wasm_runtime_lookup_wasi_start_function(module_inst))) {
  96. return wasm_runtime_call_wasm(exec_env, func, 0, NULL);
  97. }
  98. #endif /* end of WASM_ENABLE_LIBC_WASI */
  99. if (!(func = wasm_runtime_lookup_function(module_inst, "main", NULL))
  100. && !(func = wasm_runtime_lookup_function(module_inst,
  101. "__main_argc_argv", NULL))
  102. && !(func = wasm_runtime_lookup_function(module_inst, "_main", NULL))) {
  103. #if WASM_ENABLE_LIBC_WASI != 0
  104. wasm_runtime_set_exception(
  105. module_inst, "lookup the entry point symbol (like _start, main, "
  106. "_main, __main_argc_argv) failed");
  107. #else
  108. wasm_runtime_set_exception(module_inst,
  109. "lookup the entry point symbol (like main, "
  110. "_main, __main_argc_argv) failed");
  111. #endif
  112. return false;
  113. }
  114. #if WASM_ENABLE_INTERP != 0
  115. if (module_inst->module_type == Wasm_Module_Bytecode) {
  116. is_import_func = ((WASMFunctionInstance *)func)->is_import_func;
  117. }
  118. #endif
  119. #if WASM_ENABLE_AOT != 0
  120. if (module_inst->module_type == Wasm_Module_AoT) {
  121. is_import_func = ((AOTFunctionInstance *)func)->is_import_func;
  122. }
  123. #endif
  124. if (is_import_func) {
  125. wasm_runtime_set_exception(module_inst, "lookup main function failed");
  126. return false;
  127. }
  128. module_type = module_inst->module_type;
  129. func_type = wasm_runtime_get_function_type(func, module_type);
  130. if (!func_type) {
  131. LOG_ERROR("invalid module instance type");
  132. return false;
  133. }
  134. if (!check_main_func_type(func_type)) {
  135. wasm_runtime_set_exception(module_inst,
  136. "invalid function type of main function");
  137. return false;
  138. }
  139. if (func_type->param_count) {
  140. for (i = 0; i < argc; i++)
  141. total_argv_size += (uint32)(strlen(argv[i]) + 1);
  142. total_argv_size = align_uint(total_argv_size, 4);
  143. total_size = (uint64)total_argv_size + sizeof(int32) * (uint64)argc;
  144. if (total_size >= UINT32_MAX
  145. || !(argv_buf_offset = wasm_runtime_module_malloc(
  146. module_inst, (uint32)total_size, (void **)&argv_buf))) {
  147. wasm_runtime_set_exception(module_inst, "allocate memory failed");
  148. return false;
  149. }
  150. p = argv_buf;
  151. argv_offsets = (uint32 *)(p + total_argv_size);
  152. p_end = p + total_size;
  153. for (i = 0; i < argc; i++) {
  154. bh_memcpy_s(p, (uint32)(p_end - p), argv[i],
  155. (uint32)(strlen(argv[i]) + 1));
  156. argv_offsets[i] = argv_buf_offset + (uint32)(p - argv_buf);
  157. p += strlen(argv[i]) + 1;
  158. }
  159. argc1 = 2;
  160. argv1[0] = (uint32)argc;
  161. argv1[1] =
  162. (uint32)wasm_runtime_addr_native_to_app(module_inst, argv_offsets);
  163. }
  164. ret = wasm_runtime_call_wasm(exec_env, func, argc1, argv1);
  165. if (ret && func_type->result_count > 0 && argc > 0 && argv)
  166. /* copy the return value */
  167. *(int *)argv = (int)argv1[0];
  168. if (argv_buf_offset)
  169. wasm_runtime_module_free(module_inst, argv_buf_offset);
  170. return ret;
  171. }
  172. bool
  173. wasm_application_execute_main(WASMModuleInstanceCommon *module_inst, int32 argc,
  174. char *argv[])
  175. {
  176. bool ret;
  177. #if WASM_ENABLE_THREAD_MGR != 0
  178. WASMCluster *cluster;
  179. #endif
  180. #if WASM_ENABLE_THREAD_MGR != 0 || WASM_ENABLE_MEMORY_PROFILING != 0
  181. WASMExecEnv *exec_env;
  182. #endif
  183. ret = execute_main(module_inst, argc, argv);
  184. #if WASM_ENABLE_THREAD_MGR != 0
  185. exec_env = wasm_runtime_get_exec_env_singleton(module_inst);
  186. if (exec_env && (cluster = wasm_exec_env_get_cluster(exec_env))) {
  187. wasm_cluster_wait_for_all_except_self(cluster, exec_env);
  188. }
  189. #endif
  190. #if WASM_ENABLE_MEMORY_PROFILING != 0
  191. exec_env = wasm_runtime_get_exec_env_singleton(module_inst);
  192. if (exec_env) {
  193. wasm_runtime_dump_mem_consumption(exec_env);
  194. }
  195. #endif
  196. #if WASM_ENABLE_PERF_PROFILING != 0
  197. wasm_runtime_dump_perf_profiling(module_inst);
  198. #endif
  199. return (ret && !wasm_runtime_get_exception(module_inst)) ? true : false;
  200. }
  201. /**
  202. * Implementation of wasm_application_execute_func()
  203. */
  204. union ieee754_float {
  205. float f;
  206. /* This is the IEEE 754 single-precision format. */
  207. union {
  208. struct {
  209. unsigned int negative : 1;
  210. unsigned int exponent : 8;
  211. unsigned int mantissa : 23;
  212. } ieee_big_endian;
  213. struct {
  214. unsigned int mantissa : 23;
  215. unsigned int exponent : 8;
  216. unsigned int negative : 1;
  217. } ieee_little_endian;
  218. } ieee;
  219. };
  220. union ieee754_double {
  221. double d;
  222. /* This is the IEEE 754 double-precision format. */
  223. union {
  224. struct {
  225. unsigned int negative : 1;
  226. unsigned int exponent : 11;
  227. /* Together these comprise the mantissa. */
  228. unsigned int mantissa0 : 20;
  229. unsigned int mantissa1 : 32;
  230. } ieee_big_endian;
  231. struct {
  232. /* Together these comprise the mantissa. */
  233. unsigned int mantissa1 : 32;
  234. unsigned int mantissa0 : 20;
  235. unsigned int exponent : 11;
  236. unsigned int negative : 1;
  237. } ieee_little_endian;
  238. } ieee;
  239. };
  240. static bool
  241. execute_func(WASMModuleInstanceCommon *module_inst, const char *name,
  242. int32 argc, char *argv[])
  243. {
  244. WASMFunctionInstanceCommon *target_func;
  245. WASMType *type = NULL;
  246. WASMExecEnv *exec_env = NULL;
  247. uint32 argc1, *argv1 = NULL, cell_num = 0, j, k = 0;
  248. #if WASM_ENABLE_REF_TYPES != 0
  249. uint32 param_size_in_double_world = 0, result_size_in_double_world = 0;
  250. #endif
  251. int32 i, p, module_type;
  252. uint64 total_size;
  253. const char *exception;
  254. char buf[128];
  255. bh_assert(argc >= 0);
  256. LOG_DEBUG("call a function \"%s\" with %d arguments", name, argc);
  257. if (!(target_func =
  258. wasm_runtime_lookup_function(module_inst, name, NULL))) {
  259. snprintf(buf, sizeof(buf), "lookup function %s failed", name);
  260. wasm_runtime_set_exception(module_inst, buf);
  261. goto fail;
  262. }
  263. module_type = module_inst->module_type;
  264. type = wasm_runtime_get_function_type(target_func, module_type);
  265. if (!type) {
  266. LOG_ERROR("invalid module instance type");
  267. return false;
  268. }
  269. if (type->param_count != (uint32)argc) {
  270. wasm_runtime_set_exception(module_inst, "invalid input argument count");
  271. goto fail;
  272. }
  273. #if WASM_ENABLE_REF_TYPES != 0
  274. for (i = 0; i < type->param_count; i++) {
  275. param_size_in_double_world +=
  276. wasm_value_type_cell_num_outside(type->types[i]);
  277. }
  278. for (i = 0; i < type->result_count; i++) {
  279. result_size_in_double_world += wasm_value_type_cell_num_outside(
  280. type->types[type->param_count + i]);
  281. }
  282. argc1 = param_size_in_double_world;
  283. cell_num = (param_size_in_double_world >= result_size_in_double_world)
  284. ? param_size_in_double_world
  285. : result_size_in_double_world;
  286. #else
  287. argc1 = type->param_cell_num;
  288. cell_num = (argc1 > type->ret_cell_num) ? argc1 : type->ret_cell_num;
  289. #endif
  290. total_size = sizeof(uint32) * (uint64)(cell_num > 2 ? cell_num : 2);
  291. if ((!(argv1 = runtime_malloc((uint32)total_size, module_inst, NULL, 0)))) {
  292. goto fail;
  293. }
  294. /* Parse arguments */
  295. for (i = 0, p = 0; i < argc; i++) {
  296. char *endptr = NULL;
  297. bh_assert(argv[i] != NULL);
  298. if (argv[i][0] == '\0') {
  299. snprintf(buf, sizeof(buf), "invalid input argument %" PRId32, i);
  300. wasm_runtime_set_exception(module_inst, buf);
  301. goto fail;
  302. }
  303. switch (type->types[i]) {
  304. case VALUE_TYPE_I32:
  305. argv1[p++] = (uint32)strtoul(argv[i], &endptr, 0);
  306. break;
  307. case VALUE_TYPE_I64:
  308. {
  309. union {
  310. uint64 val;
  311. uint32 parts[2];
  312. } u;
  313. u.val = strtoull(argv[i], &endptr, 0);
  314. argv1[p++] = u.parts[0];
  315. argv1[p++] = u.parts[1];
  316. break;
  317. }
  318. case VALUE_TYPE_F32:
  319. {
  320. float32 f32 = strtof(argv[i], &endptr);
  321. if (isnan(f32)) {
  322. if (argv[i][0] == '-') {
  323. union ieee754_float u;
  324. u.f = f32;
  325. if (is_little_endian())
  326. u.ieee.ieee_little_endian.negative = 1;
  327. else
  328. u.ieee.ieee_big_endian.negative = 1;
  329. bh_memcpy_s(&f32, sizeof(float), &u.f, sizeof(float));
  330. }
  331. if (endptr[0] == ':') {
  332. uint32 sig;
  333. union ieee754_float u;
  334. sig = (uint32)strtoul(endptr + 1, &endptr, 0);
  335. u.f = f32;
  336. if (is_little_endian())
  337. u.ieee.ieee_little_endian.mantissa = sig;
  338. else
  339. u.ieee.ieee_big_endian.mantissa = sig;
  340. bh_memcpy_s(&f32, sizeof(float), &u.f, sizeof(float));
  341. }
  342. }
  343. bh_memcpy_s(&argv1[p], (uint32)total_size - p, &f32,
  344. (uint32)sizeof(float));
  345. p++;
  346. break;
  347. }
  348. case VALUE_TYPE_F64:
  349. {
  350. union {
  351. float64 val;
  352. uint32 parts[2];
  353. } u;
  354. u.val = strtod(argv[i], &endptr);
  355. if (isnan(u.val)) {
  356. if (argv[i][0] == '-') {
  357. union ieee754_double ud;
  358. ud.d = u.val;
  359. if (is_little_endian())
  360. ud.ieee.ieee_little_endian.negative = 1;
  361. else
  362. ud.ieee.ieee_big_endian.negative = 1;
  363. bh_memcpy_s(&u.val, sizeof(double), &ud.d,
  364. sizeof(double));
  365. }
  366. if (endptr[0] == ':') {
  367. uint64 sig;
  368. union ieee754_double ud;
  369. sig = strtoull(endptr + 1, &endptr, 0);
  370. ud.d = u.val;
  371. if (is_little_endian()) {
  372. ud.ieee.ieee_little_endian.mantissa0 = sig >> 32;
  373. ud.ieee.ieee_little_endian.mantissa1 = (uint32)sig;
  374. }
  375. else {
  376. ud.ieee.ieee_big_endian.mantissa0 = sig >> 32;
  377. ud.ieee.ieee_big_endian.mantissa1 = (uint32)sig;
  378. }
  379. bh_memcpy_s(&u.val, sizeof(double), &ud.d,
  380. sizeof(double));
  381. }
  382. }
  383. argv1[p++] = u.parts[0];
  384. argv1[p++] = u.parts[1];
  385. break;
  386. }
  387. #if WASM_ENABLE_SIMD != 0
  388. case VALUE_TYPE_V128:
  389. {
  390. /* it likes 0x123\0x234 or 123\234 */
  391. /* retrive first i64 */
  392. *(uint64 *)(argv1 + p) = strtoull(argv[i], &endptr, 0);
  393. /* skip \ */
  394. endptr++;
  395. /* retrive second i64 */
  396. *(uint64 *)(argv1 + p + 2) = strtoull(endptr, &endptr, 0);
  397. p += 4;
  398. break;
  399. }
  400. #endif /* WASM_ENABLE_SIMD != 0 */
  401. #if WASM_ENABLE_REF_TYPES != 0
  402. case VALUE_TYPE_FUNCREF:
  403. {
  404. if (strncasecmp(argv[i], "null", 4) == 0) {
  405. argv1[p++] = (uint32)-1;
  406. }
  407. else {
  408. argv1[p++] = (uint32)strtoul(argv[i], &endptr, 0);
  409. }
  410. break;
  411. }
  412. case VALUE_TYPE_EXTERNREF:
  413. {
  414. #if UINTPTR_MAX == UINT32_MAX
  415. if (strncasecmp(argv[i], "null", 4) == 0) {
  416. argv1[p++] = (uint32)-1;
  417. }
  418. else {
  419. argv1[p++] = strtoul(argv[i], &endptr, 0);
  420. }
  421. #else
  422. union {
  423. uintptr_t val;
  424. uint32 parts[2];
  425. } u;
  426. if (strncasecmp(argv[i], "null", 4) == 0) {
  427. u.val = (uintptr_t)-1LL;
  428. }
  429. else {
  430. u.val = strtoull(argv[i], &endptr, 0);
  431. }
  432. argv1[p++] = u.parts[0];
  433. argv1[p++] = u.parts[1];
  434. #endif
  435. break;
  436. }
  437. #endif /* WASM_ENABLE_REF_TYPES */
  438. default:
  439. bh_assert(0);
  440. break;
  441. }
  442. if (endptr && *endptr != '\0' && *endptr != '_') {
  443. snprintf(buf, sizeof(buf), "invalid input argument %" PRId32 ": %s",
  444. i, argv[i]);
  445. wasm_runtime_set_exception(module_inst, buf);
  446. goto fail;
  447. }
  448. }
  449. wasm_runtime_set_exception(module_inst, NULL);
  450. #if WASM_ENABLE_REF_TYPES == 0
  451. bh_assert(p == (int32)argc1);
  452. #endif
  453. exec_env = wasm_runtime_get_exec_env_singleton(module_inst);
  454. if (!exec_env) {
  455. wasm_runtime_set_exception(module_inst,
  456. "create singleton exec_env failed");
  457. goto fail;
  458. }
  459. if (!wasm_runtime_call_wasm(exec_env, target_func, argc1, argv1)) {
  460. goto fail;
  461. }
  462. /* print return value */
  463. for (j = 0; j < type->result_count; j++) {
  464. switch (type->types[type->param_count + j]) {
  465. case VALUE_TYPE_I32:
  466. {
  467. os_printf("0x%" PRIx32 ":i32", argv1[k]);
  468. k++;
  469. break;
  470. }
  471. case VALUE_TYPE_I64:
  472. {
  473. union {
  474. uint64 val;
  475. uint32 parts[2];
  476. } u;
  477. u.parts[0] = argv1[k];
  478. u.parts[1] = argv1[k + 1];
  479. k += 2;
  480. os_printf("0x%" PRIx64 ":i64", u.val);
  481. break;
  482. }
  483. case VALUE_TYPE_F32:
  484. {
  485. os_printf("%.7g:f32", *(float32 *)(argv1 + k));
  486. k++;
  487. break;
  488. }
  489. case VALUE_TYPE_F64:
  490. {
  491. union {
  492. float64 val;
  493. uint32 parts[2];
  494. } u;
  495. u.parts[0] = argv1[k];
  496. u.parts[1] = argv1[k + 1];
  497. k += 2;
  498. os_printf("%.7g:f64", u.val);
  499. break;
  500. }
  501. #if WASM_ENABLE_REF_TYPES != 0
  502. case VALUE_TYPE_FUNCREF:
  503. {
  504. if (argv1[k] != NULL_REF)
  505. os_printf("%u:ref.func", argv1[k]);
  506. else
  507. os_printf("func:ref.null");
  508. k++;
  509. break;
  510. }
  511. case VALUE_TYPE_EXTERNREF:
  512. {
  513. #if UINTPTR_MAX == UINT32_MAX
  514. if (argv1[k] != 0 && argv1[k] != (uint32)-1)
  515. os_printf("%p:ref.extern", (void *)argv1[k]);
  516. else
  517. os_printf("extern:ref.null");
  518. k++;
  519. #else
  520. union {
  521. uintptr_t val;
  522. uint32 parts[2];
  523. } u;
  524. u.parts[0] = argv1[k];
  525. u.parts[1] = argv1[k + 1];
  526. k += 2;
  527. if (u.val && u.val != (uintptr_t)-1LL)
  528. os_printf("%p:ref.extern", (void *)u.val);
  529. else
  530. os_printf("extern:ref.null");
  531. #endif
  532. break;
  533. }
  534. #endif
  535. #if WASM_ENABLE_SIMD != 0
  536. case VALUE_TYPE_V128:
  537. {
  538. uint64 *v = (uint64 *)(argv1 + k);
  539. os_printf("<0x%016" PRIx64 " 0x%016" PRIx64 ">:v128", *v,
  540. *(v + 1));
  541. k += 4;
  542. break;
  543. }
  544. #endif /* WASM_ENABLE_SIMD != 0 */
  545. default:
  546. bh_assert(0);
  547. break;
  548. }
  549. if (j < (uint32)(type->result_count - 1))
  550. os_printf(",");
  551. }
  552. os_printf("\n");
  553. wasm_runtime_free(argv1);
  554. return true;
  555. fail:
  556. if (argv1)
  557. wasm_runtime_free(argv1);
  558. exception = wasm_runtime_get_exception(module_inst);
  559. bh_assert(exception);
  560. os_printf("%s\n", exception);
  561. return false;
  562. }
  563. bool
  564. wasm_application_execute_func(WASMModuleInstanceCommon *module_inst,
  565. const char *name, int32 argc, char *argv[])
  566. {
  567. bool ret;
  568. #if WASM_ENABLE_THREAD_MGR != 0
  569. WASMCluster *cluster;
  570. #endif
  571. #if WASM_ENABLE_THREAD_MGR != 0 || WASM_ENABLE_MEMORY_PROFILING != 0
  572. WASMExecEnv *exec_env;
  573. #endif
  574. ret = execute_func(module_inst, name, argc, argv);
  575. #if WASM_ENABLE_THREAD_MGR != 0
  576. exec_env = wasm_runtime_get_exec_env_singleton(module_inst);
  577. if (exec_env && (cluster = wasm_exec_env_get_cluster(exec_env))) {
  578. wasm_cluster_wait_for_all_except_self(cluster, exec_env);
  579. }
  580. #endif
  581. #if WASM_ENABLE_MEMORY_PROFILING != 0
  582. exec_env = wasm_runtime_get_exec_env_singleton(module_inst);
  583. if (exec_env) {
  584. wasm_runtime_dump_mem_consumption(exec_env);
  585. }
  586. #endif
  587. #if WASM_ENABLE_PERF_PROFILING != 0
  588. wasm_runtime_dump_perf_profiling(module_inst);
  589. #endif
  590. return (ret && !wasm_runtime_get_exception(module_inst)) ? true : false;
  591. }