1// run 2 3// Copyright 2019 The Go Authors. All rights reserved. 4// Use of this source code is governed by a BSD-style 5// license that can be found in the LICENSE file. 6 7package main 8 9import "reflect" 10 11func main() {} 12 13func typ(x interface{}) reflect.Type { return reflect.ValueOf(x).Type() } 14 15var byteType = typ((byte)(0)) 16var ptrType = typ((*byte)(nil)) 17 18// Arrays of pointers. There are two size thresholds. 19// Bit masks are chunked in groups of 120 pointers. 20// Array types with >16384 pointers have a GC program instead of a bitmask. 21var smallPtrType = reflect.ArrayOf(100, ptrType) 22var mediumPtrType = reflect.ArrayOf(1000, ptrType) 23var bigPtrType = reflect.ArrayOf(16385, ptrType) 24 25var x0 = reflect.New(reflect.StructOf([]reflect.StructField{ 26 {Name: "F1", Type: byteType}, 27 {Name: "F2", Type: bigPtrType}, 28})) 29var x1 = reflect.New(reflect.StructOf([]reflect.StructField{ 30 {Name: "F1", Type: smallPtrType}, 31 {Name: "F2", Type: bigPtrType}, 32})) 33var x2 = reflect.New(reflect.StructOf([]reflect.StructField{ 34 {Name: "F1", Type: mediumPtrType}, 35 {Name: "F2", Type: bigPtrType}, 36})) 37var x3 = reflect.New(reflect.StructOf([]reflect.StructField{ 38 {Name: "F1", Type: ptrType}, 39 {Name: "F2", Type: byteType}, 40 {Name: "F3", Type: bigPtrType}, 41})) 42var x4 = reflect.New(reflect.StructOf([]reflect.StructField{ 43 {Name: "F1", Type: ptrType}, 44 {Name: "F2", Type: smallPtrType}, 45 {Name: "F3", Type: bigPtrType}, 46})) 47var x5 = reflect.New(reflect.StructOf([]reflect.StructField{ 48 {Name: "F1", Type: ptrType}, 49 {Name: "F2", Type: mediumPtrType}, 50 {Name: "F3", Type: bigPtrType}, 51})) 52