I'm looking at porting a game to HTML5, but I'm running into some problems.
The game uses multithreading quite a bit, with rendering running on the main thread and scripts running on worker threads. Multiple scripts can (and frequently do) run concurrently. It's got a fair amount of global data that any script can access, mostly to read from but occasionally to write to as well. Mechanisms are in place to ensure that thread safety is not a problem.
It looks like HTML 5 Web Workers can be used to set up multithreading, but getting the global data to work will be a big problem, as there doesn't appear to be any easy way to share data between workers. I could theoretically put all the global data in a shared worker and have each script worker send it messages to get and set data, but access is common enough that the message-passing overhead would completely destroy performance, especially since a simple read would be far more expensive than a write, and potentially require some sort of CPS implementation just to make it work.
Is there any good way to port an architecture like this to HTML5 and JavaScript?