Skip to content

Commit e0e47e2

Browse files
committed
reflect: test repeats with large scalar tails
This adds a GC bitmap test of a type with many pointer bits and a large scalar tail, such as the one in issue #11286. This test would have failed prior to the fix in a8ae93f. This test is a more direct version of the test introduced in that commit (which was distilled from the failing test in the issue). Change-Id: I2e716cd1000b49bde237f5da6d857e8983fe7e7a Reviewed-on: https://go-review.googlesource.com/11423 Reviewed-by: Russ Cox <[email protected]>
1 parent 4b28755 commit e0e47e2

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/reflect/all_test.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4571,8 +4571,12 @@ func TestGCBits(t *testing.T) {
45714571
uintptr
45724572
*byte
45734573
}
4574+
type Xbigptrscalar struct {
4575+
_ [100]*byte
4576+
_ [100]uintptr
4577+
}
45744578

4575-
var Tscalar, Tptr, Tscalarptr, Tptrscalar Type
4579+
var Tscalar, Tptr, Tscalarptr, Tptrscalar, Tbigptrscalar Type
45764580
{
45774581
// Building blocks for types constructed by reflect.
45784582
// This code is in a separate block so that code below
@@ -4591,10 +4595,15 @@ func TestGCBits(t *testing.T) {
45914595
uintptr
45924596
*byte
45934597
}
4598+
type Bigptrscalar struct {
4599+
_ [100]*byte
4600+
_ [100]uintptr
4601+
}
45944602
Tscalar = TypeOf(Scalar{})
45954603
Tptr = TypeOf(Ptr{})
45964604
Tscalarptr = TypeOf(Scalarptr{})
45974605
Tptrscalar = TypeOf(Ptrscalar{})
4606+
Tbigptrscalar = TypeOf(Bigptrscalar{})
45984607
}
45994608

46004609
empty := []byte{}
@@ -4632,6 +4641,8 @@ func TestGCBits(t *testing.T) {
46324641
verifyGCBits(t, ArrayOf(1, ArrayOf(10000, Tptrscalar)), rep(10000, lit(1, 0)))
46334642
verifyGCBits(t, TypeOf([2][10000]Xptrscalar{}), rep(2*10000, lit(1, 0)))
46344643
verifyGCBits(t, ArrayOf(2, ArrayOf(10000, Tptrscalar)), rep(2*10000, lit(1, 0)))
4644+
verifyGCBits(t, TypeOf([4]Xbigptrscalar{}), join(rep(3, join(rep(100, lit(1)), rep(100, lit(0)))), rep(100, lit(1))))
4645+
verifyGCBits(t, ArrayOf(4, Tbigptrscalar), join(rep(3, join(rep(100, lit(1)), rep(100, lit(0)))), rep(100, lit(1))))
46354646

46364647
verifyGCBitsSlice(t, TypeOf([]Xptr{}), 0, empty)
46374648
verifyGCBitsSlice(t, SliceOf(Tptr), 0, empty)
@@ -4657,6 +4668,8 @@ func TestGCBits(t *testing.T) {
46574668
verifyGCBitsSlice(t, SliceOf(ArrayOf(10000, Tptrscalar)), 1, rep(10000, lit(1, 0)))
46584669
verifyGCBitsSlice(t, TypeOf([][10000]Xptrscalar{}), 2, rep(10000, lit(1, 0)))
46594670
verifyGCBitsSlice(t, SliceOf(ArrayOf(10000, Tptrscalar)), 2, rep(10000, lit(1, 0)))
4671+
verifyGCBitsSlice(t, TypeOf([]Xbigptrscalar{}), 4, join(rep(100, lit(1)), rep(100, lit(0))))
4672+
verifyGCBitsSlice(t, SliceOf(Tbigptrscalar), 4, join(rep(100, lit(1)), rep(100, lit(0))))
46604673

46614674
verifyGCBits(t, TypeOf((chan [100]Xscalar)(nil)), lit(1))
46624675
verifyGCBits(t, ChanOf(BothDir, ArrayOf(100, Tscalar)), lit(1))

0 commit comments

Comments
 (0)