Add printingAdd print time for wamrc, fix posix mmap bug time for wamrc, fixed a posix mmap bug. (#206)
Change-Id: Ib6517b8a69cf022a1a6a74efa1f98155aec143bc
This commit is contained in:
@ -727,6 +727,8 @@ aot_compile_wasm(AOTCompContext *comp_ctx)
|
||||
bool ret;
|
||||
uint32 i;
|
||||
|
||||
bh_print_time("Begin to compile WASM bytecode to LLVM IR");
|
||||
|
||||
for (i = 0; i < comp_ctx->func_ctx_count; i++)
|
||||
if (!aot_compile_func(comp_ctx, i)) {
|
||||
#if 0
|
||||
@ -744,6 +746,8 @@ aot_compile_wasm(AOTCompContext *comp_ctx)
|
||||
errno = 0;
|
||||
#endif
|
||||
|
||||
bh_print_time("Begin to verify LLVM module");
|
||||
|
||||
ret = LLVMVerifyModule(comp_ctx->module, LLVMPrintMessageAction, &msg);
|
||||
if (!ret && msg) {
|
||||
if (msg[0] != '\0') {
|
||||
@ -754,6 +758,8 @@ aot_compile_wasm(AOTCompContext *comp_ctx)
|
||||
LLVMDisposeMessage(msg);
|
||||
}
|
||||
|
||||
bh_print_time("Begin to run function optimization passes");
|
||||
|
||||
if (comp_ctx->optimize) {
|
||||
LLVMInitializeFunctionPassManager(comp_ctx->pass_mgr);
|
||||
for (i = 0; i < comp_ctx->func_ctx_count; i++)
|
||||
@ -769,6 +775,8 @@ aot_emit_llvm_file(AOTCompContext *comp_ctx, const char *file_name)
|
||||
{
|
||||
char *err = NULL;
|
||||
|
||||
bh_print_time("Begin to emit LLVM IR file");
|
||||
|
||||
if (LLVMPrintModuleToFile(comp_ctx->module, file_name, &err) != 0) {
|
||||
if (err) {
|
||||
LLVMDisposeMessage(err);
|
||||
@ -786,6 +794,8 @@ aot_emit_object_file(AOTCompContext *comp_ctx, char *file_name)
|
||||
{
|
||||
char *err = NULL;
|
||||
|
||||
bh_print_time("Begin to emit object file");
|
||||
|
||||
if (LLVMTargetMachineEmitToFile(comp_ctx->target_machine,
|
||||
comp_ctx->module,
|
||||
file_name,
|
||||
|
||||
@ -1837,6 +1837,8 @@ aot_obj_data_create(AOTCompContext *comp_ctx)
|
||||
char *err = NULL;
|
||||
AOTObjectData *obj_data;
|
||||
|
||||
bh_print_time("Begin to emit object file to buffer");
|
||||
|
||||
if (!(obj_data = wasm_runtime_malloc(sizeof(AOTObjectData)))) {
|
||||
aot_set_last_error("allocate memory failed.");
|
||||
return false;
|
||||
@ -1866,6 +1868,8 @@ aot_obj_data_create(AOTCompContext *comp_ctx)
|
||||
goto fail;
|
||||
}
|
||||
|
||||
bh_print_time("Begin to resolve object file info");
|
||||
|
||||
/* resolve target info/text/relocations/functions */
|
||||
if (!aot_resolve_target_info(comp_ctx, obj_data)
|
||||
|| !aot_resolve_text(obj_data)
|
||||
@ -1894,6 +1898,8 @@ aot_emit_aot_file(AOTCompContext *comp_ctx, AOTCompData *comp_data,
|
||||
if (!obj_data)
|
||||
return false;
|
||||
|
||||
bh_print_time("Begin to emit AOT file");
|
||||
|
||||
aot_file_size = get_aot_file_size(comp_data, obj_data);
|
||||
|
||||
if (!(buf = aot_file_buf = wasm_runtime_malloc(aot_file_size))) {
|
||||
|
||||
@ -43,7 +43,7 @@ os_mmap(void *hint, uint32 size, int prot, int flags)
|
||||
|
||||
/* try 5 times */
|
||||
for (i = 0; i < 5; i ++) {
|
||||
addr = mmap(hint, size, map_prot, map_flags, -1, 0);
|
||||
addr = mmap(hint, request_size, map_prot, map_flags, -1, 0);
|
||||
if (addr != MAP_FAILED)
|
||||
break;
|
||||
}
|
||||
|
||||
@ -52,3 +52,28 @@ bh_log(LogLevel log_level, const char *file, int line, const char *fmt, ...)
|
||||
|
||||
os_printf("\n");
|
||||
}
|
||||
|
||||
static uint32 last_time_ms = 0;
|
||||
static uint32 total_time_ms = 0;
|
||||
|
||||
void
|
||||
bh_print_time(const char *prompt)
|
||||
{
|
||||
uint32 curr_time_ms;
|
||||
|
||||
if (log_verbose_level < 3)
|
||||
return;
|
||||
|
||||
curr_time_ms = (uint32)bh_get_tick_ms();
|
||||
|
||||
if (last_time_ms == 0)
|
||||
last_time_ms = curr_time_ms;
|
||||
|
||||
total_time_ms += curr_time_ms - last_time_ms;
|
||||
|
||||
printf("%-48s time of last stage: %u ms, total time: %u ms\n",
|
||||
prompt, curr_time_ms - last_time_ms, total_time_ms);
|
||||
|
||||
last_time_ms = curr_time_ms;
|
||||
}
|
||||
|
||||
|
||||
@ -47,6 +47,9 @@ bh_log(LogLevel log_level, const char *file, int line, const char *fmt, ...);
|
||||
#define LOG_WARNING(...) bh_log(LOG_LEVEL_WARNING, NULL, 0, __VA_ARGS__)
|
||||
#define LOG_VERBOSE(...) bh_log(LOG_LEVEL_VERBOSE, NULL, 0, __VA_ARGS__)
|
||||
|
||||
void
|
||||
bh_print_time(const char *prompt);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user