Merge pull request #421 from visualfc/abibasic

runtime: global abi basic
This commit is contained in:
xushiwei
2024-06-25 15:46:00 +08:00
committed by GitHub
11 changed files with 6614 additions and 6945 deletions

View File

@@ -26,17 +26,23 @@ type Kind = abi.Kind
type Type = abi.Type
// -----------------------------------------------------------------------------
var (
tyBasic [abi.UnsafePointer + 1]*Type
)
func Basic(kind Kind) *Type {
name, size, align := basicTypeInfo(kind)
return &Type{
Size_: size,
Hash: uint32(kind), // TODO(xsw): hash
Align_: uint8(align),
FieldAlign_: uint8(align),
Kind_: uint8(kind),
Str_: name,
if tyBasic[kind] == nil {
name, size, align := basicTypeInfo(kind)
tyBasic[kind] = &Type{
Size_: size,
Hash: uint32(kind), // TODO(xsw): hash
Align_: uint8(align),
FieldAlign_: uint8(align),
Kind_: uint8(kind),
Str_: name,
}
}
return tyBasic[kind]
}
func basicTypeInfo(kind abi.Kind) (string, uintptr, uintptr) {