3 ms·
'the overhead of profiling and applying optimizations has always been greater than any efficiency gains.' Not necessarily, especially if you explicitly rely on
by szemet 10y ago
'the overhead of profiling and applying optimizations has always been greater than any efficiency gains.'
Not necessarily, especially if you explicitly rely on them.
For example in C++ you deliberately have to avoid overusing virtual functions if you don't want the overhead. In Java, virtual functions are the default, and you usually don't care: if you call them a lot (e.g. in a tight loop) JVM will adaptively give you the proper implementation - without per call indirection - or may even inline it.
If you code C++ in Java style then JVM will win - so the overhead of (runtime) profiling and applying optimizations not always greater
- Vogtinator 10y agoG++ 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.