mirror of
https://github.com/bytecodealliance/wasm-micro-runtime.git
synced 2025-05-08 20:56:13 +00:00
Fix issue of Multi-tier JIT (#2056)
This commit is contained in:
parent
b0f614d77a
commit
605c8b07dc
|
@ -602,6 +602,9 @@ struct WASMModule {
|
||||||
since no need to enable llvm jit compilation for Mode_Interp and
|
since no need to enable llvm jit compilation for Mode_Interp and
|
||||||
Mode_Fast_JIT, so as to improve performance for them */
|
Mode_Fast_JIT, so as to improve performance for them */
|
||||||
bool enable_llvm_jit_compilation;
|
bool enable_llvm_jit_compilation;
|
||||||
|
/* The count of groups which finish compiling the fast jit
|
||||||
|
functions in that group */
|
||||||
|
uint32 fast_jit_ready_groups;
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -3182,6 +3182,11 @@ orcjit_thread_callback(void *arg)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#if WASM_ENABLE_JIT != 0 && WASM_ENABLE_LAZY_JIT != 0
|
||||||
|
os_mutex_lock(&module->tierup_wait_lock);
|
||||||
|
module->fast_jit_ready_groups++;
|
||||||
|
os_mutex_unlock(&module->tierup_wait_lock);
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if WASM_ENABLE_FAST_JIT != 0 && WASM_ENABLE_JIT != 0 \
|
#if WASM_ENABLE_FAST_JIT != 0 && WASM_ENABLE_JIT != 0 \
|
||||||
|
@ -3209,9 +3214,11 @@ orcjit_thread_callback(void *arg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Wait until init_llvm_jit_functions_stage2 finishes */
|
/* Wait until init_llvm_jit_functions_stage2 finishes and all
|
||||||
|
fast jit functions are compiled */
|
||||||
os_mutex_lock(&module->tierup_wait_lock);
|
os_mutex_lock(&module->tierup_wait_lock);
|
||||||
while (!(module->llvm_jit_inited && module->enable_llvm_jit_compilation)) {
|
while (!(module->llvm_jit_inited && module->enable_llvm_jit_compilation
|
||||||
|
&& module->fast_jit_ready_groups >= group_stride)) {
|
||||||
os_cond_reltimedwait(&module->tierup_wait_cond,
|
os_cond_reltimedwait(&module->tierup_wait_cond,
|
||||||
&module->tierup_wait_lock, 10000);
|
&module->tierup_wait_lock, 10000);
|
||||||
if (module->orcjit_stop_compiling) {
|
if (module->orcjit_stop_compiling) {
|
||||||
|
|
|
@ -2025,6 +2025,11 @@ orcjit_thread_callback(void *arg)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#if WASM_ENABLE_JIT != 0 && WASM_ENABLE_LAZY_JIT != 0
|
||||||
|
os_mutex_lock(&module->tierup_wait_lock);
|
||||||
|
module->fast_jit_ready_groups++;
|
||||||
|
os_mutex_unlock(&module->tierup_wait_lock);
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if WASM_ENABLE_FAST_JIT != 0 && WASM_ENABLE_JIT != 0 \
|
#if WASM_ENABLE_FAST_JIT != 0 && WASM_ENABLE_JIT != 0 \
|
||||||
|
@ -2052,9 +2057,11 @@ orcjit_thread_callback(void *arg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Wait until init_llvm_jit_functions_stage2 finishes */
|
/* Wait until init_llvm_jit_functions_stage2 finishes and all
|
||||||
|
fast jit functions are compiled */
|
||||||
os_mutex_lock(&module->tierup_wait_lock);
|
os_mutex_lock(&module->tierup_wait_lock);
|
||||||
while (!(module->llvm_jit_inited && module->enable_llvm_jit_compilation)) {
|
while (!(module->llvm_jit_inited && module->enable_llvm_jit_compilation
|
||||||
|
&& module->fast_jit_ready_groups >= group_stride)) {
|
||||||
os_cond_reltimedwait(&module->tierup_wait_cond,
|
os_cond_reltimedwait(&module->tierup_wait_cond,
|
||||||
&module->tierup_wait_lock, 10000);
|
&module->tierup_wait_lock, 10000);
|
||||||
if (module->orcjit_stop_compiling) {
|
if (module->orcjit_stop_compiling) {
|
||||||
|
|
|
@ -1489,7 +1489,7 @@ set_running_mode(WASMModuleInstance *module_inst, RunningMode running_mode,
|
||||||
os_mutex_lock(&module->tierup_wait_lock);
|
os_mutex_lock(&module->tierup_wait_lock);
|
||||||
while (!module->llvm_jit_inited) {
|
while (!module->llvm_jit_inited) {
|
||||||
os_cond_reltimedwait(&module->tierup_wait_cond,
|
os_cond_reltimedwait(&module->tierup_wait_cond,
|
||||||
&module->tierup_wait_lock, 10);
|
&module->tierup_wait_lock, 10000);
|
||||||
if (module->orcjit_stop_compiling) {
|
if (module->orcjit_stop_compiling) {
|
||||||
/* init_llvm_jit_functions_stage2 failed */
|
/* init_llvm_jit_functions_stage2 failed */
|
||||||
os_mutex_unlock(&module->tierup_wait_lock);
|
os_mutex_unlock(&module->tierup_wait_lock);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user