From: Matthew Dempsky Date: Sun, 20 Dec 2020 03:26:06 +0000 (-0800) Subject: [dev.regabi] cmd/compile: move itabname call out of implements X-Git-Tag: go1.17beta1~1539^2~283 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=06915ac14dfb7c80f384e3446bc6fa474e6bfa94;p=gostls13.git [dev.regabi] cmd/compile: move itabname call out of implements We only need to call itabname when actually creating the OCONVIFACE ops, not any time we test whether a type implements an interface. Additionally, by moving this call out of implements, we make it purely based on types, which makes it safe to move to package types. Does not pass toolstash -cmp, because it shuffles symbol creation order. Change-Id: Iea8e0c9374218f4d97b4339020ebd758d051bd03 Reviewed-on: https://go-review.googlesource.com/c/go/+/279333 Reviewed-by: Russ Cox Run-TryBot: Russ Cox TryBot-Result: Go Bot Trust: Matthew Dempsky --- diff --git a/src/cmd/compile/internal/gc/subr.go b/src/cmd/compile/internal/gc/subr.go index 2b0047e150..48cbd2505e 100644 --- a/src/cmd/compile/internal/gc/subr.go +++ b/src/cmd/compile/internal/gc/subr.go @@ -304,6 +304,14 @@ func assignop(src, dst *types.Type) (ir.Op, string) { var missing, have *types.Field var ptr int if implements(src, dst, &missing, &have, &ptr) { + // Call itabname so that (src, dst) + // gets added to itabs early, which allows + // us to de-virtualize calls through this + // type/interface pair later. See peekitabs in reflect.go + if isdirectiface(src) && !dst.IsEmptyInterface() { + itabname(src, dst) + } + return ir.OCONVIFACE, "" } @@ -1404,14 +1412,6 @@ func implements(t, iface *types.Type, m, samename **types.Field, ptr *int) bool } } - // We're going to emit an OCONVIFACE. - // Call itabname so that (t, iface) - // gets added to itabs early, which allows - // us to de-virtualize calls through this - // type/interface pair later. See peekitabs in reflect.go - if isdirectiface(t0) && !iface.IsEmptyInterface() { - itabname(t0, iface) - } return true }