Enable running mode control for runtime and module instance (#1923)
Enable setting running mode when executing a wasm bytecode file - Four running modes are supported: interpreter, fast-jit, llvm-jit and multi-tier-jit - Add APIs to set/get the default running mode of the runtime - Add APIs to set/get the running mode of a wasm module instance - Add running mode options for iwasm command line tool And add size/opt level options for LLVM JIT
This commit is contained in:
@ -2989,6 +2989,7 @@ static bool
|
||||
init_llvm_jit_functions_stage1(WASMModule *module, char *error_buf,
|
||||
uint32 error_buf_size)
|
||||
{
|
||||
LLVMJITOptions llvm_jit_options = wasm_runtime_get_llvm_jit_options();
|
||||
AOTCompOption option = { 0 };
|
||||
char *aot_last_error;
|
||||
uint64 size;
|
||||
@ -3027,8 +3028,11 @@ init_llvm_jit_functions_stage1(WASMModule *module, char *error_buf,
|
||||
}
|
||||
|
||||
option.is_jit_mode = true;
|
||||
option.opt_level = 3;
|
||||
option.size_level = 3;
|
||||
|
||||
llvm_jit_options = wasm_runtime_get_llvm_jit_options();
|
||||
option.opt_level = llvm_jit_options.opt_level;
|
||||
option.size_level = llvm_jit_options.size_level;
|
||||
|
||||
#if WASM_ENABLE_BULK_MEMORY != 0
|
||||
option.enable_bulk_memory = true;
|
||||
#endif
|
||||
@ -3112,6 +3116,8 @@ init_llvm_jit_functions_stage2(WASMModule *module, char *error_buf,
|
||||
module->func_ptrs[i] = (void *)func_addr;
|
||||
|
||||
#if WASM_ENABLE_FAST_JIT != 0 && WASM_ENABLE_LAZY_JIT != 0
|
||||
module->functions[i]->llvm_jit_func_ptr = (void *)func_addr;
|
||||
|
||||
if (module->orcjit_stop_compiling)
|
||||
return false;
|
||||
#endif
|
||||
@ -3202,9 +3208,9 @@ orcjit_thread_callback(void *arg)
|
||||
|
||||
/* Wait until init_llvm_jit_functions_stage2 finishes */
|
||||
os_mutex_lock(&module->tierup_wait_lock);
|
||||
while (!module->llvm_jit_inited) {
|
||||
while (!(module->llvm_jit_inited && module->enable_llvm_jit_compilation)) {
|
||||
os_cond_reltimedwait(&module->tierup_wait_cond,
|
||||
&module->tierup_wait_lock, 10);
|
||||
&module->tierup_wait_lock, 10000);
|
||||
if (module->orcjit_stop_compiling) {
|
||||
/* init_llvm_jit_functions_stage2 failed */
|
||||
os_mutex_unlock(&module->tierup_wait_lock);
|
||||
@ -4300,9 +4306,9 @@ wasm_loader_unload(WASMModule *module)
|
||||
module->functions[i]->fast_jit_jitted_code);
|
||||
}
|
||||
#if WASM_ENABLE_JIT != 0 && WASM_ENABLE_LAZY_JIT != 0
|
||||
if (module->functions[i]->llvm_jit_func_ptr) {
|
||||
if (module->functions[i]->call_to_fast_jit_from_llvm_jit) {
|
||||
jit_code_cache_free(
|
||||
module->functions[i]->llvm_jit_func_ptr);
|
||||
module->functions[i]->call_to_fast_jit_from_llvm_jit);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user