diff options
author | Dmitry Vyukov <dvyukov@google.com> | 2019-10-22 14:20:51 +0200 |
---|---|---|
committer | Dmitry Vyukov <dvyukov@google.com> | 2019-11-06 09:08:53 +0000 |
commit | 61089984a89743af1d8bad569dcffe62f00a6970 (patch) | |
tree | 45c28d6ba3101fa0197336aaecd99392997b6fc5 /src/runtime/iface.go | |
parent | f71bd516b7003abed2c86b64ade6c0026075b6e8 (diff) | |
download | go-61089984a89743af1d8bad569dcffe62f00a6970.tar.gz go-61089984a89743af1d8bad569dcffe62f00a6970.zip |
runtime: clarify that itab.hash of dynamic entries is unused
The hash is used in type switches. However, compiler statically generates itab's
for all interface/type pairs used in switches (which are added to itabTable
in itabsinit). The dynamically-generated itab's never participate in type switches,
and thus the hash is irrelevant.
Change-Id: I4f6e37be31b8f5605cca7a1806cb04708e948cea
Reviewed-on: https://go-review.googlesource.com/c/go/+/202448
Run-TryBot: Dmitry Vyukov <dvyukov@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Diffstat (limited to 'src/runtime/iface.go')
-rw-r--r-- | src/runtime/iface.go | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/runtime/iface.go b/src/runtime/iface.go index 243e51fc48..05de282aa7 100644 --- a/src/runtime/iface.go +++ b/src/runtime/iface.go @@ -66,6 +66,12 @@ func getitab(inter *interfacetype, typ *_type, canfail bool) *itab { m = (*itab)(persistentalloc(unsafe.Sizeof(itab{})+uintptr(len(inter.mhdr)-1)*sys.PtrSize, 0, &memstats.other_sys)) m.inter = inter m._type = typ + // The hash is used in type switches. However, compiler statically generates itab's + // for all interface/type pairs used in switches (which are added to itabTable + // in itabsinit). The dynamically-generated itab's never participate in type switches, + // and thus the hash is irrelevant. + // Note: m.hash is _not_ the hash used for the runtime itabTable hash table. + m.hash = 0 m.init() itabAdd(m) unlock(&itabLock) @@ -233,7 +239,6 @@ imethods: return iname } m.fun[0] = uintptr(fun0) - m.hash = typ.hash return "" } |