Research task: Examine strategies for optimizing vtable/itable dispatch in the closed world #446
Replies: 7 comments
-
zulip discussion: https://quarkusio.zulipchat.com/#narrow/stream/237892-qcc/topic/vtables.20(or.20image.20data.20structure.20layout) And the example from that discussion:
|
Beta Was this translation helpful? Give feedback.
-
It sounds like the LLVM |
Beta Was this translation helpful? Give feedback.
-
This is handled in LLVM here: |
Beta Was this translation helpful? Give feedback.
-
In terms of debugging, I'd rather have a canonical vtable to look at rather than manually searching the |
Beta Was this translation helpful? Give feedback.
-
What type of debugging are you thinking of where it might be a concern? Run time program debugging, or debugging the generated code itself? From the latter perspective I imagine that having the dispatch methods physically together in the For run time program debugging, it seems like it would be less of a concern how dispatch is organized, but maybe there's a case that I should be thinking of but I'm not? |
Beta Was this translation helpful? Give feedback.
-
Debugging behaviour differences between the native image and the regular JVM. When default methods were added to interfaces back in JDK 8, I spent a lot of time debugging dispatch issues and being able to dump the vtables for different classes and compare them made it much clearer where the bugs where. Tracing through multiple layers of For methods like Object#toString, which will have deep hierarchies and implementors in many different layers, we may end up with a higher footprint from generating the code for the dispatch routines (even if lowered to jump tables) per-callsite code than creating a vtable per class. |
Beta Was this translation helpful? Give feedback.
-
My current plan for supporting a particular dispatch implementation is to introduce transformations during the lowering stage of compilation which removes all method invocations in favor of either inlining or function calls (through a table if needed). This should allow us to implement multiple independent strategies for dispatch and devirtualization which can work together or be switched out - in particular it should allow us to start off with something trivial and improve from there. Importantly, it removes the burden of implementing dispatch from the back end. I'm seeing how it would look to have a separate |
Beta Was this translation helpful? Give feedback.
-
The initial dispatch algorithm will amount to using comparisons against the numerical class ID of the target object. This implementation is simple to implement, while also aggressively favoring devirtualization. However there are many cases which might be better served by a more sophisticated solution.
This task is to identify different likely dispatch cases and their characteristics, to research possible dispatch strategies, and to determine the best strategy to use for each case and the tradeoffs therein.
Beta Was this translation helpful? Give feedback.
All reactions