staticdata: pack CodeInstances at the front of precomposed sysimages
After the previous two commits, the only load-time relocations left in
a precomposed system image are native function pointers (FunctionRef),
which live exclusively in CodeInstances -- as do the stores made by
jl_update_all_fptrs and most runtime mutation of image objects during
startup (flags and world-age updates). Serializing all CodeInstances
first therefore confines nearly every load-time and startup store to a
small contiguous region at the front of the image.
Only the physical write order changes: cross-references go through
layout_table (indexed by queue id), the relocation lists are pushed in
stream-position order regardless of visit order, and the queue itself
is untouched, so incremental-image semantics are unaffected (the
reordering is only applied to precomposed images anyway).
In the test sysimage, the pages touched by external relocations drop
from 2265 to 604 (the ~9.4MB CodeInstance region), dirty pages in the
mapped .ji drop from ~70MB to ~13MB of 161MB, and startup at the
preferred address improves from 41.3ms to 29.3ms (slide fallback:
51.8ms; classic embedded sysimage: ~78ms), largely from the reduced
copy-on-write faulting.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>