Update documentation on Wasm Workers
Update documentation on Wasm Workers stack size, and Wasm Workers vs Emscripten Workers API. Addresses #21610.
So the pre-allocated stack is for thread-local storage? @juj
If the normal worker api can be spawned using a custom URL, how do we postmessage wasm function calls over? How does the worker api function?
Sorry for the delay, I was on a leave for a while there. Updated to address the review.
So the pre-allocated stack is for thread-local storage? @juj
With Wasm Workers, the stack memory area that is passed to Wasm Worker creation will contain the stack, but additionally, the TLS memory for the Wasm Worker will be located at the bottom end of that memory area. This simplifies the Wasm Worker memory initialization, as it allows one to allocate only one memory block for all dynamic memory needs for the Wasm Worker.
If the normal worker api can be spawned using a custom URL, how do we postmessage wasm function calls over? How does the worker api function?
The earlier Worker API uses these functions to postMessage() there and back: https://github.com/emscripten-core/emscripten/blob/58d39a5978d78f7348ad7e9b658aaa2399ab4326/system/include/emscripten/emscripten.h#L126-L138
emscripten_call_worker() performs a postMessage(), and emscripten_worker_respond() replies back. In general that API is not that fully crafted, and quite old as it predates SharedArrayBuffer. So most Emscripten applications should avoid using it (to the point of probably considering it as deprecated-ish).
Hey, updated the PR to latest main. Any more reviews, or good to land?