Skip to content

[Wasm RyuJIT] Stack Tracing #121830

@kg

Description

@kg

To be able to walk the stack in the Wasm environment we need to manually maintain a stack of the managed code that is executing as we recurse (via function calls) and return. You can see one approach to this described in NAOT-LLVM's documentation, here: https://github.com/dotnet/runtimelab/blob/feature/NativeAOT-LLVM/docs/design/coreclr/botr/nativeaot-wasm-exception-handling.md#:~:text=With%20that%20said%2C%20here%20is%20one%20way%20codegen%20could%20maintain%20the%20unwind%20index

Implementing this will require the JIT to generate a prologue at the head of every managed method to create a virtual stack frame and push it onto the stack, along with an epilogue to pop it when returning. Exception unwinding will also need to properly manipulate this stack during abnormal exits of methods to ensure they don't remain on the stack.

The current stack pointer likely needs to be passed to all managed methods as an argument because the code size penalty from using a global is severe due to the limitations of Wasm linkers (the global index would have to be 5 bytes long, raising the size of a stack access from 2 bytes to 6.)

(incomplete - work in progress)

Metadata

Metadata

Assignees

No one assigned

    Labels

    arch-wasmWebAssembly architecturearea-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions