Source file
src/reflect/map_noswiss_test.go
1
2
3
4
5
6
7 package reflect_test
8
9 import (
10 "internal/abi"
11 "internal/goarch"
12 . "reflect"
13 "testing"
14 )
15
16 func testGCBitsMap(t *testing.T) {
17 const bucketCount = abi.OldMapBucketCount
18
19 hdr := make([]byte, bucketCount/goarch.PtrSize)
20
21 verifyMapBucket := func(t *testing.T, k, e Type, m any, want []byte) {
22 verifyGCBits(t, MapBucketOf(k, e), want)
23 verifyGCBits(t, CachedBucketOf(TypeOf(m)), want)
24 }
25 verifyMapBucket(t,
26 Tscalar, Tptr,
27 map[Xscalar]Xptr(nil),
28 join(hdr, rep(bucketCount, lit(0)), rep(bucketCount, lit(1)), lit(1)))
29 verifyMapBucket(t,
30 Tscalarptr, Tptr,
31 map[Xscalarptr]Xptr(nil),
32 join(hdr, rep(bucketCount, lit(0, 1)), rep(bucketCount, lit(1)), lit(1)))
33 verifyMapBucket(t, Tint64, Tptr,
34 map[int64]Xptr(nil),
35 join(hdr, rep(bucketCount, rep(8/goarch.PtrSize, lit(0))), rep(bucketCount, lit(1)), lit(1)))
36 verifyMapBucket(t,
37 Tscalar, Tscalar,
38 map[Xscalar]Xscalar(nil),
39 empty)
40 verifyMapBucket(t,
41 ArrayOf(2, Tscalarptr), ArrayOf(3, Tptrscalar),
42 map[[2]Xscalarptr][3]Xptrscalar(nil),
43 join(hdr, rep(bucketCount*2, lit(0, 1)), rep(bucketCount*3, lit(1, 0)), lit(1)))
44 verifyMapBucket(t,
45 ArrayOf(64/goarch.PtrSize, Tscalarptr), ArrayOf(64/goarch.PtrSize, Tptrscalar),
46 map[[64 / goarch.PtrSize]Xscalarptr][64 / goarch.PtrSize]Xptrscalar(nil),
47 join(hdr, rep(bucketCount*64/goarch.PtrSize, lit(0, 1)), rep(bucketCount*64/goarch.PtrSize, lit(1, 0)), lit(1)))
48 verifyMapBucket(t,
49 ArrayOf(64/goarch.PtrSize+1, Tscalarptr), ArrayOf(64/goarch.PtrSize, Tptrscalar),
50 map[[64/goarch.PtrSize + 1]Xscalarptr][64 / goarch.PtrSize]Xptrscalar(nil),
51 join(hdr, rep(bucketCount, lit(1)), rep(bucketCount*64/goarch.PtrSize, lit(1, 0)), lit(1)))
52 verifyMapBucket(t,
53 ArrayOf(64/goarch.PtrSize, Tscalarptr), ArrayOf(64/goarch.PtrSize+1, Tptrscalar),
54 map[[64 / goarch.PtrSize]Xscalarptr][64/goarch.PtrSize + 1]Xptrscalar(nil),
55 join(hdr, rep(bucketCount*64/goarch.PtrSize, lit(0, 1)), rep(bucketCount, lit(1)), lit(1)))
56 verifyMapBucket(t,
57 ArrayOf(64/goarch.PtrSize+1, Tscalarptr), ArrayOf(64/goarch.PtrSize+1, Tptrscalar),
58 map[[64/goarch.PtrSize + 1]Xscalarptr][64/goarch.PtrSize + 1]Xptrscalar(nil),
59 join(hdr, rep(bucketCount, lit(1)), rep(bucketCount, lit(1)), lit(1)))
60 }
61
View as plain text