bytecodealliance / wasm-micro-runtime

WebAssembly Micro Runtime (WAMR)
Apache License 2.0
4.94k stars 623 forks source link

AOT/JIT stack frame enhancement #2506

Open wenyongh opened 1 year ago

wenyongh commented 1 year ago

AOT stack frame enhancement

Motivation

Currently LLVM AOT/JIT doesn’t use the stack frame like interpreter/fast-jit except in the feature of dumping call stack and performance profiling, since the operations of the function local variables and stack operators have been optimized to the operations of registers and native stack by the LLVM codegen. The stack frame data is very simple in dump-call-stack and perf-profiling features, only several fields are stored in the stack frame, including func_index, time_started, total_exec_time and total_exec_cnt. There may be some scenarios requiring to create the stack frame data like interpreter and commit data to it when needed:

The data to commit to the stack frame

It may include:

Some functionalities to support

And also we should support the current dump-call-stack and perf-profiling features.

Extend the AOTFrame structure

Add some fields in it, including ip, sp, frame_ref, lp and so on. And make the offset of these fields fixed, so the compiler can easily calculate the offsets of them in the running status.

wenyongh commented 1 year ago

https://github.com/bytecodealliance/wasm-micro-runtime/pull/2350

tamaroning commented 5 months ago

@wenyongh Hello, what is the current status of this issue? It seems that the dev branch has not merged to main yet. I am interested in using AOT stack frames to checkpoint/restore wasm runtimes.

wenyongh commented 5 months ago

Hi, the AOT stack frame feature is already supported in the main branch: it was merged into branch dev/gc_refactor, and the latter was merged into main. Please refer to: https://github.com/bytecodealliance/wasm-micro-runtime/blob/main/doc/build_wamr.md#enable-aot-stack-frame-feature

And for checkpoint/restore feature, maybe you can refer to this PR: https://github.com/bytecodealliance/wasm-micro-runtime/pull/3289

tamaroning commented 5 months ago

Thank you for your swift response and sharing useful information:)