Move Core.Compiler into Base
This is the first step in what I am hoping will eventually result in making the compiler itself an upgradable stdlib. Over time, we've gained several non-Base consumers of Core.Compiler, and we've reached a bit of a breaking point where maintaining those downstream dependencies is getting more difficult than the close coupling of Core.Compiler to the runtime is worth.
In this first step, I am moving Core.Compiler into Base, ending the duplication of common data structure and generic functions between Core.Compiler and Base. This split goes back quite far (although not all the way) to the early days of Julia and predates the world-age mechanism.
The extant Base and Core.Compiler environments have some differences (other than the duplication). I think the primary ones are (but I will add more here if somebody points one out).
-
Core.Compilerdoes not usegetproperty -
Core.Compilerdoes not have extensible==equality
In this, I decided to retain the former by setting getproperty = getfield for Core.Compiler itself (though of course not for the datatstructures shared with Base). I don't think it's strictly necessary, but might as well.
For equality, I decided the easiest thing to do would be to try to merge the equalities and see what happens. In general, Core.Compiler is relatively restricted in the kinds of equality comparisons it can make, so I think it'll work out fine, but we can revisit this.
This seems to be fully working and most of this is just moving code around. I think most of that refactoring is independently useful, so I'll pull some of it out into separate PRs to make this PR more manageable.
Sounds like there's general support for this, so I'll pull out the various refactorings separately and get them merged so that this PR isn't a huge monolith. Then we can look at the effect of this on downstream consumers and decide whether to merge as is or first figure out the eventual plan (whether this will become a stdlib etc), to avoid breaking things twice.
I think this is good to go from my perspective.
The plan here is to merge this together with the follow-on (not yet put up) PR to make the compiler a stdlib to avoid breaking people twice. Everyone seems generally on board with the direction though.
Been looking forward to this. I think we can also remove the handful of if nameof(@__MODULE__) === :Base branches for avoiding method overwrites between Compiler and Base.
Continued in #56409.