lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Tue, May 14, 2019 at 7:10 PM Philippe Verdy <verdy_p@wanadoo.fr> wrote:
>
> Isn't it possible to just compile Lua with a C compiler targetting  WebAssembly?
...
> Did someone try it ? Could Lua be successfully compiled with its toolchain (which includes the C compiler and most shell and dev tools from Linux) ?

I do not understand if you are asking for *Other* ones doing that...
however, yes, I did in [1]. There is also an online version if you
want to make some experimentation (serach for "playground" in [1]).

> I cannot be so bad in perfomance, given the demos including games made with Unity. The mini Linux kernel run by Webasembly boots really fast and applications made with it are also very small to download. Behind the scene, there's the LLVM engine, but we've seen Mozilla and Google working to boost WebAssembly. And soon Microsoft will abandon Edge to rebuild it from the Webkit/Chromium base, so it will hopefully support WebAssembly)
>

Whithout an heavy use of coroutine/error (i.e. longjmp), I cannot see
any performance loss wrt PUC-Rio lua compiled to binary. By the way,
it was not a very deep benchmark.

On Tue, May 14, 2019 at 5:41 PM Sean Conner <sean@conman.org> wrote:
>   Perhaps I don't understand what's going on, but once Lua calls into C, the
> Lua VM isn't running.  Are you perhaps looking for some form of preemptive
> task switching for Lua coroutines?

> Le mar. 14 mai 2019 à 17:47, Francisco Olarte <folarte@peoplecall.com> a écrit :
>> Why do you need this? I did a similar thing, more or less:

I did this mostly to avoid messing with emscripten interface. I liked
to keep that code small, and write as much as I can in the sole lua
and javascript. However, I agreed with you: a proper C api published
to the lua interpreter is better than my proposed solution. This is
why I was asking for alternative in my fist message.

On Tue, May 14, 2019 at 9:12 PM William Ahern
<william@25thandclement.com> wrote:
> FWIW, WebAssembly is hostile to coroutines and stackful coroutines in
> particular. It does not make a good target for Lua, Go, or similar languages
> that reify the logical execution stack. They require an entire extra layer
> of indirection which will always make them second-class citizens in WASM.

True, but this is just a limitation of WASM 1.0/MVP. For now, there is
no way to implement longjmp fully in WASM, so the toolchain must
switch back and forth between WASM and javascript to handle it.
However there is already some work for a better implementation that we
could have in the next WASM revision [2].

pocomane

[1] https://github.com/pocomane/walua
[2] https://github.com/WebAssembly/exception-handling/blob/master/proposals/Exceptions.md