4 ms·
It's also worth noting that a vtable implementation of `virtual` methods is not required by the standard. Granted, I'm not aware of any other implementations o
by hermitdev 5y ago
It's also worth noting that a vtable implementation of `virtual` methods is not required by the standard. Granted, I'm not aware of any other implementations of virtual methods (in the case where the compiler cannot optimize the virtual dispatch) in production compilers.
- Kranar 5y agoGCC can use whole program optimization to replace virtual dispatch with a series of if statements. There are plenty of situations where it's faster to test for a handful of types and then inline the body than it is to perform two indirections.
- hermitdev 5y ago> GCC can use whole program optimization to replace virtual dispatch with a series of if statements. Would you happen to have a sharable example of this occurring? I'd be curious to see what heuristics GCC is using. Also, what the conditional is on...is it still on the vtable, but just avoiding the indirect call?
- Kranar 5y agoJan Hubička worked on much of the devirtualization in GCC and posted a blog about how it works here: http://hubicka.blogspot.com/2014/01/devirtualization-in-c-part-1.html http://hubicka.blogspot.com/2014/01/devirtualization-in-c-pa...