News for hackers. Stuff that matters.
Re:I 10x'd a TI-84 emulator's speed by replacing a switch-case by fps_doug on Monday August 08, 2022 @04:11AM (#32383355)
TFA references a post that states that optimized switch statements in V8 are still just if-elseif-else and not jump tables, at least back when it was written. They might be faster than unoptimized JS, but certainly not as fast as jump tables. The author didn't even bother to split up the functions/switch blocks further when they learned about the requirements to get V8 to actually optimize a switch, as it seemed not worth it.
Re:I 10x'd a TI-84 emulator's speed by replacing a switch-case by fenomas on Monday August 08, 2022 @05:22AM (#32383653)
Sure, none of that is in doubt. But in my experience the performance cost of hot code getting deopted is so massive as to overwhelm virtually any other factor, so realistically, fixing the deopt is what solved TFA's problem. Of course getting rid of the switch statements was presumably an additional speedup, but since TFA doesn't compare those cases I guess that's neither here nor there.
Re:I 10x'd a TI-84 emulator's speed by replacing a switch-case by whizzter on Monday August 08, 2022 @04:22AM (#32383398)
The if-else behaviour comes from the EcmaScript spec, check the sibling comment.