WebAssembly / tool-conventions

Conventions supporting interoperatibility between tools working with WebAssembly.
Artistic License 2.0
297 stars 65 forks source link

Coredumps: how to support reference values and tables? #215

Open fitzgen opened 11 months ago

fitzgen commented 11 months ago

The coredump spec currently doesn't mention tables, presumably because it isn't clear how to encode reference values in core dumps. But this is still an issue today even without tables because globals can store references, as well as locals and the operand stack, all of which are included in core dumps.

So we should figure out what to do about references and then also allow encoding tables in core dumps.

Today, Wasmtime is encoding funcrefs and externrefs globals as null, unconditionally.

The coredump value encoding doesn't even have options for reference values at the moment.

Things we should figure out:

My biggest take away from thinking about this so far is that I think we need to switch the encoding of locals and the operand stack to use optional const expressions (so we can get ref.func, struct.new and friends; optional so we can represent optimized away values) or something even more general (like functions/code sections that can do arbitrary allocation and have access to locals to facilitate cycle creation) or something coredump-specific rather than trying to reuse core Wasm constructs.

We might also want to consider switching away from using the core Wasm global section to encode globals so that coredumps can have optimized-away global values.


cc @xtuc