3 ms·
Having a native stack switch for WASM would be nice but it's not necessary. Map all memory segments as shared into several instances of a single module -- each
by couchand 3y ago
Having a native stack switch for WASM would be nice but it's not necessary. Map all memory segments as shared into several instances of a single module -- each instance is a fiber.
Implementation is left as an exercise for the reader.
- kevingadd 3y agoThis doesn't address the shadow stack at all. It doesn't work.
- couchand 3y agoEach instance has its own stack. Switching between them is cooperative on a single thread. What am I missing?
- kevingadd 3y agoWebAssembly stores stack data - parameters, return addresses, local variables - in a "shadow stack" that does not live in the native heap your application has access to. There's no way for you to switch it.
- couchand 3y agoEach instantiated module has its own complete function call stack. A call out of the module, to a bit of control code in JS, and then into a different instance of the same module, with the same memory mappings, would look (to the program itself) like a stack switch, no? I guess it raises the philosophical question of what is a stack switch, anyway? If you end up cooperatively running multiple "green threads" within a single "OS thread" does it matter that what you actually switched was the entire execution environment?