3 ms·
I thought that one of the major points of WASM was that it would be fast? The first advantage listed on the official WebAssembly website is "Efficient and fast"
by acbart 7y ago
I thought that one of the major points of WASM was that it would be fast? The first advantage listed on the official WebAssembly website is "Efficient and fast" [0]. But I suppose you wrote "the point" - it's just one of several points. But ideally, it should run at "native speed", right?
[0] https://webassembly.org/ https://webassembly.org/
- snek 7y agoIt is designed to be able to skip the "tier up JIT" stage that JS code has to go through, where JS code is profiled at runtime to decide what should be optimized, what the types are, etc. `1 + 1` in JS and `(i32.add (i32.const 1) (i32.const 1))` should still result in the same cpu code, the only difference is that it takes longer for the JS code to get there (and there's no guarantee that it happens to the JS code). (and yes I know, the addition would be constant folded, it's just an example okay)
- sstangl 7y agoIn Firefox, Wasm still uses a tiered JIT. Like JS, there is a single-pass JIT and a JIT that does more aggressive optimizations (mostly: good regalloc). However the compilers are much simpler than the equivalent JS compilers, because wasm doesn't need on-stack-invalidation.
- JMTQp8lwXL 7y agoIt sounds more useful to just ship less JavaScript code if your problem is taking too much time script parsing, etc. Especially given how bundle sizes have grown in the past few years.