2 ms·
You make some interesting points about cases where JS will always be difficult to be optimized automatically. I wonder if compiler hints can help in that regar
by azhenley 8y ago
You make some interesting points about cases where JS will always be difficult to be optimized automatically.
I wonder if compiler hints can help in that regard? For example, if performance is important then you could annotate the 'x+=x' line to tell the compiler to not check for overflow.
- Thiez 8y agoSure, you can hint with OR: `x = x | 0; x = (x + x) | 0;`. Bitwise operators always work on 32 bit integers in js. I'm not sure whether the js vms actually need or use this information.
- amelius 8y agoAnother option would be that the compiler deduces when exactly the statement x+=x would need to switch from integer to double. That's more difficult, and impossible in general, but not impossible in specific cases.
- imtringued 8y agoWe have that already. It's called asm.js and it's successor is WebAssembly.