@@ -956,7 +956,10 @@ func (n *structFieldInfoPathNode) rvField(v reflect.Value) (rv reflect.Value) {
956
956
// Note that as of Jan 2021 (go 1.16 release), go:linkname(s) are not inlined
957
957
// outside of the standard library use (e.g. within sync, reflect, etc).
958
958
//
959
- // Consequently, these do not necessarily give a performance boost, as a function overhead
959
+ // Consequently, these do not necessarily give a performance boost, as a function overhead.
960
+ //
961
+ // Also, we link to the functions in reflect where possible, as opposed to those in runtime.
962
+ // They are guaranteed to be safer for our use, even when they are just trampoline functions.
960
963
961
964
//go:linkname maplen reflect.maplen
962
965
//go:noescape
@@ -986,34 +989,32 @@ func mapassign(typ unsafe.Pointer, m unsafe.Pointer, key, val unsafe.Pointer)
986
989
//go:noescape
987
990
func mapdelete (typ unsafe.Pointer , m unsafe.Pointer , key unsafe.Pointer )
988
991
989
- //go:linkname typedmemmove runtime.typedmemmove
990
- //go:noescape
991
- func typedmemmove (typ unsafe.Pointer , dst , src unsafe.Pointer )
992
-
993
- //go:linkname typedmemclr runtime.typedmemclr
992
+ //go:linkname unsafe_New reflect.unsafe_New
994
993
//go:noescape
995
- func typedmemclr (typ unsafe.Pointer , dst unsafe.Pointer )
994
+ func unsafe_New (typ unsafe.Pointer ) unsafe.Pointer
996
995
997
996
//go:linkname typedslicecopy reflect.typedslicecopy
998
997
//go:noescape
999
998
func typedslicecopy (elemType unsafe.Pointer , dst , src unsafeSlice ) int
1000
999
1001
- //go:linkname unsafe_New reflect.unsafe_New
1000
+ //go:linkname typedmemmove reflect.typedmemmove
1002
1001
//go:noescape
1003
- func unsafe_New (typ unsafe.Pointer ) unsafe.Pointer
1002
+ func typedmemmove (typ unsafe.Pointer , dst , src unsafe.Pointer )
1003
+
1004
+ //go:linkname typedmemclr reflect.typedmemclr
1005
+ //go:noescape
1006
+ func typedmemclr (typ unsafe.Pointer , dst unsafe.Pointer )
1004
1007
1005
1008
//go:linkname memhash runtime.memhash
1006
1009
//go:noescape
1007
1010
func memhash (p unsafe.Pointer , seed , length uintptr ) uintptr
1008
1011
1009
- // //go:linkname memmove reflect.memmove
1010
- // //go:noescape
1011
- // func memmove(dst, src unsafe.Pointer, n int)
1012
-
1013
1012
// ---------- others ---------------
1014
1013
1015
1014
func hashShortString (b []byte ) uintptr {
1016
1015
return memhash (unsafe .Pointer (& b [0 ]), 0 , uintptr (len (b )))
1017
1016
}
1018
1017
1019
1018
// var _ = runtime.MemProfileRate
1019
+ // func maplen(typ unsafe.Pointer) int { return *((*int)(typ)) }
1020
+ // func chanlen(typ unsafe.Pointer) int { return int(*((*uint)(typ))) }
0 commit comments