@@ -1694,13 +1694,13 @@ func MapOf(key, elem Type) Type {
1694
1694
return typehash (ktyp , p , seed )
1695
1695
}
1696
1696
mt .Flags = 0
1697
- if ktyp .Size_ > maxKeySize {
1697
+ if ktyp .Size_ > abi . MapMaxKeyBytes {
1698
1698
mt .KeySize = uint8 (goarch .PtrSize )
1699
1699
mt .Flags |= 1 // indirect key
1700
1700
} else {
1701
1701
mt .KeySize = uint8 (ktyp .Size_ )
1702
1702
}
1703
- if etyp .Size_ > maxValSize {
1703
+ if etyp .Size_ > abi . MapMaxElemBytes {
1704
1704
mt .ValueSize = uint8 (goarch .PtrSize )
1705
1705
mt .Flags |= 2 // indirect value
1706
1706
} else {
@@ -1954,21 +1954,11 @@ func hashMightPanic(t *abi.Type) bool {
1954
1954
}
1955
1955
}
1956
1956
1957
- // Make sure these routines stay in sync with ../runtime/map.go!
1958
- // These types exist only for GC, so we only fill out GC relevant info.
1959
- // Currently, that's just size and the GC program. We also fill in string
1960
- // for possible debugging use.
1961
- const (
1962
- bucketSize uintptr = abi .MapBucketCount
1963
- maxKeySize uintptr = abi .MapMaxKeyBytes
1964
- maxValSize uintptr = abi .MapMaxElemBytes
1965
- )
1966
-
1967
1957
func bucketOf (ktyp , etyp * abi.Type ) * abi.Type {
1968
- if ktyp .Size_ > maxKeySize {
1958
+ if ktyp .Size_ > abi . MapMaxKeyBytes {
1969
1959
ktyp = ptrTo (ktyp )
1970
1960
}
1971
- if etyp .Size_ > maxValSize {
1961
+ if etyp .Size_ > abi . MapMaxElemBytes {
1972
1962
etyp = ptrTo (etyp )
1973
1963
}
1974
1964
@@ -1980,29 +1970,29 @@ func bucketOf(ktyp, etyp *abi.Type) *abi.Type {
1980
1970
var gcdata * byte
1981
1971
var ptrdata uintptr
1982
1972
1983
- size := bucketSize * (1 + ktyp .Size_ + etyp .Size_ ) + goarch .PtrSize
1973
+ size := abi . MapBucketCount * (1 + ktyp .Size_ + etyp .Size_ ) + goarch .PtrSize
1984
1974
if size & uintptr (ktyp .Align_ - 1 ) != 0 || size & uintptr (etyp .Align_ - 1 ) != 0 {
1985
1975
panic ("reflect: bad size computation in MapOf" )
1986
1976
}
1987
1977
1988
1978
if ktyp .PtrBytes != 0 || etyp .PtrBytes != 0 {
1989
- nptr := (bucketSize * (1 + ktyp .Size_ + etyp .Size_ ) + goarch .PtrSize ) / goarch .PtrSize
1979
+ nptr := (abi . MapBucketCount * (1 + ktyp .Size_ + etyp .Size_ ) + goarch .PtrSize ) / goarch .PtrSize
1990
1980
n := (nptr + 7 ) / 8
1991
1981
1992
1982
// Runtime needs pointer masks to be a multiple of uintptr in size.
1993
1983
n = (n + goarch .PtrSize - 1 ) &^ (goarch .PtrSize - 1 )
1994
1984
mask := make ([]byte , n )
1995
- base := bucketSize / goarch .PtrSize
1985
+ base := uintptr ( abi . MapBucketCount / goarch .PtrSize )
1996
1986
1997
1987
if ktyp .PtrBytes != 0 {
1998
- emitGCMask (mask , base , ktyp , bucketSize )
1988
+ emitGCMask (mask , base , ktyp , abi . MapBucketCount )
1999
1989
}
2000
- base += bucketSize * ktyp .Size_ / goarch .PtrSize
1990
+ base += abi . MapBucketCount * ktyp .Size_ / goarch .PtrSize
2001
1991
2002
1992
if etyp .PtrBytes != 0 {
2003
- emitGCMask (mask , base , etyp , bucketSize )
1993
+ emitGCMask (mask , base , etyp , abi . MapBucketCount )
2004
1994
}
2005
- base += bucketSize * etyp .Size_ / goarch .PtrSize
1995
+ base += abi . MapBucketCount * etyp .Size_ / goarch .PtrSize
2006
1996
2007
1997
word := base
2008
1998
mask [word / 8 ] |= 1 << (word % 8 )
0 commit comments