Open TianlongLiang opened 1 year ago
Thats sounds to be a great thing, enhancing adaptability. But maybe there should be more options like "enabling debugging", "AOT-mode" etc.. Are there insights about the impacts?
Thats sounds to be a great thing, enhancing adaptability. But maybe there should be more options like "enabling debugging", "AOT-mode" etc.. Are there insights about the impacts?
Hi, the feature is only to control the running mode when the input is a wasm bytecode file: to run the wasm file with interpreter, fast-jit, llvm-jit or multi-tier-jit. It doesn't impact the AOT mode: if the input is AOT file, runtime always runs it with AOT mode.
For the "enabling debugging", I think if it is compiled, e.g. cmake -DWAMR_BUILD_DEBUG_INTERP
, then developer can enter the interpreter mode to enable source debugging, e.g. iwasm --interp -g=ip:port <wasm_file>
, no need to add an extra running mode.
BTW, we basically finished the coding the feature, refer to PR https://github.com/bytecodealliance/wasm-micro-runtime/pull/1890, now it is under testing. If you are interested in it, maybe you can have a try.
Currently, WAMR running mode(Classic/Fast Interpreter, Fast JIT, LLVM JIT, or Multi-tier JIT) is determined at compile time by setting C macro. There is no way to choose a different running mode at execution time, even though the related code is also compiled and available. For example, we can’t run wasm code in Interpreter mode when Fast JIT is compiled, and if we want to use Interpreter mode, we will have to compile a new iwasm.
So we plan to add general APIs(when embedding WAMR) and CLI options(when using iwasm) to allow users to control the running mode at execution time.
When embedding WAMR
Running modes definition:
APIs can control running mode in different granularity:
at runtime level:
RunningMode running_mode
forRuntimeInitArgs
so that the user can initialize the default running mode usingwasm_runtime_full_init(RuntimeInitArgs *init_args)
at module instance level:
The priority of choosing running mode:
When using iwasm
Four command line options to control the running mode of iwasm:
--interp
: run iwasm in class interpreter mode--fast-jit
: run iwasm in fast jit mode--llvm-jit
: run iwasm in llvm jit mode--multi-tier-jit
: run iwasm in multi-tier jit modeAnd two more command line options to control LLVM JIT's size and optimization level:
--llvm-jit-opt-level=n
: possible n values are 1, 2, 3. Currently, the opt level is hard coded to 3--llvm-jit-size-level=n
: possible n values are 1, 2, 3. Currently, the size level is hard coded to 3Example program/CLI usage
Example C program embedding WAMR:
Example iwasm CLI usage:
Subtasks and milestones