News for hackers. Stuff that matters.
Re:Bringing Asm.js to Chakra and Microsoft Edge by flohofwoe on Thursday May 07, 2015 @03:09PM (#9507501)
In the end there's not much difference between PNaCl and asm.js (see for yourself: http://floooh.github.io/oryol/). Both compile down to 'immutable' machine code, either via JIT or AOT compilation, both call into the same browser API backends, both are based on LLVM (actually PNaCl and emscripten use the same modified LLVM frontend) both have somewhat similar restrictions what APIs can be called in threads, the only real difference is whether a pthreads-style threading model is supported or not (PNaCl does, asm.js does not, but work is underway at Mozilla to implement a true pthreads-style model via SharedArrayBuffer).
Re:Bringing Asm.js to Chakra and Microsoft Edge by teacup50 on Thursday May 07, 2015 @04:45PM (#9508167)
If I want to implement NaCL execution, I only need to support a (sane) bytecode and a reasonable "syscall" surface (pepper -- and only if I want to support pepper. I may not want to for things like server-side sandboxing).

I can AOT compile a complete binary, and can run on (just about) any target.

If I want to implement asm.js, I have to implement a full JavaScript JIT (if I want decent performance). This is Hard. I can't AOT compile, by the nature of JavaScript.

So, no, there is a difference. One of these technologies brings the entire bloated browser technology stack along with it, and one finally cleans up that bloat.

Re:Bringing Asm.js to Chakra and Microsoft Edge by pcwalton on Thursday May 07, 2015 @06:26PM (#9508781)
> If I want to implement NaCL execution, I only need to support a (sane) bytecode

What makes asm.js "insane" by comparison? The syntax?

There's a bytecode for asm.js too if you want it. https://github.com/kripken/emscripten/wiki/Emterpreter

> If I want to implement asm.js, I have to implement a full JavaScript JIT (if I want decent performance). This is Hard.

Writing a compiler that gets decent performance for LLVM is also Hard. (Go look at the size of the x86 backend alone in LLVM.) If you were writing an asm.js engine from scratch with no support for any JS other than Emterpreter bytecode, asm.js is probably even a bit easier than supporting PNaCl, due to the lack of types and no SSA. But honestly, the amount of work you need to parse a different bytecode doesn't matter much compared to the amount of work you need to do to write a good compiler, which you would have to do either way.

> One of these technologies brings the entire bloated browser technology stack along with it, and one finally cleans up that bloat.

Except that, as I mentioned above, you're never going to "clean up" the stack. HN, which you're using to post this comment, hasn't even moved beyond the <font> and <center> tags; what chance is there for browsers to drop all that technology when many sites haven't even adopted CSS1? The difference isn't between "HTML + CSS + JS" and "alternative stack", it's "HTML + CSS + JS + asm.js" and "HTML + CSS + JS + alternative-stack-that-duplicates-the-features-of-the-previous-three". You have to take that into account when talking about the complexity calculus.

Re:Bringing Asm.js to Chakra and Microsoft Edge by bzbarsky on Friday May 08, 2015 @12:08AM (#9509913)
> I can't AOT compile, by the nature of JavaScript.

Firefox AOT compiles asm.js. All you have to do is validate it (like you would any other bytecode) and then you can in fact AOT compile it. You don't even need a full JS parser, since asm.js only uses a subset of the syntax allowed in JS.

Re:Bringing Asm.js to Chakra and Microsoft Edge by ygra on Thursday May 07, 2015 @06:02PM (#9508638)
Asm.js bypasses the JIT, using AOT compilation directly to machine code (after verification). You just need a JS parser, not the JIT. At least not if you only want to support asm.js.
Re:Bringing Asm.js to Chakra and Microsoft Edge by TazeTSchnitzel on Thursday May 07, 2015 @03:21PM (#9507582)
There's a very big difference. NaCl and PNaCl don't use the standard, multi-vendor web APIs. They use a proprietary single-vendor (Google) API, Pepper. This not only makes implementation by competitors difficult, it's needless duplication of effort (why maintain multiple APIs for the same thing?).

Also, both are based on single-vendor, single-implementation technology. NaCl used actual native code, so if you're not using x86-64 or ARM, too bad! And PNaCl uses LLVM, so there's only one implementation.

Compare this to asm.js. It's a strict subset of ECMAScript/JavaScript, which has several high-quality implementations, and is portable across platforms. It uses the existing standard web APIs, which also have several high-quality implementations.

Re:Bringing Asm.js to Chakra and Microsoft Edge by flohofwoe on Thursday May 07, 2015 @03:29PM (#9507643)
Sure, but under the hood both the HTML5 APIs and Pepper APIs call into the same code, at least for WebGL, the performance behaviour on Chrome between WebGL and Pepper's GL wrapper is basically identical, and most other exposed API features are so similar to their HTML5 counterparts that it is almost certain that there's the same code underneath.
Re:Bringing Asm.js to Chakra and Microsoft Edge by TazeTSchnitzel on Thursday May 07, 2015 @03:31PM (#9507656)
> Sure, but under the hood both the HTML5 APIs and Pepper APIs call into the same code

It's still wasted effort, though. Maybe they share some code, but Pepper is an unnecessary extra API. One that's non-standard and results in vendor lock-in.

Re:Bringing Asm.js to Chakra and Microsoft Edge by dman on Thursday May 07, 2015 @04:21PM (#9507998)
Do you think Google could be persuaded to contribute PNaCL as an open standard?
Re:Bringing Asm.js to Chakra and Microsoft Edge by pcwalton on Thursday May 07, 2015 @04:34PM (#9508100)
There were beginnings of talks to get cross-vendor consensus on Pepper (which would be a prerequisite to any standardization attempt of PNaCl) in 2010: https://mail.mozilla.org/pipermail/plugin-futures/2010-April...

The general consensus among non-Google browser vendors was that just using the existing browser APIs was a more desirable approach than Pepper. Since then, Pepper has remained a Chrome-specific technology.

Re:Bringing Asm.js to Chakra and Microsoft Edge by cpeterso on Thursday May 07, 2015 @06:23PM (#9508766)
Could Google add NaCl support to Firefox with an add-on?
Re:Bringing Asm.js to Chakra and Microsoft Edge by TazeTSchnitzel on Thursday May 07, 2015 @06:26PM (#9508783)
They could, but why would they?
Re:Bringing Asm.js to Chakra and Microsoft Edge by dman on Friday May 08, 2015 @10:34AM (#9511902)
To help developers?
Re:Bringing Asm.js to Chakra and Microsoft Edge by dragonwriter on Thursday May 07, 2015 @04:31PM (#9508075)
Judging from their FAQ [0] on it, it doesn't seem like they are generally opposed to the idea, just see it as premature at this time.

[0] https://developer.chrome.com/native-client/faq

Re:Bringing Asm.js to Chakra and Microsoft Edge by Sephr on Thursday May 07, 2015 @05:16PM (#9508354)
Pepper is not proprietary, it's completely open source.
Re:Bringing Asm.js to Chakra and Microsoft Edge by TazeTSchnitzel on Thursday May 07, 2015 @08:27PM (#9509328)
That doesn't make it not proprietary! It's open-source, sure, but it's not something easy for other browser vendors to implement and only has a single implementation.
Re:Bringing Asm.js to Chakra and Microsoft Edge by bzbarsky on Thursday May 07, 2015 @11:46PM (#9509865)
Being open source doesn't help other people to adopt the code if it has hard dependencies on other parts of Chrome.