Skip to content

Commit a6edfc5

Browse files
Rename to "ZeroValSize" and document as "ZeroValSize is the size in bytes of runtime.zeroVal."
1 parent 89475c8 commit a6edfc5

File tree

5 files changed

+9
-8
lines changed

5 files changed

+9
-8
lines changed

src/cmd/compile/internal/walk/assign.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ func walkAssignMapRead(init *ir.Nodes, n *ir.AssignListStmt) ir.Node {
169169
a := n.Lhs[0]
170170

171171
var call *ir.CallExpr
172-
if w := t.Elem().Size(); w <= abi.MaxZero {
172+
if w := t.Elem().Size(); w <= abi.ZeroValSize {
173173
fn := mapfn(mapaccess2[fast], t, false)
174174
call = mkcall1(fn, fn.Type().ResultsTuple(), init, reflectdata.IndexMapRType(base.Pos, r), r.X, key)
175175
} else {

src/cmd/compile/internal/walk/expr.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -826,7 +826,7 @@ func walkIndexMap(n *ir.IndexExpr, init *ir.Nodes) ir.Node {
826826
switch {
827827
case n.Assigned:
828828
mapFn = mapfn(mapassign[fast], t, false)
829-
case t.Elem().Size() > abi.MaxZero:
829+
case t.Elem().Size() > abi.ZeroValSize:
830830
args = append(args, reflectdata.ZeroAddr(t.Elem().Size()))
831831
mapFn = mapfn("mapaccess1_fat", t, true)
832832
default:

src/internal/abi/map.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@ const (
1313
MapMaxElemBytes = 128 // Must fit in a uint8.
1414
)
1515

16-
const MaxZero = 1024
16+
// ZeroValSize is the size in bytes of runtime.zeroVal.
17+
const ZeroValSize = 1024

src/reflect/value.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1603,7 +1603,7 @@ func (v Value) IsZero() bool {
16031603
}
16041604
typ := (*abi.ArrayType)(unsafe.Pointer(v.typ()))
16051605
// If the type is comparable, then compare directly with zero.
1606-
if typ.Equal != nil && typ.Size() <= abi.MaxZero {
1606+
if typ.Equal != nil && typ.Size() <= abi.ZeroValSize {
16071607
// v.ptr doesn't escape, as Equal functions are compiler generated
16081608
// and never escape. The escape analysis doesn't know, as it is a
16091609
// function pointer call.
@@ -1631,7 +1631,7 @@ func (v Value) IsZero() bool {
16311631
}
16321632
typ := (*abi.StructType)(unsafe.Pointer(v.typ()))
16331633
// If the type is comparable, then compare directly with zero.
1634-
if v.typ().Equal != nil && v.typ().Size() <= abi.MaxZero {
1634+
if v.typ().Equal != nil && v.typ().Size() <= abi.ZeroValSize {
16351635
// See noescape justification above.
16361636
return typ.Equal(noescape(v.ptr), unsafe.Pointer(&zeroVal[0]))
16371637
}
@@ -3277,7 +3277,7 @@ func Zero(typ Type) Value {
32773277
fl := flag(t.Kind())
32783278
if t.IfaceIndir() {
32793279
var p unsafe.Pointer
3280-
if t.Size() <= abi.MaxZero {
3280+
if t.Size() <= abi.ZeroValSize {
32813281
p = unsafe.Pointer(&zeroVal[0])
32823282
} else {
32833283
p = unsafe_New(t)
@@ -3288,7 +3288,7 @@ func Zero(typ Type) Value {
32883288
}
32893289

32903290
//go:linkname zeroVal runtime.zeroVal
3291-
var zeroVal [abi.MaxZero]byte
3291+
var zeroVal [abi.ZeroValSize]byte
32923292

32933293
// New returns a Value representing a pointer to a new zero value
32943294
// for the specified type. That is, the returned Value's Type is PointerTo(typ).

src/runtime/map.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1436,7 +1436,7 @@ func reflectlite_maplen(h *hmap) int {
14361436
return h.count
14371437
}
14381438

1439-
var zeroVal [abi.MaxZero]byte
1439+
var zeroVal [abi.ZeroValSize]byte
14401440

14411441
// mapinitnoop is a no-op function known the Go linker; if a given global
14421442
// map (of the right size) is determined to be dead, the linker will

0 commit comments

Comments
 (0)