3 ms·
> V8 cannot compile arithmetic assignment operators, which it calls left-side expressions, so you can see a rapid speed boost in V8 when you replace something l
by Narishma 9y ago
> V8 cannot compile arithmetic assignment operators, which it calls left-side expressions, so you can see a rapid speed boost in V8 when you replace something like a += 1 with a = a + 1.
Is there a reason it can't? I'm not familiar with Javascript, but aren't the two expressions equivalent?
- austincheney 9y agoThe two expressions are equivalent. V8 cannot compile that logic into optimized bytecode due to a violation in its code engine that conflicts with other optimization logic. So instead of fast compiled code the code in the local scope of that expression is slow string interpreted code. https://github.com/vhf/v8-bailout-reasons https://github.com/vhf/v8-bailout-reasons
- chillee 9y agoDo you have a source that cites the += example? I can't seem to find it on the page you linked.
- austincheney 9y agoI remember seeing the cause of this specific case mentioned in a slide deck by one of the V8 engineers. I don't remember where online it is. I was to validate this performance limitation more than a year ago through self-testing in my personal code. As titzer mentioned this issue may no longer exist. I would have to run additional tests to independently make an assessment with the current V8.
- titzer 9y agoThat list is for CrankShaft which has been replaced by TurboFan > 6 months ago. If you continue to experience slowdowns please file a bug and it can be investigated.
- maaark 9y agoThere's an automotive engineer somewhere reading this, irrationally upset at the idea of replacing a crankshaft with a turbofan.