Refactor generated function implementation to provide bindings/method (#57230)
This PR refactors the generated function implementation in multiple
ways:
1. Rather than allocating a new LineNumber node to pass to the
generator, we just pass the original method from which this
LineNumberNode was constructed. This has been a bit of a longer-standing
annoyance of mine, since the generator needs to know properties of the
original method to properly interpret the return value from the
generator, but this information was only available on the C side.
2. Move the handling of `Expr` returns fully into Julia. Right not
things were a bit split with the julia code post-processing an `Expr`
return, but then handing it back to C for lowering. By moving it fully
into Julia, we can keep the C-side interface simpler by always getting a
`CodeInfo`.
With these refactorings done, amend the post-processing code to provide
binding edges for `Expr` returns. Ordinarily, bindings in lowered code
do not need edges, because we will scan the lowered code of the method
to find them. However, generated functions are different, because we do
not in general have the lowered code available. To still give them
binding edges, we simply scan through the post-lowered code and all of
the bindings we find into the edges array.
I will note that both of these will require minor adjustments to
`@generated` functions that use the CodeInfo interface (N.B.: this
interface is not considered stable and we've broken it in almost every
release so far). In particular, the following adjustments need to be
made:
1. Adjusting the `source` argument to the new `Method` ABI
2. If necessary, adding any edges that correspond to GlobalRefs used -
the code will treat the returned CodeInfo mostly opaquely and (unlike in
the `Expr` case) will not automatically compute these edges.