improve concurrency safety for `Compiler.finish!` (#57248)
Similar to JuliaLang/julia#57229, this commit ensures that
`Compiler.finish!` properly synchronizes the operations to set
`max_world` for cached `CodeInstance`s by holding the world counter
lock. Previously, `Compiler.finish!` relied on a narrow timing window to
avoid race conditions, which was not a robust approach in a concurrent
execution environment.
This change ensures that `Compiler.finish!` holds the appropriate lock
(via `jl_promote_ci_to_current`).