import (
"go/constant"
+ "internal/abi"
"cmd/compile/internal/base"
"cmd/compile/internal/ir"
a := n.Lhs[0]
var call *ir.CallExpr
- if w := t.Elem().Size(); w <= zeroValSize {
+ if w := t.Elem().Size(); w <= abi.ZeroValSize {
fn := mapfn(mapaccess2[fast], t, false)
call = mkcall1(fn, fn.Type().ResultsTuple(), init, reflectdata.IndexMapRType(base.Pos, r), r.X, key)
} else {
import (
"fmt"
"go/constant"
+ "internal/abi"
"internal/buildcfg"
"strings"
switch {
case n.Assigned:
mapFn = mapfn(mapassign[fast], t, false)
- case t.Elem().Size() > zeroValSize:
+ case t.Elem().Size() > abi.ZeroValSize:
args = append(args, reflectdata.ZeroAddr(t.Elem().Size()))
mapFn = mapfn("mapaccess1_fat", t, true)
default:
}
typ := (*abi.ArrayType)(unsafe.Pointer(v.typ()))
// If the type is comparable, then compare directly with zero.
- if typ.Equal != nil && typ.Size() <= maxZero {
+ if typ.Equal != nil && typ.Size() <= abi.ZeroValSize {
// v.ptr doesn't escape, as Equal functions are compiler generated
// and never escape. The escape analysis doesn't know, as it is a
// function pointer call.
}
typ := (*abi.StructType)(unsafe.Pointer(v.typ()))
// If the type is comparable, then compare directly with zero.
- if typ.Equal != nil && typ.Size() <= maxZero {
+ if typ.Equal != nil && typ.Size() <= abi.ZeroValSize {
// See noescape justification above.
return typ.Equal(noescape(v.ptr), unsafe.Pointer(&zeroVal[0]))
}
fl := flag(t.Kind())
if t.IfaceIndir() {
var p unsafe.Pointer
- if t.Size() <= maxZero {
+ if t.Size() <= abi.ZeroValSize {
p = unsafe.Pointer(&zeroVal[0])
} else {
p = unsafe_New(t)
return Value{t, nil, fl}
}
-// must match declarations in runtime/map.go.
-const maxZero = 1024
-
//go:linkname zeroVal runtime.zeroVal
-var zeroVal [maxZero]byte
+var zeroVal [abi.ZeroValSize]byte
// New returns a Value representing a pointer to a new zero value
// for the specified type. That is, the returned Value's Type is PointerTo(typ).
return h.count
}
-const maxZero = 1024 // must match value in reflect/value.go:maxZero cmd/compile/internal/gc/walk.go:zeroValSize
-var zeroVal [maxZero]byte
+var zeroVal [abi.ZeroValSize]byte
// mapinitnoop is a no-op function known the Go linker; if a given global
// map (of the right size) is determined to be dead, the linker will