diff options
| author | Cuong Manh Le <cuong.manhle.vn@gmail.com> | 2022-09-30 12:04:46 +0700 |
|---|---|---|
| committer | Cuong Manh Le <cuong.manhle.vn@gmail.com> | 2023-02-04 07:02:59 +0000 |
| commit | fcff7226f3aa4e92302a9475d23c254ff6dccedb (patch) | |
| tree | 52a990f8f1bf133f5ff001fd755eaa50bc1cc926 /src/cmd/compile/internal/reflectdata/alg.go | |
| parent | b1fd277318fbc0d90b2befee915f2f542c143a6d (diff) | |
| download | go-fcff7226f3aa4e92302a9475d23c254ff6dccedb.tar.xz | |
cmd/compile: use runtime hash func for known types
Those functions are defined in package runtime already, so just use them
instead of creating ONAME nodes with nil Func.
Change-Id: If29814a5254793c578c15b70f9c194b7414911d4
Reviewed-on: https://go-review.googlesource.com/c/go/+/436959
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Diffstat (limited to 'src/cmd/compile/internal/reflectdata/alg.go')
| -rw-r--r-- | src/cmd/compile/internal/reflectdata/alg.go | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/src/cmd/compile/internal/reflectdata/alg.go b/src/cmd/compile/internal/reflectdata/alg.go index 4f174a3bb8..bcc5112b8e 100644 --- a/src/cmd/compile/internal/reflectdata/alg.go +++ b/src/cmd/compile/internal/reflectdata/alg.go @@ -235,6 +235,12 @@ func genhash(t *types.Type) *obj.LSym { return closure } +func runtimeHashFor(name string, t *types.Type) *ir.Name { + n := typecheck.LookupRuntime(name) + n = typecheck.SubstArgTypes(n, t) + return n +} + func hashfor(t *types.Type) ir.Node { var sym *types.Sym @@ -242,19 +248,19 @@ func hashfor(t *types.Type) ir.Node { case types.AMEM: base.Fatalf("hashfor with AMEM type") case types.AINTER: - sym = ir.Pkgs.Runtime.Lookup("interhash") + return runtimeHashFor("interhash", t) case types.ANILINTER: - sym = ir.Pkgs.Runtime.Lookup("nilinterhash") + return runtimeHashFor("nilinterhash", t) case types.ASTRING: - sym = ir.Pkgs.Runtime.Lookup("strhash") + return runtimeHashFor("strhash", t) case types.AFLOAT32: - sym = ir.Pkgs.Runtime.Lookup("f32hash") + return runtimeHashFor("f32hash", t) case types.AFLOAT64: - sym = ir.Pkgs.Runtime.Lookup("f64hash") + return runtimeHashFor("f64hash", t) case types.ACPLX64: - sym = ir.Pkgs.Runtime.Lookup("c64hash") + return runtimeHashFor("c64hash", t) case types.ACPLX128: - sym = ir.Pkgs.Runtime.Lookup("c128hash") + return runtimeHashFor("c128hash", t) default: // Note: the caller of hashfor ensured that this symbol // exists and has a body by calling genhash for t. |
