Commit 8e4399ff authored by Agniva De Sarker's avatar Agniva De Sarker Committed by Agniva De Sarker

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: default avatarKeith Randall <khr@golang.org>
Reviewed-by: default avatarMartin Möhrmann <moehrmann@google.com>
parent 5d1a9517
......@@ -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)
......
......@@ -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
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