Re: LuaJIT and WebAssembly

  • From: Kriss <Kriss@xxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Fri, 21 Apr 2017 19:14:31 +0100

Figure I'll chip in here with some thoughts since all of this has been on
my mind for sometime.

Personally I've been targeting the web via NaCl/Asm.js and now WebAssembly,
I'd say NaCl is the better technology but looks like WA is the one that we
are going to end up with, mostly for political reasons.

I'm coming at this from the point of view of previously using flash a lot
and even using Lua via NPAPI, which was barely much of anything other than
a way to hijack part of a browser window with a native dll, So I guess you
would say I'm pretty committed to ruining stuff in a browser, mostly game
type things running in Lua.

Right now, the situation with WA is that it is still pretty early on and
not worth doing anything other than keeping an eye on. The point is whats
happening here is down to politics and adoption so do not engage until the
dust settles.

Although it would be nice to have a WA port of LuaJIT It doesn't actually
help very much without the FFI/JIT. So even though it sits in the back of
my mind as something to do, it really isn't any sort of priority for the
near future and would not even be of any major benefit.

Currently I'm trapped with having to do things the old Lua way, optimising
by pushing data out into small C routines for speed and avoiding the FFI so
that I can maintain a code base that will run using Lua in a browser. For
Win/Linux/OSX builds I'm using LuaJIT but not to its full potential due to
this desire to write code that will also run in a browser.

FYI We also need to avoid threads, NaCl has them, Asm.js/WebAssembly does
not.


So I'd love to have a WebAsembly version of LuaJIT, but it is not much help
without the FFI/JIT and that doesn't look possible right now.

I think LuaJIT could be ported to work in NaCl, so that is currently the
only viable web target. However who knows if google are going to slowly
drop NaCl and just embrace WA? Even if that doesn't happen there is still
only a small chunk of browsers out there that will ever run NaCl. As a
reminder of how much this entire area is held back by politics, the
Chromium team strips NaCl out of their builds so NaCl will *only* work in
Google Chrome not Chromium.


So Yay, WebAssembly, but best to wait until it is actually here before
considering it and preferably until it has some sort of JIT support before
taking it seriously.


PS. My main Lua project that also runs in a browser ->
https://github.com/xriss/gamecake


On Fri, Apr 21, 2017 at 2:38 AM, Yichun Zhang (agentzh) <agentzh@xxxxxxxxx>
wrote:

Hello!

On Sat, Apr 15, 2017 at 9:45 AM, Las wrote:
Would not work AFAIK.
LuaJIT uses self-modifying code, which I don't think webassembly
supports.


Well, even though the JIT compiler won't work in that context, porting
LuaJIT's assembly-based interpreter over to WebAssembly may still give
us a nice speedup as compared to a similar WA port of the standard Lua
interpreters. The JIT compiler part of LuaJIT is optional anyway.

Regards,
Yichun




-- 
Kriss

http://www.WetGenes.com/

Other related posts: