1
0
mirror of https://github.com/golang/go synced 2024-11-23 22:50:05 -07:00

cmd/compile: refactor zero value size to be a constant

Change-Id: I31dd4fb55d5974cd45de00148039d04f8a7d5cb3
Reviewed-on: https://go-review.googlesource.com/c/go/+/187257
Run-TryBot: Agniva De Sarker <agniva.quicksilver@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Martin Möhrmann <moehrmann@google.com>
This commit is contained in:
Agniva De Sarker 2019-07-23 23:27:28 +05:30 committed by Agniva De Sarker
parent 5d1a95175e
commit 8e4399ff77
2 changed files with 4 additions and 3 deletions

View File

@ -15,6 +15,7 @@ import (
// The constant is known to runtime.
const tmpstringbufsize = 32
const zeroValSize = 1024 // must match value of runtime/map.go:maxZero
func walk(fn *Node) {
Curfn = fn
@ -756,7 +757,7 @@ opswitch:
// a = *var
a := n.List.First()
if w := t.Elem().Width; w <= 1024 { // 1024 must match runtime/map.go:maxZero
if w := t.Elem().Width; w <= zeroValSize {
fn := mapfn(mapaccess2[fast], t)
r = mkcall1(fn, fn.Type.Results(), init, typename(t), r.Left, key)
} else {
@ -1093,7 +1094,7 @@ opswitch:
key = nod(OADDR, key, nil)
}
if w := t.Elem().Width; w <= 1024 { // 1024 must match runtime/map.go:maxZero
if w := t.Elem().Width; w <= zeroValSize {
n = mkcall1(mapfn(mapaccess1[fast], t), types.NewPtr(t.Elem()), init, typename(t), map_, key)
} else {
z := zeroaddr(w)

View File

@ -1386,5 +1386,5 @@ func reflect_ismapkey(t *_type) bool {
return ismapkey(t)
}
const maxZero = 1024 // must match value in cmd/compile/internal/gc/walk.go
const maxZero = 1024 // must match value in cmd/compile/internal/gc/walk.go:zeroValSize
var zeroVal [maxZero]byte