Walter Bright:

It does for classes/methods marked 'final' and also in cases where it can statically tell that a class instance is the most derived type.

Recently I have seen this through Reddit (with a comment by Anon):

http://eli.thegreenplace.net/2013/12/05/the-cost-of-dynamic-virtual-calls-vs-static-crtp-dispatch-in-c/

The JavaVM is often able to de-virtualize virtual calls.


Regarding Java performance matters, from my experience another significant source of optimization in the JavaVM that is often overlooked is that the JavaVM is able to partially unroll even loops with a statically-unknown number of cycles. Currently I think GCC/DMD/LDC2 are not able or willing to do this. I think LLVM was trying to work on this problem a little.

Bye,
bearophile

Reply via email to