4 ms·
One nice thing about WebAssembly is that it can run in a browser. How would you implement things like fork() in that context, given the inability to manipulate
by panic 3y ago
One nice thing about WebAssembly is that it can run in a browser. How would you implement things like fork() in that context, given the inability to manipulate the stack?
- abetusk 3y agoWeb workers? [0] [0] https://emscripten.org/docs/api_reference/wasm_workers.html https://emscripten.org/docs/api_reference/wasm_workers.html
- syrusakbary 3y agoIn WASIX we fully solved that, so is definitely doable to run fork on the browser. Although I'm extremely curious the WALI fork strategy would work in the browser. Maybe the creators can chime in here?
- kg 3y agofork in the browser is functionally impossible unless you mean some sort of 'damaged fork' where only the native wasm heap is mirrored and not everything else, which would be effectively useless.
- deleted 3y ago[deleted]
- yuri91 3y agoCould you elaborate on how you solved the issue? A link to the relevant code would be nice.
- syrusakbary 3y agoSure thing: https://github.com/wasix-org/wasix-libc/blob/main/libc-top-half/musl/src/process/fork.c https://github.com/wasix-org/wasix-libc/blob/main/libc-top-h...
- panic 3y agoThe C function you linked calls _Fork, which calls __wasi_proc_fork, which calls __imported_wasix_32v1_proc_fork, which is the 'proc_fork' import in the 'wasix_32v1' module. The question is, what JavaScript function is provided for this proc_fork import when instantiating a WebAssembly module using WASIX? From what I understand about the WebAssembly JavaScript API, such a function is impossible to implement, which is why I'm curious how it was done here.