3 ms·
I don’t think this is true. If you know the set of functions that can be dispatched to, you could inline them in a jump table / switch statement. JVM could defi
by weberc2 8y ago
I don’t think this is true. If you know the set of functions that can be dispatched to, you could inline them in a jump table / switch statement. JVM could definitely do this since it doesn’t even need to know the full set; it could inline new functions as it encounters them. This is all theoretical, of course.
- xxs 8y agoThere are inline caches (IC) and JVM uses that to a point. The inline caching for hotspot is 2 targets with guard checks[0] and then a polymorphic call. However if there are no dominating/common calls the IC is useless. On top of that JVM has an inline budget and just stops at a point. So the switch stuff ain't happening for megamorph. [0]:https://blog.h2o.ai/2010/04/inline-caches-and-call-site-optimization/ https://blog.h2o.ai/2010/04/inline-caches-and-call-site-opti...
- dnomad 8y agoThis is exactly what the JVM does. See [0]. [0] https://mechanical-sympathy.blogspot.com/2012/04/invoke-interface-optimisations.html https://mechanical-sympathy.blogspot.com/2012/04/invoke-inte...
- xxs 8y ago>>jump table / switch statement. >This is exactly what the JVM does. See [0]. The jump table from Martin's blog is the virtual call one.
- MrBuddyCasino 8y agoMonomophisation is a common optimization on the JVM, combined with a guard condition that de-optimizes should the type assertion fail. Not sure if that only affects the hot path.