mirror of
https://github.com/bytecodealliance/wasm-micro-runtime.git
synced 2025-05-30 21:47:24 +00:00
Reset JitCompContext before compiling each function (#1062)
Or else, all secondary IRs and machine code will be appended into the content of first function
This commit is contained in:
parent
dc0e28b790
commit
7de695fb3a
|
@ -152,42 +152,15 @@ jit_compiler_compile(WASMModule *module, uint32 func_idx)
|
||||||
bool
|
bool
|
||||||
jit_compiler_compile_all(WASMModule *module)
|
jit_compiler_compile_all(WASMModule *module)
|
||||||
{
|
{
|
||||||
JitCompContext *cc;
|
|
||||||
char *last_error;
|
|
||||||
bool ret = true;
|
|
||||||
uint32 i;
|
uint32 i;
|
||||||
|
|
||||||
/* Initialize compilation context. */
|
|
||||||
if (!(cc = jit_calloc(sizeof(*cc))))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (!jit_cc_init(cc, 64)) {
|
|
||||||
jit_free(cc);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < module->function_count; i++) {
|
for (i = 0; i < module->function_count; i++) {
|
||||||
cc->cur_wasm_module = module;
|
if (!jit_compiler_compile(module, i)) {
|
||||||
cc->cur_wasm_func = module->functions[i];
|
return false;
|
||||||
cc->cur_wasm_func_idx = i;
|
|
||||||
cc->mem_space_unchanged = (!cc->cur_wasm_func->has_op_memory_grow
|
|
||||||
&& !cc->cur_wasm_func->has_op_func_call)
|
|
||||||
|| (!module->possible_memory_grow);
|
|
||||||
|
|
||||||
/* Apply compiler passes. */
|
|
||||||
if (!apply_compiler_passes(cc) || jit_get_last_error(cc)) {
|
|
||||||
last_error = jit_get_last_error(cc);
|
|
||||||
os_printf("fast jit compilation failed: %s\n",
|
|
||||||
last_error ? last_error : "unknown error");
|
|
||||||
ret = false;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Delete the compilation context. */
|
return true;
|
||||||
jit_cc_delete(cc);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
|
Loading…
Reference in New Issue
Block a user