cmd/compile: switch to computing dict format on instantiated functions
Change to computing the dictionary form on each shape-instantiated
function, rather than once on the underlying generic function/method.
The problem with computing the dictionary format on the generic function
is that we had to force early transformations to create all the
needed/implicit CONVIFACE nodes, since many of these nodes cause the
need for a dictionary entry. Also, the dictionary entries needed can
different with different instantiations of the same generic function,
especially depending on whether a type argument is a non-interface or
interface type, or a instantiated type vs. a non-instantiated type.
By computing the dictionary format on the instantiated function, we are
scanning a function where all the transformations have been done to
create implicit CONVFIFACE nodes, and we know the above relevant
information about the type params (which are shapes).
Much of the change is more mechanical changes from typeparams to shapes,
and generic functions/info to instantiated functions/info. Some of the
most important non-mechanical changes are:
- Separated out the dictionary transformations to nodes into a separate
dictPass, since we need to analyze instantiated functions after
stenciling, but before the dictionary transformations.
- Added type param index to shape types, since we need to be able
distinguish type params of an instantiation which are different but
happen to have the same shape.
- Allow the type substituter to work with shapes again (since for the
dictionary entries we need to substitute shape params to the concrete
type args).
- Support types.IdentityStrict() that does strict type comparison (no
special case for shapes). This needed for type substitution,
formatting and creating dictionaries, etc. We can maybe create better
names for this function.
- Add new information to instInfo to contain a mapping from the shape
type params to their instantiated type bound. This is needed when
doing the dictionary transformations related to type bounds.
Change-Id: I1c3ca312c5384f318c4dd7d0858dba9766396ff6
Reviewed-on: https://go-review.googlesource.com/c/go/+/349613
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org>