]> Cypherpunks.ru repositories - gostls13.git/commit
cmd/compile: switch to computing dict format on instantiated functions
authorDan Scales <danscales@google.com>
Mon, 13 Sep 2021 20:53:18 +0000 (13:53 -0700)
committerDan Scales <danscales@google.com>
Wed, 15 Sep 2021 22:53:17 +0000 (22:53 +0000)
commit59a9a035ffa34c26a287d124180f6eca7c912311
tree3101120a9e68c7a3eae9b4dfa10a356323324aeb
parent0edc6c4fa088a74bef98d55cc93ffa387d4f7b2d
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>
src/cmd/compile/internal/noder/irgen.go
src/cmd/compile/internal/noder/stencil.go
src/cmd/compile/internal/reflectdata/reflect.go
src/cmd/compile/internal/typecheck/subr.go
src/cmd/compile/internal/types/identity.go