Break dependency between loading and Core.Compiler (#56186)
This code was originally added in
df81bf9a96c59f257a01307cd0ecf05035d8301f where Core.Compiler would keep
an array of all the things it inferred, which could then be provieded to
the runtime to be included in the package image. In
113efb6e0aa27879cb423ab323c0159911e4c5e7 keeping the array itself became
a runtime service for locking considerations. As a result, the role of
Core.Compiler here is a bit weird. It has the enable switch and the GC
root, but all the actual state is being managed by the runtime.
It would be desirable to remove the Core.Compiler reference, so that
loading.jl can function even if `Core.Compiler` does not exist (which is
in theory supposed to be possible, even though we currently never run in
such a configuration; that said, post trimming one might imagine useful
instances of such a setup).
To do this, put the runtime fully in charge of managing this array.
Core.Compiler will call the callback unconditionally for all newly
inferred cis and the runtime can decide whether to save it or not.
Extracted from #56128