diff options
author | Dan Scales <danscales@google.com> | 2021-06-01 10:49:14 -0700 |
---|---|---|
committer | Dan Scales <danscales@google.com> | 2021-06-04 17:48:10 +0000 |
commit | de614651561c6d5bfe1e68bddaf0dedab9a0ecb0 (patch) | |
tree | a39ef75b81e36091467f1e09765ed4022475c1d0 /src/cmd/compile/internal/gc | |
parent | 4cf7f5f6947c1e3200d669ae7b8016f7431d718c (diff) | |
download | go-de614651561c6d5bfe1e68bddaf0dedab9a0ecb0.tar.gz go-de614651561c6d5bfe1e68bddaf0dedab9a0ecb0.zip |
[dev.typeparams] cmd/compile: allow inlining in instantiated functions
Change markType to scan generic types and methods, so that inlineable
functions inside generic functions/methods will be properly marked for
export, which means inlining inside instantiated functions will work
correctly.
Also, fix handling of closures for instantiated functions. Some code
needs to be adjusted, since instantiated functions/methods are compiled
as if in the package of the source generic function/type, rather than in
the local package. When we create the closure struct, we want to make
sure that the .F field has the same package as the other fields for the
closure variables. Also, we need to disable a check in tcCompLit() when
being done for an instantiated function, since fields of the closure
struct will be from the source package, not the local package.
Re-enabled part of the orderedmapsimp test that was disabled because of
these issues.
Change-Id: Ic4dba8917da0a36b17c0bdb69d6d6edfdf14104a
Reviewed-on: https://go-review.googlesource.com/c/go/+/324331
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Dan Scales <danscales@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Diffstat (limited to 'src/cmd/compile/internal/gc')
-rw-r--r-- | src/cmd/compile/internal/gc/export.go | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/cmd/compile/internal/gc/export.go b/src/cmd/compile/internal/gc/export.go index e19d52fa95..a11e5fdd30 100644 --- a/src/cmd/compile/internal/gc/export.go +++ b/src/cmd/compile/internal/gc/export.go @@ -94,15 +94,14 @@ func (p *exporter) markObject(n ir.Node) { // markType recursively visits types reachable from t to identify // functions whose inline bodies may be needed. func (p *exporter) markType(t *types.Type) { - if p.marked[t] { + if t.IsInstantiatedGeneric() { + // Re-instantiated types don't add anything new, so don't follow them. return } - p.marked[t] = true - if t.HasTParam() { - // Don't deal with any generic types or their methods, since we - // will only be inlining actual instantiations, not generic methods. + if p.marked[t] { return } + p.marked[t] = true // If this is a named type, mark all of its associated // methods. Skip interface types because t.Methods contains @@ -159,5 +158,8 @@ func (p *exporter) markType(t *types.Type) { p.markType(f.Type) } } + + case types.TTYPEPARAM: + // No other type that needs to be followed. } } |