]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: refactor zero value size to be a constant
authorAgniva De Sarker <agnivade@yahoo.co.in>
Tue, 23 Jul 2019 17:57:28 +0000 (23:27 +0530)
committerAgniva De Sarker <agniva.quicksilver@gmail.com>
Thu, 29 Aug 2019 08:35:32 +0000 (08:35 +0000)
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>
src/cmd/compile/internal/gc/walk.go
src/runtime/map.go

index 397f549ab171f5986734a24409032cbfb81ffbef..1c445603d9b7205e5a291ee801205ca51315102b 100644 (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)
index 386f9655a490a5b1756757e82edab3b0311c5a04..4861cf08db64f0155d50bab9ad379f2985358651 100644 (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