diff options
| author | Ian Lance Taylor <iant@golang.org> | 2025-12-02 21:13:19 -0800 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2026-02-07 15:09:43 -0800 |
| commit | d440b8b48560d29995d299973e6c79bd11fb90e9 (patch) | |
| tree | 8483d9fd300b10716bb954dc29bec37dc12f499c /src/runtime | |
| parent | d61c0c9283fb1cc3195f113428296976f1fc03ce (diff) | |
| download | go-d440b8b48560d29995d299973e6c79bd11fb90e9.tar.xz | |
internal/abi, runtime: put type descriptor sizes in internal/abi
Change-Id: I4ecfda9f85b00a228e8cf51d7ff4457ef7f83ce5
Reviewed-on: https://go-review.googlesource.com/c/go/+/726160
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Diffstat (limited to 'src/runtime')
| -rw-r--r-- | src/runtime/type.go | 59 |
1 files changed, 1 insertions, 58 deletions
diff --git a/src/runtime/type.go b/src/runtime/type.go index 82ac5120bb..a8205c2404 100644 --- a/src/runtime/type.go +++ b/src/runtime/type.go @@ -540,67 +540,10 @@ func moduleTypelinks(md *moduledata) []*_type { td = alignUp(td, 0x20) } - // This code must match the data structures built by - // cmd/compile/internal/reflectdata/reflect.go:writeType. - typ := (*_type)(unsafe.Pointer(td)) - ret = append(ret, typ) - var typSize, add uintptr - switch typ.Kind_ { - case abi.Array: - typSize = unsafe.Sizeof(abi.ArrayType{}) - case abi.Chan: - typSize = unsafe.Sizeof(abi.ChanType{}) - case abi.Func: - typSize = unsafe.Sizeof(abi.FuncType{}) - ft := (*abi.FuncType)(unsafe.Pointer(typ)) - add = uintptr(ft.NumIn()+ft.NumOut()) * goarch.PtrSize - case abi.Interface: - typSize = unsafe.Sizeof(abi.InterfaceType{}) - it := (*abi.InterfaceType)(unsafe.Pointer(typ)) - add = uintptr(len(it.Methods)) * unsafe.Sizeof(abi.Imethod{}) - case abi.Map: - typSize = unsafe.Sizeof(abi.MapType{}) - case abi.Pointer: - typSize = unsafe.Sizeof(abi.PtrType{}) - case abi.Slice: - typSize = unsafe.Sizeof(abi.SliceType{}) - case abi.Struct: - typSize = unsafe.Sizeof(abi.StructType{}) - st := (*abi.StructType)(unsafe.Pointer(typ)) - add = uintptr(len(st.Fields)) * unsafe.Sizeof(abi.StructField{}) - - case abi.Bool, - abi.Int, abi.Int8, abi.Int16, abi.Int32, abi.Int64, - abi.Uint, abi.Uint8, abi.Uint16, abi.Uint32, abi.Uint64, abi.Uintptr, - abi.Float32, abi.Float64, - abi.Complex64, abi.Complex128, - abi.String, - abi.UnsafePointer: - - typSize = unsafe.Sizeof(_type{}) - - default: - println("type descriptor at", hex(td), "is kind", typ.Kind_) - throw("invalid type descriptor") - } - - td += typSize - - mcount := uintptr(0) - if typ.TFlag&abi.TFlagUncommon != 0 { - ut := (*abi.UncommonType)(unsafe.Pointer(td)) - mcount = uintptr(ut.Mcount) - td += unsafe.Sizeof(abi.UncommonType{}) - } - - td += add - - if mcount > 0 { - td += mcount * unsafe.Sizeof(abi.Method{}) - } + td += uintptr(typ.DescriptorSize()) } if moduleToTypelinks == nil { |
