Re:Faster JavaScript Calls
by k__ on Monday February 15, 2021 @02:17PM
(#26146080)
Isn't that what asm.js did?
[ Parent
| on HN ]
Maybe from a certain perspective. But it worked by conforming the bundle to a particular subset of JS that the authors knew to be optimized, instead of expressing information to the interpreter outright. That seems like a comparatively limited channel for communication.
From what I understand, in Safari at least they tried to make many of the optimizations general. So if you use asm.js-style type indications in your code even without following the full spec, you might see some performance benefit.
I have sometimes found a speedup when adding apparently an superfluous |0.
The highly optimizable, explicit and precise code for the interpreter is WASM.
JS VMs don't need more hints from the code. They need guarantees. They already analyze and profile JS, but as long as JS is allowed to be dynamic (and it has to, it won't be JS without it), then they have to keep the complexity and cost of all the extra runtime checks and possible deoptimizations.