top | item 13759750

(no title)

zfedoran | 9 years ago

I'd love to know what the current advantages are over running asm.js? I understand that it will definitely be faster eventually, but if I have a project that uses asm.js today, would it make sense to run it with WebAssembly instead? (ignoring the fact that not all browsers support it)

One potential issue:

"If you have lots of back-and-forth between WebAssembly and JS (as you do with smaller tasks), then this overhead is noticeable."

As far as I'm aware, asm.js code does not have an issue with this, as it is just js code. Is this correct?

(edit: I should have mentioned that I'm primarily interested from an electron.js point of view at the moment, where Firefox asm.js optimizations are unavailable)

discuss

order

TazeTSchnitzel|9 years ago

> As far as I'm aware, asm.js code does not have an issue with this, as it is just js code. Is this correct?

It's not, because asm.js is treated specially in some cases. For instance, in Firefox asm.js calls to JS have to go through an FFI, IIRC.

geofft|9 years ago

asm.js code is "just" JS code in the sense that it is a subset of JS: a non-asm.js-aware JS implementation can treat it the same way as normal JS, and it will execute correctly. But in implementations where it's fast, asm.js is usually handled separately.

It looks like Mozilla's asm.js implementation used to have the exact same problem: https://hacks.mozilla.org/2015/03/asm-speedups-everywhere/#c... I'm not familiar enough with asm.js to know if that's still a problem.

abecedarius|9 years ago

Re your last question: when I wrote http://wry.me/hacking/Turing-Drawings I found that "each call into an asm.js function takes about 2 msec (at this writing)" (on Firefox). That was back in the week of asm.js's release, and I'd bet the situation's better now. But it was the same kind of issue.

mbebenita|9 years ago

Emscripten should produce an asm.js fallback if wasm support is missing. The biggest wins in the short term will be smaller code size, and faster first startup time.