Re: Sync API for workers

----- Original Message -----
> From: "David Bruant" <bruant.d@gmail.com>
> To: "Jonas Sicking" <jonas@sicking.cc>
> Cc: "public-webapps" <public-webapps@w3.org>, azakai@mozilla.com
> Sent: Sunday, October 13, 2013 1:36:22 PM
> Subject: Re: Sync API for workers
> 
> > * You could solve the use case of compile-to-JS for code that uses
> > sync APIs using yield. However it requires changing all functions into
> > generators, and all function calls into yield* statements.
>
> all? as is "all function in the application"? that sounds like a too
> violent constraint, especially if a small proportion of the code uses
> sync functions. Maybe only the functions that may call a sync function
> need to be changed to generators... oh... hmm... I don't know.
> Taking the liberty to cc Alon Zakai to ask for his expert opinion on
> this topics.
> 

Not sure about all the context here. In general, the idea of using yield or CPS to handle synchronous code has come up in emscripten, but no one has done work to implement it, so we don't have a concrete answer for how practical it would be. My guess however is that it would be not very practical, because large codebases can have sync code anywhere, and relying on static analysis to simplify that so it is mostly not a factor is very optimistic. CPS all the time would likely be too slow; yield all the time I am less clear on because I am not sure the implementations are mature enough to benchmark yet (and no implementation at all in IE and Safari last I heard) - we would need to ask JS engine devs on that.

- Alon

Received on Monday, 14 October 2013 09:39:16 UTC