mirror of
https://github.com/golang/go
synced 2024-11-23 10:30:03 -07:00
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 <rsc@golang.org>
This commit is contained in:
parent
4b287553a4
commit
e0e47e22ce
@ -4571,8 +4571,12 @@ func TestGCBits(t *testing.T) {
|
||||
uintptr
|
||||
*byte
|
||||
}
|
||||
type Xbigptrscalar struct {
|
||||
_ [100]*byte
|
||||
_ [100]uintptr
|
||||
}
|
||||
|
||||
var Tscalar, Tptr, Tscalarptr, Tptrscalar Type
|
||||
var Tscalar, Tptr, Tscalarptr, Tptrscalar, Tbigptrscalar Type
|
||||
{
|
||||
// Building blocks for types constructed by reflect.
|
||||
// This code is in a separate block so that code below
|
||||
@ -4591,10 +4595,15 @@ func TestGCBits(t *testing.T) {
|
||||
uintptr
|
||||
*byte
|
||||
}
|
||||
type Bigptrscalar struct {
|
||||
_ [100]*byte
|
||||
_ [100]uintptr
|
||||
}
|
||||
Tscalar = TypeOf(Scalar{})
|
||||
Tptr = TypeOf(Ptr{})
|
||||
Tscalarptr = TypeOf(Scalarptr{})
|
||||
Tptrscalar = TypeOf(Ptrscalar{})
|
||||
Tbigptrscalar = TypeOf(Bigptrscalar{})
|
||||
}
|
||||
|
||||
empty := []byte{}
|
||||
@ -4632,6 +4641,8 @@ func TestGCBits(t *testing.T) {
|
||||
verifyGCBits(t, ArrayOf(1, ArrayOf(10000, Tptrscalar)), rep(10000, lit(1, 0)))
|
||||
verifyGCBits(t, TypeOf([2][10000]Xptrscalar{}), rep(2*10000, lit(1, 0)))
|
||||
verifyGCBits(t, ArrayOf(2, ArrayOf(10000, Tptrscalar)), rep(2*10000, lit(1, 0)))
|
||||
verifyGCBits(t, TypeOf([4]Xbigptrscalar{}), join(rep(3, join(rep(100, lit(1)), rep(100, lit(0)))), rep(100, lit(1))))
|
||||
verifyGCBits(t, ArrayOf(4, Tbigptrscalar), join(rep(3, join(rep(100, lit(1)), rep(100, lit(0)))), rep(100, lit(1))))
|
||||
|
||||
verifyGCBitsSlice(t, TypeOf([]Xptr{}), 0, empty)
|
||||
verifyGCBitsSlice(t, SliceOf(Tptr), 0, empty)
|
||||
@ -4657,6 +4668,8 @@ func TestGCBits(t *testing.T) {
|
||||
verifyGCBitsSlice(t, SliceOf(ArrayOf(10000, Tptrscalar)), 1, rep(10000, lit(1, 0)))
|
||||
verifyGCBitsSlice(t, TypeOf([][10000]Xptrscalar{}), 2, rep(10000, lit(1, 0)))
|
||||
verifyGCBitsSlice(t, SliceOf(ArrayOf(10000, Tptrscalar)), 2, rep(10000, lit(1, 0)))
|
||||
verifyGCBitsSlice(t, TypeOf([]Xbigptrscalar{}), 4, join(rep(100, lit(1)), rep(100, lit(0))))
|
||||
verifyGCBitsSlice(t, SliceOf(Tbigptrscalar), 4, join(rep(100, lit(1)), rep(100, lit(0))))
|
||||
|
||||
verifyGCBits(t, TypeOf((chan [100]Xscalar)(nil)), lit(1))
|
||||
verifyGCBits(t, ChanOf(BothDir, ArrayOf(100, Tscalar)), lit(1))
|
||||
|
Loading…
Reference in New Issue
Block a user