3 ms·
To be fair, JVMs are typically pretty bad at method dispatch as they typically haven't needed to worry about dynamic dispatch (because, after all, typically the
by gsnedders 12y ago
To be fair, JVMs are typically pretty bad at method dispatch as they typically haven't needed to worry about dynamic dispatch (because, after all, typically the main concern has been Java).
JS engines have done a fair bit around dispatch, but ultimately much of that is similar to what was done in Self over twenty years ago.
- shellac 12y agoThat's not really true. Java linking happens very late, and so invoking methods at polymorphic call sites does have more in common with 'dynamic' languages than you might think. Hotspot has smalltalk roots, and features like inline caching at call sites together with optimistic fast paths, guards, deoptimisation, and other things that would be familiar from, say, a ruby implementation.
- gsnedders 12y agoYes — HotSpot does much of this, but the inability until recently to encode "call this function which expects some number of arguments" in the instruction set has historically been the limiting factor. invokedynamic helps a lot, but it adds enough levels of indirection that AIUI often enough isn't inlined for it to really solve everything. I wonder if a tracing JVM would handle it better? Probably.