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:
@ -56,9 +56,31 @@ jit_code_cache_free(void *ptr)
|
||||
bool
|
||||
jit_pass_register_jitted_code(JitCompContext *cc)
|
||||
{
|
||||
uint32 jit_func_idx =
|
||||
cc->cur_wasm_func_idx - cc->cur_wasm_module->import_function_count;
|
||||
cc->cur_wasm_module->fast_jit_func_ptrs[jit_func_idx] =
|
||||
cc->cur_wasm_func->fast_jit_jitted_code = cc->jitted_addr_begin;
|
||||
WASMModuleInstance *instance;
|
||||
WASMModule *module = cc->cur_wasm_module;
|
||||
WASMFunction *func = cc->cur_wasm_func;
|
||||
uint32 jit_func_idx = cc->cur_wasm_func_idx - module->import_function_count;
|
||||
|
||||
#if WASM_ENABLE_FAST_JIT != 0 && WASM_ENABLE_JIT != 0 \
|
||||
&& WASM_ENABLE_LAZY_JIT != 0
|
||||
os_mutex_lock(&module->instance_list_lock);
|
||||
#endif
|
||||
|
||||
module->fast_jit_func_ptrs[jit_func_idx] = func->fast_jit_jitted_code =
|
||||
cc->jitted_addr_begin;
|
||||
|
||||
#if WASM_ENABLE_FAST_JIT != 0 && WASM_ENABLE_JIT != 0 \
|
||||
&& WASM_ENABLE_LAZY_JIT != 0
|
||||
instance = module->instance_list;
|
||||
while (instance) {
|
||||
if (instance->e->running_mode == Mode_Fast_JIT)
|
||||
instance->fast_jit_func_ptrs[jit_func_idx] = cc->jitted_addr_begin;
|
||||
instance = instance->e->next;
|
||||
}
|
||||
|
||||
os_mutex_unlock(&module->instance_list_lock);
|
||||
#else
|
||||
(void)instance;
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -254,6 +254,8 @@ jit_compiler_set_call_to_fast_jit(WASMModule *module, uint32 func_idx)
|
||||
|
||||
func_ptr = jit_codegen_compile_call_to_fast_jit(module, func_idx);
|
||||
if (func_ptr) {
|
||||
uint32 i = func_idx - module->import_function_count;
|
||||
module->functions[i]->call_to_fast_jit_from_llvm_jit = func_ptr;
|
||||
jit_compiler_set_llvm_jit_func_ptr(module, func_idx, func_ptr);
|
||||
}
|
||||
|
||||
@ -267,12 +269,14 @@ jit_compiler_set_llvm_jit_func_ptr(WASMModule *module, uint32 func_idx,
|
||||
WASMModuleInstance *instance;
|
||||
uint32 i = func_idx - module->import_function_count;
|
||||
|
||||
module->functions[i]->llvm_jit_func_ptr = module->func_ptrs[i] = func_ptr;
|
||||
|
||||
os_mutex_lock(&module->instance_list_lock);
|
||||
|
||||
module->func_ptrs[i] = func_ptr;
|
||||
|
||||
instance = module->instance_list;
|
||||
while (instance) {
|
||||
instance->func_ptrs[func_idx] = func_ptr;
|
||||
if (instance->e->running_mode == Mode_Multi_Tier_JIT)
|
||||
instance->func_ptrs[func_idx] = func_ptr;
|
||||
instance = instance->e->next;
|
||||
}
|
||||
os_mutex_unlock(&module->instance_list_lock);
|
||||
|
||||
Reference in New Issue
Block a user