aotcompile: look up equivalent compiled CodeInstances sharded by MethodInstance (#64212)
When linking an image, each call to a CodeInstance that is not being
compiled looked for an equivalent one by scanning every function being
compiled. That is quadratic in the size of the image, and took about a
tenth of the single-threaded time spent writing a large sysimage.
Equivalent CodeInstances have egal defs, which for a MethodInstance is
the same object, so index the compiled functions by def once and look
only at those. The result is the same, since candidates keep the order
of the full scan.
This was added in #60093.
Assisted-by: Claude Code (Claude Opus 5.5)