The other cheerful thing the switch statement does is put a range check in. This would cause a range check to be done for each bytecode looked up unless you did the gnuify. 15 years back we actually altered the 68K binary to no-op out the range check which improved performance a measurable amount on.
On 2010-11-06, at 1:42 PM, Levente Uzonyi wrote:
On Sat, 6 Nov 2010, Igor Stasenko wrote:
I suppose its related to fact, that with small number of cases (like up to 16) its not worth using indirect jump, because with branch prediction you can achieve same or even better performance. That's why i think, modern compilers do not using jump tables. Having more than 16 number of cases, is an edge case. Not saying about 256.
I expect a compiler to generate the fastest possible code, if I ask for that. I think we agree, that gcc doesn't do this.
Levente
Btw, I was also thinking that compilers generating jump tables for case statements.
-- =========================================================================== John M. McIntosh johnmci@smalltalkconsulting.com Twitter: squeaker68882 Corporate Smalltalk Consulting Ltd. http://www.smalltalkconsulting.com ===========================================================================