Polimorphic vs Megamorphic calls
Remi Forax
forax at univ-mlv.fr
Wed Mar 30 15:12:22 UTC 2016
----- Mail original -----
> De: "Ionut" <ionutb83 at yahoo.com>
> À: "Hotspot-dev Developers" <hotspot-dev at openjdk.java.net>
> Envoyé: Mardi 29 Mars 2016 10:32:40
> Objet: Polimorphic vs Megamorphic calls
>
> Hello All,
Hi,
> Could you please explain what is the difference between a Polimorphic and a Megamorphic call?
It's a dynamic property of a method call instruction (invokeinterface and invokevirtual in the Java bytecode).
This is related to an optimization technique called inlining-cache [1],
For Hotspot,
- if the instruction has always been called the same method implementation, the callsite is monomorphic,
and the inlining cache is just a comparison and a jump,
- if the instruction has been called a small number of method implementations (for Hotspot, it's 2),
the inlining cache do several comparison/jump checks.
- if the instruction has been called with a lot of different implementations,
there is no inlining cache, a virtual call [2] is generated instead.
> If you have some documentation on this topic or how it is handled by HotSpot would be great.
There is a wiki, (not updated as i should be)
https://wiki.openjdk.java.net/display/HotSpot/PerformanceTechniques
(see sections Profiling, Deoptimization, Methods)
> Regards,
> Ionut
Rémi
[1] https://en.wikipedia.org/wiki/Inline_caching
[2] https://wiki.openjdk.java.net/display/HotSpot/VirtualCalls
More information about the hotspot-dev
mailing list