runtime: expand abi array

This commit is contained in:
visualfc
2024-06-15 06:48:16 +08:00
parent f3b6d25aaa
commit 6e73fbf65e
3 changed files with 61 additions and 65 deletions

View File

@@ -83,23 +83,27 @@ const (
itabHdrSize = unsafe.Sizeof(itab{}) - pointerSize
)
var hdrSizes = [...]uintptr{
arrayTypeHdrSize,
chanTypeHdrSize,
funcTypeHdrSize,
interfaceTypeHdrSize,
mapTypeHdrSize,
ptrTypeHdrSize,
sliceTypeHdrSize,
typeHdrSize,
structTypeHdrSize,
}
func hdrSizeOf(kind abi.Kind) uintptr {
if kind >= abi.Array && kind <= abi.Struct {
return hdrSizes[kind-abi.Array]
switch kind {
case abi.Array:
return arrayTypeHdrSize
case abi.Chan:
return chanTypeHdrSize
case abi.Func:
return funcTypeHdrSize
case abi.Interface:
return interfaceTypeHdrSize
case abi.Map:
return mapTypeHdrSize
case abi.Pointer:
return ptrTypeHdrSize
case abi.Slice:
return sliceTypeHdrSize
case abi.Struct:
return structTypeHdrSize
default:
return typeHdrSize
}
return typeHdrSize
}
// NewNamed returns an uninitialized named type.