From ca4b60b3351431ffc7052735331462ddc8a01bee Mon Sep 17 00:00:00 2001 From: Wenyong Huang Date: Mon, 9 May 2022 15:19:55 +0800 Subject: [PATCH] Auto dump mem/perf profiling in execute_main/execute_func (#1157) Automatically dump memory/performance profiling data in wasm_application_execute_main and wasm_application_execute_func when the related feature is enabled. And remove unused aot_compile_wasm_file func declaration in aot_compiler.h. --- core/iwasm/common/wasm_application.c | 26 ++++++++++++++++++++++++++ core/iwasm/compilation/aot_compiler.h | 5 ----- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/core/iwasm/common/wasm_application.c b/core/iwasm/common/wasm_application.c index 9155625d1..a139d1f4e 100644 --- a/core/iwasm/common/wasm_application.c +++ b/core/iwasm/common/wasm_application.c @@ -212,6 +212,8 @@ wasm_application_execute_main(WASMModuleInstanceCommon *module_inst, int32 argc, bool ret; #if WASM_ENABLE_THREAD_MGR != 0 WASMCluster *cluster; +#endif +#if WASM_ENABLE_THREAD_MGR != 0 || WASM_ENABLE_MEMORY_PROFILING != 0 WASMExecEnv *exec_env; #endif @@ -224,6 +226,17 @@ wasm_application_execute_main(WASMModuleInstanceCommon *module_inst, int32 argc, } #endif +#if WASM_ENABLE_MEMORY_PROFILING != 0 + exec_env = wasm_runtime_get_exec_env_singleton(module_inst); + if (exec_env) { + wasm_runtime_dump_mem_consumption(exec_env); + } +#endif + +#if WASM_ENABLE_PERF_PROFILING != 0 + wasm_runtime_dump_perf_profiling(module_inst); +#endif + return (ret && !wasm_runtime_get_exception(module_inst)) ? true : false; } @@ -721,6 +734,8 @@ wasm_application_execute_func(WASMModuleInstanceCommon *module_inst, bool ret; #if WASM_ENABLE_THREAD_MGR != 0 WASMCluster *cluster; +#endif +#if WASM_ENABLE_THREAD_MGR != 0 || WASM_ENABLE_MEMORY_PROFILING != 0 WASMExecEnv *exec_env; #endif @@ -733,5 +748,16 @@ wasm_application_execute_func(WASMModuleInstanceCommon *module_inst, } #endif +#if WASM_ENABLE_MEMORY_PROFILING != 0 + exec_env = wasm_runtime_get_exec_env_singleton(module_inst); + if (exec_env) { + wasm_runtime_dump_mem_consumption(exec_env); + } +#endif + +#if WAMR_ENABLE_PERF_PROFILING != 0 + wasm_runtime_dump_perf_profiling(module_inst); +#endif + return (ret && !wasm_runtime_get_exception(module_inst)) ? true : false; } diff --git a/core/iwasm/compilation/aot_compiler.h b/core/iwasm/compilation/aot_compiler.h index 8637b6d82..4efd1bfb0 100644 --- a/core/iwasm/compilation/aot_compiler.h +++ b/core/iwasm/compilation/aot_compiler.h @@ -371,11 +371,6 @@ aot_emit_aot_file_buf(AOTCompContext *comp_ctx, AOTCompData *comp_data, bool aot_emit_object_file(AOTCompContext *comp_ctx, char *file_name); -uint8 * -aot_compile_wasm_file(const uint8 *wasm_file_buf, uint32 wasm_file_size, - uint32 opt_level, uint32 size_level, char *error_buf, - uint32 error_buf_size, uint32 *p_aot_file_size); - #ifdef __cplusplus } /* end of extern "C" */ #endif