From b1fd277318fbc0d90b2befee915f2f542c143a6d Mon Sep 17 00:00:00 2001 From: Cuong Manh Le Date: Fri, 30 Sep 2022 11:51:48 +0700 Subject: [PATCH] cmd/compile: use memhash from package runtime Simplify the code, and prevent creating ONAME node with nil Func. Passes toolstash-check. Change-Id: I5e5be660510dc0ef5521d278c6b9214a80b994eb Reviewed-on: https://go-review.googlesource.com/c/go/+/436958 Run-TryBot: Cuong Manh Le TryBot-Result: Gopher Robot Reviewed-by: Matthew Dempsky Reviewed-by: Keith Randall Reviewed-by: Michael Knyszek --- src/cmd/compile/internal/reflectdata/alg.go | 14 ++------------ .../compile/internal/typecheck/_builtin/runtime.go | 2 +- src/cmd/compile/internal/typecheck/builtin.go | 2 +- 3 files changed, 4 insertions(+), 14 deletions(-) diff --git a/src/cmd/compile/internal/reflectdata/alg.go b/src/cmd/compile/internal/reflectdata/alg.go index 4577e9cfc4..4f174a3bb8 100644 --- a/src/cmd/compile/internal/reflectdata/alg.go +++ b/src/cmd/compile/internal/reflectdata/alg.go @@ -595,17 +595,7 @@ func anyCall(fn *ir.Func) bool { } func hashmem(t *types.Type) ir.Node { - sym := ir.Pkgs.Runtime.Lookup("memhash") - - // TODO(austin): This creates an ir.Name with a nil Func. - n := typecheck.NewName(sym) - ir.MarkFunc(n) - n.SetType(types.NewSignature(nil, []*types.Field{ - types.NewField(base.Pos, nil, types.NewPtr(t)), - types.NewField(base.Pos, nil, types.Types[types.TUINTPTR]), - types.NewField(base.Pos, nil, types.Types[types.TUINTPTR]), - }, []*types.Field{ - types.NewField(base.Pos, nil, types.Types[types.TUINTPTR]), - })) + n := typecheck.LookupRuntime("memhash") + n = typecheck.SubstArgTypes(n, t) return n } diff --git a/src/cmd/compile/internal/typecheck/_builtin/runtime.go b/src/cmd/compile/internal/typecheck/_builtin/runtime.go index 69c456a557..3b32044756 100644 --- a/src/cmd/compile/internal/typecheck/_builtin/runtime.go +++ b/src/cmd/compile/internal/typecheck/_builtin/runtime.go @@ -207,7 +207,7 @@ func strequal(p, q unsafe.Pointer) bool func interequal(p, q unsafe.Pointer) bool func nilinterequal(p, q unsafe.Pointer) bool -func memhash(p unsafe.Pointer, h uintptr, size uintptr) uintptr +func memhash(x *any, h uintptr, size uintptr) uintptr func memhash0(p unsafe.Pointer, h uintptr) uintptr func memhash8(p unsafe.Pointer, h uintptr) uintptr func memhash16(p unsafe.Pointer, h uintptr) uintptr diff --git a/src/cmd/compile/internal/typecheck/builtin.go b/src/cmd/compile/internal/typecheck/builtin.go index 6aa5e391fc..9be354e38d 100644 --- a/src/cmd/compile/internal/typecheck/builtin.go +++ b/src/cmd/compile/internal/typecheck/builtin.go @@ -361,7 +361,7 @@ func runtimeTypes() []*types.Type { typs[123] = newSig(params(typs[3], typs[3], typs[5]), params(typs[6])) typs[124] = newSig(params(typs[3], typs[3]), params(typs[6])) typs[125] = newSig(params(typs[7], typs[7]), params(typs[6])) - typs[126] = newSig(params(typs[7], typs[5], typs[5]), params(typs[5])) + typs[126] = newSig(params(typs[3], typs[5], typs[5]), params(typs[5])) typs[127] = newSig(params(typs[7], typs[5]), params(typs[5])) typs[128] = newSig(params(typs[22], typs[22]), params(typs[22])) typs[129] = newSig(params(typs[24], typs[24]), params(typs[24])) -- 2.48.1