wasmfx / wasmfxtime

A fork of wasmtime (a fast and secure runtime for WebAssembly) supporting the WasmFX instruction set
https://wasmfx.dev/
Apache License 2.0
19 stars 1 forks source link

Codegen for switch instructions #264

Open frank-emrich opened 3 days ago

frank-emrich commented 3 days ago

This PR provides the missing piece to support switch instructions, by adding the necessary codegen (but only for the optimized implementation, support in the baseline implementation is not included).

Thus, the main change is the addition of wasmtime_cranelift::wasmfx::optimized::translate_switch.

In general, the implementation piggybacks on #256: On resume, we now fill the HandlerList with m entries for all tags with suspend handlers, followed by n entries for all tags with switch handlers. The search_handler code is changed so that on suspend and switch, we look in the correct part of the HandlerList. We could use two separate HandlerLists instead, but then we would have yet another allocation to manage, so putting both kinds of tags into the same list, and then only searching part of it seems preferable.

A few more notes: