if n.X.Type().IsChan() && n.Op() == ir.OCAP {
s.Fatalf("cannot inline cap(chan)") // must use runtime.chancap now
}
+ if n.X.Type().IsMap() && n.Op() == ir.OCAP {
+ s.Fatalf("cannot inline cap(map)") // cap(map) does not exist
+ }
// if n == nil {
// return 0
// } else {
- // // len
- // return *((*int)n)
- // // cap
+ // // len, the actual loadType depends
+ // return int(*((*loadType)n))
+ // // cap (chan only, not used for now)
// return *(((*int)n)+1)
// }
lenType := n.Type()
case ir.OLEN:
if buildcfg.Experiment.SwissMap && n.X.Type().IsMap() {
// length is stored in the first word.
- s.vars[n] = s.load(lenType, x)
+ loadType := reflectdata.SwissMapType().Field(0).Type // uint64
+ load := s.load(loadType, x)
+ s.vars[n] = s.conv(nil, load, loadType, lenType) // integer conversion doesn't need Node
} else {
// length is stored in the first word for map/chan
s.vars[n] = s.load(lenType, x)
type Map struct {
// The number of filled slots (i.e. the number of elements in all
// tables). Excludes deleted slots.
+ // Must be first (known by the compiler, for len() builtin).
used uint64
// seed is the hash seed, computed as a unique random number per map.