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 0 forks source link

Remove fibre::{Fiber, Suspend} types #220

Closed frank-emrich closed 1 week ago

frank-emrich commented 2 weeks ago

This PR performs a refactoring required by a follow-up PR that will implement actual pooling of VMContRefs.

This PR removes the types Fiber and Suspend from the fibre create (i.e., our version of wasmtime-fiber). These two types are effectively leftovers from wasmtime-fiber, but only add a layer of unnecessary indirection at this point.

Note that the fibre::FiberStack type remains. Some functions originally implemented on Fiber are moved to FiberStack now. Further, the VMContRef definition used in the optimized implementation now owns a fibre::FiberStack directly, rather than storing a Fiber as a wrapper around the FiberStack.

This PR does not affect the baseline implementation since it doesn't use the fibre crate at all.

frank-emrich commented 2 weeks ago

This ended up requiring a bit more back-and-forth with the test suite. The culprit is the test where we enable the unsafe_disable_continuation_linearity_check feature and then run cont_twice.wast.

The exact behavior of this test under the hood changed a bit: In the past, it was a mechanism inside the Fiber that detects if a Fiber has run to completion, and panics if you try to run it again afterwards. Since Fiber is gone now, this check does not exist any more. However, this was always somewhat superfluous, because we are already doing the same kind of checking using the VMContRef's state field. But I've had to make sure that we check the state field earlier on in the translation of resume instructions.

Given these headaches, I'm inclined to just remove unsafe_disable_continuation_linearity_check in a follow-up PR. The performance of the linearity check should be good enough so that we don't need to be able to disable it anymore.