On 2023-04-11 07:23, Hairy Pixels via fpc-devel wrote:
Strange question but I heard it brought up during a discussion and I
was very curious what compiler people think about it.
The question is, instead of using a virtual method table would it be
feasible to use a case statement on the real class type and make a
dispatch routine for each method call?
This is sometimes done by compilers when value profiling determines that
a particular function pointer call (almost) always goes to the same
target.
It can also be done as part of whole program optimisation, as Marco
mentioned. FWIW, when WPO devirtualisation is applied to the compiler
(which can be devirtualised almost completely because of the way it is
constructed), LLVM can apply your proposed optimisation (and some
others) and gets 8% extra performance. So don't expect miracles from it,
unless your main loop consists of only calling tiny virtual methods.
Jonas
_______________________________________________
fpc-devel maillist - [email protected]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel