3 ms·
G++ is able to optimize virtual calls to non-virtual calls in most cases (speculative devirtualization) by adding quick checks into the code (like if(obj->vtabl
by Vogtinator 10y ago
G++ is able to optimize virtual calls to non-virtual calls in most cases (speculative devirtualization) by adding quick checks into the code (like if(obj->vtable == Class::vtable) Class:virtualMethod(obj);) which the JVM would do as well.
So if G++ is able to tell the code paths leading to the virtual call, it does the same optimization as the JVM.
- pjmlp 10y agog++ cannot do that across dynamic libraries. It needs to see the source code at compile time. This is where JIT wins, as it can do that with binary deployed code.