Commit 61089984 authored by Dmitry Vyukov's avatar Dmitry Vyukov

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: default avatarKeith Randall <khr@golang.org>
parent f71bd516
...@@ -66,6 +66,12 @@ func getitab(inter *interfacetype, typ *_type, canfail bool) *itab { ...@@ -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 = (*itab)(persistentalloc(unsafe.Sizeof(itab{})+uintptr(len(inter.mhdr)-1)*sys.PtrSize, 0, &memstats.other_sys))
m.inter = inter m.inter = inter
m._type = typ 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() m.init()
itabAdd(m) itabAdd(m)
unlock(&itabLock) unlock(&itabLock)
...@@ -233,7 +239,6 @@ imethods: ...@@ -233,7 +239,6 @@ imethods:
return iname return iname
} }
m.fun[0] = uintptr(fun0) m.fun[0] = uintptr(fun0)
m.hash = typ.hash
return "" return ""
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment