2014-11-11 15:05:19 -07:00
|
|
|
// Copyright 2009 The Go Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
2015-01-21 23:31:49 -07:00
|
|
|
// Runtime type representation.
|
2014-11-11 15:05:19 -07:00
|
|
|
|
|
|
|
package runtime
|
|
|
|
|
|
|
|
import "unsafe"
|
|
|
|
|
2015-03-11 13:58:47 -06:00
|
|
|
// Needs to be in sync with ../../cmd/internal/ld/decodesym.go:/^commonsize and pkg/reflect/type.go:/type.
|
2014-11-11 15:05:19 -07:00
|
|
|
type _type struct {
|
|
|
|
size uintptr
|
|
|
|
hash uint32
|
|
|
|
_unused uint8
|
|
|
|
align uint8
|
|
|
|
fieldalign uint8
|
|
|
|
kind uint8
|
2014-12-27 21:32:11 -07:00
|
|
|
alg *typeAlg
|
2015-01-21 23:31:49 -07:00
|
|
|
// gc stores type info required for garbage collector.
|
2014-11-11 15:05:19 -07:00
|
|
|
// If (kind&KindGCProg)==0, then gc[0] points at sparse GC bitmap
|
|
|
|
// (no indirection), 4 bits per word.
|
|
|
|
// If (kind&KindGCProg)!=0, then gc[1] points to a compiler-generated
|
|
|
|
// read-only GC program; and gc[0] points to BSS space for sparse GC bitmap.
|
2015-01-21 23:31:49 -07:00
|
|
|
// For huge types (>maxGCMask), runtime unrolls the program directly into
|
|
|
|
// GC bitmap and gc[0] is not used. For moderately-sized types, runtime
|
2014-11-11 15:05:19 -07:00
|
|
|
// unrolls the program into gc[0] space on first use. The first byte of gc[0]
|
|
|
|
// (gc[0][0]) contains 'unroll' flag saying whether the program is already
|
|
|
|
// unrolled into gc[0] or not.
|
|
|
|
gc [2]uintptr
|
|
|
|
_string *string
|
|
|
|
x *uncommontype
|
|
|
|
ptrto *_type
|
2015-01-21 23:31:49 -07:00
|
|
|
zero *byte // ptr to the zero value for this type
|
2014-11-11 15:05:19 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
type method struct {
|
|
|
|
name *string
|
|
|
|
pkgpath *string
|
|
|
|
mtyp *_type
|
|
|
|
typ *_type
|
|
|
|
ifn unsafe.Pointer
|
|
|
|
tfn unsafe.Pointer
|
|
|
|
}
|
|
|
|
|
|
|
|
type uncommontype struct {
|
|
|
|
name *string
|
|
|
|
pkgpath *string
|
|
|
|
mhdr []method
|
|
|
|
}
|
|
|
|
|
|
|
|
type imethod struct {
|
|
|
|
name *string
|
|
|
|
pkgpath *string
|
|
|
|
_type *_type
|
|
|
|
}
|
|
|
|
|
|
|
|
type interfacetype struct {
|
|
|
|
typ _type
|
|
|
|
mhdr []imethod
|
|
|
|
}
|
|
|
|
|
|
|
|
type maptype struct {
|
|
|
|
typ _type
|
|
|
|
key *_type
|
|
|
|
elem *_type
|
2015-01-21 23:31:49 -07:00
|
|
|
bucket *_type // internal type representing a hash bucket
|
|
|
|
hmap *_type // internal type representing a hmap
|
2014-11-11 15:05:19 -07:00
|
|
|
keysize uint8 // size of key slot
|
|
|
|
indirectkey bool // store ptr to key instead of key itself
|
|
|
|
valuesize uint8 // size of value slot
|
|
|
|
indirectvalue bool // store ptr to value instead of value itself
|
|
|
|
bucketsize uint16 // size of bucket
|
2014-12-12 14:45:19 -07:00
|
|
|
reflexivekey bool // true if k==k for all keys
|
2014-11-11 15:05:19 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
type chantype struct {
|
|
|
|
typ _type
|
|
|
|
elem *_type
|
|
|
|
dir uintptr
|
|
|
|
}
|
|
|
|
|
|
|
|
type slicetype struct {
|
|
|
|
typ _type
|
|
|
|
elem *_type
|
|
|
|
}
|
|
|
|
|
|
|
|
type functype struct {
|
|
|
|
typ _type
|
|
|
|
dotdotdot bool
|
|
|
|
in slice
|
|
|
|
out slice
|
|
|
|
}
|
|
|
|
|
|
|
|
type ptrtype struct {
|
|
|
|
typ _type
|
|
|
|
elem *_type
|
|
|
|
}
|