4 ms·
Yes, LLVM has two tiers, a front end, and a back end (someone else correct me if i butcher concepts or names): The front end basically converts your human read
by atonse 11y ago
Yes, LLVM has two tiers, a front end, and a back end (someone else correct me if i butcher concepts or names):
The front end basically converts your human readable code to LLVM intermediate byte code (called IR, or intermediate representation). The byte code is independent of a CPU or programming language.
A second stage then turns that IR into x86 code or ARM code, etc. (these are "targets").
In this case, they added a target so it converts the IR into WebAssembly (which is, funny enough, yet another byte code).
You could probably, technically write any language to this but JS has certain behaviors and the JS engine will probably expect those behaviors.
- VeejayRampay 11y agoAh so I had the gist of it but it's actually even better than I thought, two tiers. Nice. Thank you for an informative answer and I'll be sure to read up on LLVM later today.
- lucozade 11y agoJust a couple of clarifications. Although the LLVM IR is mostly agnostic to the target, in practice, it's not quite that simple. However, the IR layer does make it substantially easier to move between languages and targets. It's just not free. Also, my understanding is that WebAssembly isn't a JS thing. The intent is that a VM for the bytecode will be added to the browsers alongside the JS engine. In the short term they'll use the JS engine for it by converting WebAssembly to JS but that's just a band aid to get things moving. If successful, it could mean an eventual break of the tie between the browser and JS. Interesting times....
- deleted 11y ago[deleted]
- pcwalton 11y agoTypically the implementation of Web Assembly will reside in the JS engine. There is no good reason not to continue to do in perpetuity, as far as I'm concerned. So, even in the future in which Web Assembly grows extra functionality, this is only a "break" from JS in the sense that x86-64 was a "break" from x86.
- TazeTSchnitzel 11y ago> Also, my understanding is that WebAssembly isn't a JS thing. Not really. WebAssembly is not entirely unlike asm.js. It will live within the same world that JavaScript does.