Live data from Hacker News

Skeleton WebAssembly target

reviews.llvm.org

31–40 of 60 posts

Re: Skeleton WebAssembly target

#31
post #16
post #10

If webassembly is essentially asm.js directly converted to a more compact bytecode format but with the same semantics - and emscripten already provides llvm with a backend that outputs asm.js, then what's significant about this? I had assumed from the original webassembly announcement that this would be a fairly trivial step but I expect I've misunderstood something.

Multiple things are happening in parallel here. On Emscripten's side, we're going to add a feature which translates Emscripten's asm.js output into WebAssembly, so that existing Emscripten users can easily use WebAssembly. This will indeed be a fairly simple step. [0] The new WebAssembly backend is being developed in upstream LLVM from the beginning, and will be targetting WebAssembly directly rather than going throu…

Will there be any advantage to generating asm.js over WebAssembly+polyfill for clients that don't support WebAssembly natively?

Re: Skeleton WebAssembly target

#32
post #28

Earlier quoted context omitted.

Emscripten doesn't provide LLVM with a backend it uses a fork of LLVM called Fastcomp and that has a asm.js backend. Also the current backend isn't integrated with LLVM the way normal ISA backends are. This I believe (can't access page either) will be upstream and integrated with LLVM proper. Providing performance advantages as well as allowing frontends that aren't supported in Fastcomp but are based off upstream LL…

All of those advantages are true, except for performance. We actually don't know which approach will be faster to compile, nor which approach will emit faster code. There are reasons to guess either way. The new backend being begun here is something of an experiment, as LLVM shared backend infrastructure was just not designed for this kind of thing (emitting a high-level AST IR without physical registers, etc.). Ther…

What's the relationship between WebAssembly and Emscripten's Emterpreter?

https://blog.mozilla.org/research/2015/02/23/the-emterpreter...

Re: Skeleton WebAssembly target

#33
post #10

If webassembly is essentially asm.js directly converted to a more compact bytecode format but with the same semantics - and emscripten already provides llvm with a backend that outputs asm.js, then what's significant about this? I had assumed from the original webassembly announcement that this would be a fairly trivial step but I expect I've misunderstood something.

My understanding is that it will only initially mirror asm.js but will eventually become a full-blown, independent bytecode IR that departs from JavaScript semantics (while continuing to support expressing them), allowing other languages to be compiled down to WebAssembly and run in the browser efficiently. Having a bytecode format also eases the considerable burden of parsing JavaScript – which is especially problem…

It's just a binary encoding of the AST. Nothing more, nothing less.

It's not quite a bytecode, those are typically for interpreters. Binary encoding would be more accurate.

The semantics will be identical to JavaScript but the syntax obviously can be completely different depending on the language.

Re: Skeleton WebAssembly target

#34
post #33

Earlier quoted context omitted.

My understanding is that it will only initially mirror asm.js but will eventually become a full-blown, independent bytecode IR that departs from JavaScript semantics (while continuing to support expressing them), allowing other languages to be compiled down to WebAssembly and run in the browser efficiently. Having a bytecode format also eases the considerable burden of parsing JavaScript – which is especially problem…

It's just a binary encoding of the AST. Nothing more, nothing less. It's not quite a bytecode, those are typically for interpreters. Binary encoding would be more accurate. The semantics will be identical to JavaScript but the syntax obviously can be completely different depending on the language.

It's a binary encoding of a WebAssembly AST. It's not JavaScript, though it lives in the same universe.

Re: Skeleton WebAssembly target

#35
post #16

Earlier quoted context omitted.

Multiple things are happening in parallel here. On Emscripten's side, we're going to add a feature which translates Emscripten's asm.js output into WebAssembly, so that existing Emscripten users can easily use WebAssembly. This will indeed be a fairly simple step. [0] The new WebAssembly backend is being developed in upstream LLVM from the beginning, and will be targetting WebAssembly directly rather than going throu…

Will there be any advantage to generating asm.js over WebAssembly+polyfill for clients that don't support WebAssembly natively?

The polyfill is slower.

Re: Skeleton WebAssembly target

#36
post #23
post #16

Earlier quoted context omitted.

Multiple things are happening in parallel here. On Emscripten's side, we're going to add a feature which translates Emscripten's asm.js output into WebAssembly, so that existing Emscripten users can easily use WebAssembly. This will indeed be a fairly simple step. [0] The new WebAssembly backend is being developed in upstream LLVM from the beginning, and will be targetting WebAssembly directly rather than going throu…

Are there any examples of the text format of wasm?

It doesn't yet exist. The specifications haven't been written, these are high-level design documents.

Re: Skeleton WebAssembly target

#37
post #28

Earlier quoted context omitted.

All of those advantages are true, except for performance. We actually don't know which approach will be faster to compile, nor which approach will emit faster code. There are reasons to guess either way. The new backend being begun here is something of an experiment, as LLVM shared backend infrastructure was just not designed for this kind of thing (emitting a high-level AST IR without physical registers, etc.). Ther…

What's the relationship between WebAssembly and Emscripten's Emterpreter? https://blog.mozilla.org/research/2015/02/23/the-emterpreter...

Emterpreter is just a binary encoding of asm.js to improve startup times. It's a bit of a hack.

WebAssembly is a whole new language.

Re: Skeleton WebAssembly target

#38
post #29
post #10

If webassembly is essentially asm.js directly converted to a more compact bytecode format but with the same semantics - and emscripten already provides llvm with a backend that outputs asm.js, then what's significant about this? I had assumed from the original webassembly announcement that this would be a fairly trivial step but I expect I've misunderstood something.

WebAssembly itself doesn't have anything to do with asm.js near as I can tell. It's more the ecosystem surrounding WebAssembly. I looked through the specs a little bit. What it is, is a binary encoding of the AST with some optimizations thrown in to decrease size (symbol tables instead of using the full tokens). I'm unclear on why asm.js is even mentioned but I suspect it is a temporary stop gap since those languages…

Thanks for the explanation. This was very helpful for cutting though the noise.

Re: Skeleton WebAssembly target

#39
post #33

Earlier quoted context omitted.

It's just a binary encoding of the AST. Nothing more, nothing less. It's not quite a bytecode, those are typically for interpreters. Binary encoding would be more accurate. The semantics will be identical to JavaScript but the syntax obviously can be completely different depending on the language.

It's a binary encoding of a WebAssembly AST. It's not JavaScript, though it lives in the same universe.

That's exactly what I said. Why did I get downvoted?

Re: Skeleton WebAssembly target

#40

Earlier quoted context omitted.

Will there be any advantage to generating asm.js over WebAssembly+polyfill for clients that don't support WebAssembly natively?

The polyfill is slower.

It really depends on what you mean by "slower". Emscripten already supports the "Emterpreter"[1], which uses a straight bytecode (not AST, like webassembly) version of your asm.js code that can be downloaded and parsed quickly while the much more verbose asm.js code is still downloading and being parsed. So while it does more work, it's responsive sooner.

If fast start up time is the top priority for your app, the polyfill could easily be the best choice (and there are probably more tricks to be done with incremental parsing by feeding the JS engine wasm -> asm.js code in chunks while running an interpreter in the meantime, prioritizing hot functions in the wasm stream).

[1] https://blog.mozilla.org/research/2015/02/23/the-emterpreter...

Post reply on HN