Are switch-case statements optimised for up to 10 cases?

109 views
Skip to first unread message

pawel.b...@gmail.com

unread,
May 16, 2021, 8:11:38 AM5/16/21
to v8-users
Hi,

I noticed a performance cliff when using switch case statements longer than 10 cases. I did a bit of poking around and noticed that different instructions are used to handle cases above the 10th. Until the 10th its "JumpIfTrue" and above "JumpIfTrueConstant".

Two questions:
 - are people aware of performance optimisation where switch-case statements might deteriorate after 10 cases?
 - might those different bytecode instructions be causing this?

Thanks,
Pawel
Reply all
Reply to author
Forward
0 new messages