r.Type = objabi.R_METHODOFF
}
-var kinds = []int{
- types.TINT: objabi.KindInt,
- types.TUINT: objabi.KindUint,
- types.TINT8: objabi.KindInt8,
- types.TUINT8: objabi.KindUint8,
- types.TINT16: objabi.KindInt16,
- types.TUINT16: objabi.KindUint16,
- types.TINT32: objabi.KindInt32,
- types.TUINT32: objabi.KindUint32,
- types.TINT64: objabi.KindInt64,
- types.TUINT64: objabi.KindUint64,
- types.TUINTPTR: objabi.KindUintptr,
- types.TFLOAT32: objabi.KindFloat32,
- types.TFLOAT64: objabi.KindFloat64,
- types.TBOOL: objabi.KindBool,
- types.TSTRING: objabi.KindString,
- types.TPTR: objabi.KindPtr,
- types.TSTRUCT: objabi.KindStruct,
- types.TINTER: objabi.KindInterface,
- types.TCHAN: objabi.KindChan,
- types.TMAP: objabi.KindMap,
- types.TARRAY: objabi.KindArray,
- types.TSLICE: objabi.KindSlice,
- types.TFUNC: objabi.KindFunc,
- types.TCOMPLEX64: objabi.KindComplex64,
- types.TCOMPLEX128: objabi.KindComplex128,
- types.TUNSAFEPTR: objabi.KindUnsafePointer,
+var kinds = []abi.Kind{
+ types.TINT: abi.Int,
+ types.TUINT: abi.Uint,
+ types.TINT8: abi.Int8,
+ types.TUINT8: abi.Uint8,
+ types.TINT16: abi.Int16,
+ types.TUINT16: abi.Uint16,
+ types.TINT32: abi.Int32,
+ types.TUINT32: abi.Uint32,
+ types.TINT64: abi.Int64,
+ types.TUINT64: abi.Uint64,
+ types.TUINTPTR: abi.Uintptr,
+ types.TFLOAT32: abi.Float32,
+ types.TFLOAT64: abi.Float64,
+ types.TBOOL: abi.Bool,
+ types.TSTRING: abi.String,
+ types.TPTR: abi.Pointer,
+ types.TSTRUCT: abi.Struct,
+ types.TINTER: abi.Interface,
+ types.TCHAN: abi.Chan,
+ types.TMAP: abi.Map,
+ types.TARRAY: abi.Array,
+ types.TSLICE: abi.Slice,
+ types.TFUNC: abi.Func,
+ types.TCOMPLEX64: abi.Complex64,
+ types.TCOMPLEX128: abi.Complex128,
+ types.TUNSAFEPTR: abi.UnsafePointer,
}
var (
c.Field("Align_").WriteUint8(uint8(t.Alignment()))
c.Field("FieldAlign_").WriteUint8(uint8(t.Alignment()))
- i = kinds[t.Kind()]
+ kind := kinds[t.Kind()]
if types.IsDirectIface(t) {
- i |= objabi.KindDirectIface
+ kind |= abi.KindDirectIface
}
if useGCProg {
- i |= objabi.KindGCProg
+ kind |= abi.KindGCProg
}
- c.Field("Kind_").WriteUint8(uint8(i))
+ c.Field("Kind_").WriteUint8(uint8(kind))
c.Field("Equal").WritePtr(eqfunc)
c.Field("GCData").WritePtr(gcsym)
+++ /dev/null
-// Copyright 2012 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.
-
-package objabi
-
-// Must match runtime and reflect.
-// Included by cmd/gc.
-
-const (
- KindBool = 1 + iota
- KindInt
- KindInt8
- KindInt16
- KindInt32
- KindInt64
- KindUint
- KindUint8
- KindUint16
- KindUint32
- KindUint64
- KindUintptr
- KindFloat32
- KindFloat64
- KindComplex64
- KindComplex128
- KindArray
- KindChan
- KindFunc
- KindInterface
- KindMap
- KindPtr
- KindSlice
- KindString
- KindStruct
- KindUnsafePointer
- KindDirectIface = 1 << 5
- KindGCProg = 1 << 6
- KindMask = (1 << 5) - 1
-)
"cmd/link/internal/loader"
"cmd/link/internal/sym"
"fmt"
+ "internal/abi"
"internal/buildcfg"
"strings"
"unicode"
if p == nil {
panic(fmt.Sprintf("missing symbol %q", ldr.SymName(symIdx)))
}
- if decodetypeKind(arch, p)&kindMask != kindInterface {
+ if abi.Kind(decodetypeKind(arch, p)&abi.KindMask) != abi.Interface {
panic(fmt.Sprintf("symbol %q is not an interface", ldr.SymName(symIdx)))
}
relocs := ldr.Relocs(symIdx)
panic(fmt.Sprintf("no methods on %q", ldr.SymName(symIdx)))
}
off := commonsize(arch) // reflect.rtype
- switch decodetypeKind(arch, p) & kindMask {
- case kindStruct: // reflect.structType
+ switch abi.Kind(decodetypeKind(arch, p) & abi.KindMask) {
+ case abi.Struct: // reflect.structType
off += 4 * arch.PtrSize
- case kindPtr: // reflect.ptrType
+ case abi.Pointer: // reflect.ptrType
off += arch.PtrSize
- case kindFunc: // reflect.funcType
+ case abi.Func: // reflect.funcType
off += arch.PtrSize // 4 bytes, pointer aligned
- case kindSlice: // reflect.sliceType
+ case abi.Slice: // reflect.sliceType
off += arch.PtrSize
- case kindArray: // reflect.arrayType
+ case abi.Array: // reflect.arrayType
off += 3 * arch.PtrSize
- case kindChan: // reflect.chanType
+ case abi.Chan: // reflect.chanType
off += 2 * arch.PtrSize
- case kindMap: // reflect.mapType
+ case abi.Map: // reflect.mapType
off += 4*arch.PtrSize + 8
- case kindInterface: // reflect.interfaceType
+ case abi.Interface: // reflect.interfaceType
off += 3 * arch.PtrSize
default:
// just Sizeof(rtype)
package ld
import (
- "cmd/internal/objabi"
"cmd/internal/sys"
"cmd/link/internal/loader"
"cmd/link/internal/sym"
// Type.commonType.kind
func decodetypeKind(arch *sys.Arch, p []byte) uint8 {
- return p[2*arch.PtrSize+7] & objabi.KindMask // 0x13 / 0x1f
+ return p[2*arch.PtrSize+7] & abi.KindMask // 0x13 / 0x1f
}
// Type.commonType.kind
func decodetypeUsegcprog(arch *sys.Arch, p []byte) uint8 {
- return p[2*arch.PtrSize+7] & objabi.KindGCProg // 0x13 / 0x1f
+ return p[2*arch.PtrSize+7] & abi.KindGCProg // 0x13 / 0x1f
}
// Type.commonType.size
return int64(decodeInuxi(arch, p[commonsize(arch)+2*arch.PtrSize:], arch.PtrSize))
}
-// Matches runtime/typekind.go and reflect.Kind.
-const (
- kindArray = 17
- kindChan = 18
- kindFunc = 19
- kindInterface = 20
- kindMap = 21
- kindPtr = 22
- kindSlice = 23
- kindStruct = 25
- kindMask = (1 << 5) - 1
-)
-
func decodeReloc(ldr *loader.Loader, symIdx loader.Sym, relocs *loader.Relocs, off int32) loader.Reloc {
for j := 0; j < relocs.Count(); j++ {
rel := relocs.At(j)
bytesize := decodetypeSize(d.arch, tdata)
var die, typedefdie *dwarf.DWDie
- switch kind {
- case objabi.KindBool:
+ switch abi.Kind(kind) {
+ case abi.Bool:
die = d.newdie(&dwtypes, dwarf.DW_ABRV_BASETYPE, name)
newattr(die, dwarf.DW_AT_encoding, dwarf.DW_CLS_CONSTANT, dwarf.DW_ATE_boolean, 0)
newattr(die, dwarf.DW_AT_byte_size, dwarf.DW_CLS_CONSTANT, bytesize, 0)
- case objabi.KindInt,
- objabi.KindInt8,
- objabi.KindInt16,
- objabi.KindInt32,
- objabi.KindInt64:
+ case abi.Int,
+ abi.Int8,
+ abi.Int16,
+ abi.Int32,
+ abi.Int64:
die = d.newdie(&dwtypes, dwarf.DW_ABRV_BASETYPE, name)
newattr(die, dwarf.DW_AT_encoding, dwarf.DW_CLS_CONSTANT, dwarf.DW_ATE_signed, 0)
newattr(die, dwarf.DW_AT_byte_size, dwarf.DW_CLS_CONSTANT, bytesize, 0)
- case objabi.KindUint,
- objabi.KindUint8,
- objabi.KindUint16,
- objabi.KindUint32,
- objabi.KindUint64,
- objabi.KindUintptr:
+ case abi.Uint,
+ abi.Uint8,
+ abi.Uint16,
+ abi.Uint32,
+ abi.Uint64,
+ abi.Uintptr:
die = d.newdie(&dwtypes, dwarf.DW_ABRV_BASETYPE, name)
newattr(die, dwarf.DW_AT_encoding, dwarf.DW_CLS_CONSTANT, dwarf.DW_ATE_unsigned, 0)
newattr(die, dwarf.DW_AT_byte_size, dwarf.DW_CLS_CONSTANT, bytesize, 0)
- case objabi.KindFloat32,
- objabi.KindFloat64:
+ case abi.Float32,
+ abi.Float64:
die = d.newdie(&dwtypes, dwarf.DW_ABRV_BASETYPE, name)
newattr(die, dwarf.DW_AT_encoding, dwarf.DW_CLS_CONSTANT, dwarf.DW_ATE_float, 0)
newattr(die, dwarf.DW_AT_byte_size, dwarf.DW_CLS_CONSTANT, bytesize, 0)
- case objabi.KindComplex64,
- objabi.KindComplex128:
+ case abi.Complex64,
+ abi.Complex128:
die = d.newdie(&dwtypes, dwarf.DW_ABRV_BASETYPE, name)
newattr(die, dwarf.DW_AT_encoding, dwarf.DW_CLS_CONSTANT, dwarf.DW_ATE_complex_float, 0)
newattr(die, dwarf.DW_AT_byte_size, dwarf.DW_CLS_CONSTANT, bytesize, 0)
- case objabi.KindArray:
+ case abi.Array:
die = d.newdie(&dwtypes, dwarf.DW_ABRV_ARRAYTYPE, name)
typedefdie = d.dotypedef(&dwtypes, name, die)
newattr(die, dwarf.DW_AT_byte_size, dwarf.DW_CLS_CONSTANT, bytesize, 0)
d.newrefattr(fld, dwarf.DW_AT_type, d.uintptrInfoSym)
- case objabi.KindChan:
+ case abi.Chan:
die = d.newdie(&dwtypes, dwarf.DW_ABRV_CHANTYPE, name)
s := decodetypeChanElem(d.ldr, d.arch, gotype)
d.newrefattr(die, dwarf.DW_AT_go_elem, d.defgotype(s))
// but that would change the order of DIEs we output.
d.newrefattr(die, dwarf.DW_AT_type, s)
- case objabi.KindFunc:
+ case abi.Func:
die = d.newdie(&dwtypes, dwarf.DW_ABRV_FUNCTYPE, name)
newattr(die, dwarf.DW_AT_byte_size, dwarf.DW_CLS_CONSTANT, bytesize, 0)
typedefdie = d.dotypedef(&dwtypes, name, die)
d.newrefattr(fld, dwarf.DW_AT_type, d.defptrto(d.defgotype(s)))
}
- case objabi.KindInterface:
+ case abi.Interface:
die = d.newdie(&dwtypes, dwarf.DW_ABRV_IFACETYPE, name)
typedefdie = d.dotypedef(&dwtypes, name, die)
data := d.ldr.Data(gotype)
}
d.newrefattr(die, dwarf.DW_AT_type, d.defgotype(s))
- case objabi.KindMap:
+ case abi.Map:
die = d.newdie(&dwtypes, dwarf.DW_ABRV_MAPTYPE, name)
s := decodetypeMapKey(d.ldr, d.arch, gotype)
d.newrefattr(die, dwarf.DW_AT_go_key, d.defgotype(s))
// but that would change the order of the DIEs.
d.newrefattr(die, dwarf.DW_AT_type, gotype)
- case objabi.KindPtr:
+ case abi.Pointer:
die = d.newdie(&dwtypes, dwarf.DW_ABRV_PTRTYPE, name)
typedefdie = d.dotypedef(&dwtypes, name, die)
s := decodetypePtrElem(d.ldr, d.arch, gotype)
d.newrefattr(die, dwarf.DW_AT_type, d.defgotype(s))
- case objabi.KindSlice:
+ case abi.Slice:
die = d.newdie(&dwtypes, dwarf.DW_ABRV_SLICETYPE, name)
typedefdie = d.dotypedef(&dwtypes, name, die)
newattr(die, dwarf.DW_AT_byte_size, dwarf.DW_CLS_CONSTANT, bytesize, 0)
elem := d.defgotype(s)
d.newrefattr(die, dwarf.DW_AT_go_elem, elem)
- case objabi.KindString:
+ case abi.String:
die = d.newdie(&dwtypes, dwarf.DW_ABRV_STRINGTYPE, name)
newattr(die, dwarf.DW_AT_byte_size, dwarf.DW_CLS_CONSTANT, bytesize, 0)
- case objabi.KindStruct:
+ case abi.Struct:
die = d.newdie(&dwtypes, dwarf.DW_ABRV_STRUCTTYPE, name)
typedefdie = d.dotypedef(&dwtypes, name, die)
newattr(die, dwarf.DW_AT_byte_size, dwarf.DW_CLS_CONSTANT, bytesize, 0)
}
}
- case objabi.KindUnsafePointer:
+ case abi.UnsafePointer:
die = d.newdie(&dwtypes, dwarf.DW_ABRV_BARE_PTRTYPE, name)
default:
// pointers of slices. Link to the ones we can find.
gts := d.ldr.Lookup("type:"+ptrname, 0)
if gts != 0 && d.ldr.AttrReachable(gts) {
- newattr(pdie, dwarf.DW_AT_go_kind, dwarf.DW_CLS_CONSTANT, int64(objabi.KindPtr), 0)
+ newattr(pdie, dwarf.DW_AT_go_kind, dwarf.DW_CLS_CONSTANT, int64(abi.Pointer), 0)
newattr(pdie, dwarf.DW_AT_go_runtime_type, dwarf.DW_CLS_GO_TYPEREF, 0, dwSym(gts))
}
uintptrDie := d.mkBuiltinType(ctxt, dwarf.DW_ABRV_BASETYPE, "uintptr")
newattr(uintptrDie, dwarf.DW_AT_encoding, dwarf.DW_CLS_CONSTANT, dwarf.DW_ATE_unsigned, 0)
newattr(uintptrDie, dwarf.DW_AT_byte_size, dwarf.DW_CLS_CONSTANT, int64(d.arch.PtrSize), 0)
- newattr(uintptrDie, dwarf.DW_AT_go_kind, dwarf.DW_CLS_CONSTANT, objabi.KindUintptr, 0)
+ newattr(uintptrDie, dwarf.DW_AT_go_kind, dwarf.DW_CLS_CONSTANT, int64(abi.Uintptr), 0)
newattr(uintptrDie, dwarf.DW_AT_go_runtime_type, dwarf.DW_CLS_GO_TYPEREF, 0, dwSym(d.lookupOrDiag("type:uintptr")))
d.uintptrInfoSym = d.mustFind("uintptr")
TFlag TFlag // extra type information flags
Align_ uint8 // alignment of variable with this type
FieldAlign_ uint8 // alignment of struct field with this type
- Kind_ uint8 // enumeration for C
+ Kind_ Kind // enumeration for C
// function for comparing objects of this type
// (ptr to object A, ptr to object B) -> ==?
Equal func(unsafe.Pointer, unsafe.Pointer) bool
// A Kind represents the specific kind of type that a Type represents.
// The zero Kind is not a valid kind.
-type Kind uint
+type Kind uint8
const (
Invalid Kind = iota
inReg = append(inReg, bool2byte(abid.inRegPtrs.Get(i)))
outReg = append(outReg, bool2byte(abid.outRegPtrs.Get(i)))
}
- if ft.Kind_&kindGCProg != 0 {
+ if ft.Kind_&abi.KindGCProg != 0 {
panic("can't handle gc programs")
}
func CachedBucketOf(m Type) Type {
t := m.(*rtype)
- if Kind(t.t.Kind_&kindMask) != Map {
+ if Kind(t.t.Kind_&abi.KindMask) != Map {
panic("not map")
}
tt := (*mapType)(unsafe.Pointer(t))
return m.PkgPath == ""
}
-const (
- kindDirectIface = 1 << 5
- kindGCProg = 1 << 6 // Type.gc points to GC program
- kindMask = (1 << 5) - 1
-)
-
// String returns the name of k.
func (k Kind) String() string {
if uint(k) < uint(len(kindNames)) {
b := &abi.Type{
Align_: goarch.PtrSize,
Size_: size,
- Kind_: uint8(Struct),
+ Kind_: abi.Struct,
PtrBytes: ptrdata,
GCData: gcdata,
}
// emitGCMask writes the GC mask for [n]typ into out, starting at bit
// offset base.
func emitGCMask(out []byte, base uintptr, typ *abi.Type, n uintptr) {
- if typ.Kind_&kindGCProg != 0 {
+ if typ.Kind_&abi.KindGCProg != 0 {
panic("reflect: unexpected GC program")
}
ptrs := typ.PtrBytes / goarch.PtrSize
// appendGCProg appends the GC program for the first ptrdata bytes of
// typ to dst and returns the extended slice.
func appendGCProg(dst []byte, typ *abi.Type) []byte {
- if typ.Kind_&kindGCProg != 0 {
+ if typ.Kind_&abi.KindGCProg != 0 {
// Element has GC program; emit one element.
n := uintptr(*(*uint32)(unsafe.Pointer(typ.GCData)))
prog := typ.GcSlice(4, 4+n-1)
}
f, fpkgpath := runtimeStructField(field)
ft := f.Typ
- if ft.Kind_&kindGCProg != 0 {
+ if ft.Kind_&abi.KindGCProg != 0 {
hasGCProg = true
}
if fpkgpath != "" {
// Issue 15924.
panic("reflect: embedded type with methods not implemented if type is not first field")
}
- if len(fields) > 1 && ft.Kind_&kindDirectIface != 0 {
+ if len(fields) > 1 && ft.Kind_&abi.KindDirectIface != 0 {
panic("reflect: embedded type with methods not implemented for non-pointer type")
}
for _, m := range unt.Methods() {
}
prog = append(prog, 0)
*(*uint32)(unsafe.Pointer(&prog[0])) = uint32(len(prog) - 4)
- typ.Kind_ |= kindGCProg
+ typ.Kind_ |= abi.KindGCProg
typ.GCData = &prog[0]
} else {
- typ.Kind_ &^= kindGCProg
+ typ.Kind_ &^= abi.KindGCProg
bv := new(bitVector)
addTypeBits(bv, 0, &typ.Type)
if len(bv.data) > 0 {
switch {
case len(fs) == 1 && !ifaceIndir(fs[0].Typ):
// structs of 1 direct iface type can be direct
- typ.Kind_ |= kindDirectIface
+ typ.Kind_ |= abi.KindDirectIface
default:
- typ.Kind_ &^= kindDirectIface
+ typ.Kind_ &^= abi.KindDirectIface
}
return addToCache(toType(&typ.Type))
case length == 1:
// In memory, 1-element array looks just like the element.
- array.Kind_ |= typ.Kind_ & kindGCProg
+ array.Kind_ |= typ.Kind_ & abi.KindGCProg
array.GCData = typ.GCData
array.PtrBytes = typ.PtrBytes
- case typ.Kind_&kindGCProg == 0 && array.Size_ <= abi.MaxPtrmaskBytes*8*goarch.PtrSize:
+ case typ.Kind_&abi.KindGCProg == 0 && array.Size_ <= abi.MaxPtrmaskBytes*8*goarch.PtrSize:
// Element is small with pointer mask; array is still small.
// Create direct pointer mask by turning each 1 bit in elem
// into length 1 bits in larger mask.
prog = appendVarint(prog, uintptr(length)-1)
prog = append(prog, 0)
*(*uint32)(unsafe.Pointer(&prog[0])) = uint32(len(prog) - 4)
- array.Kind_ |= kindGCProg
+ array.Kind_ |= abi.KindGCProg
array.GCData = &prog[0]
array.PtrBytes = array.Size_ // overestimate but ok; must match program
}
switch {
case length == 1 && !ifaceIndir(typ):
// array of 1 direct iface type can be direct
- array.Kind_ |= kindDirectIface
+ array.Kind_ |= abi.KindDirectIface
default:
- array.Kind_ &^= kindDirectIface
+ array.Kind_ &^= abi.KindDirectIface
}
ti, _ := lookupCache.LoadOrStore(ckey, toRType(&array.Type))
// ifaceIndir reports whether t is stored indirectly in an interface value.
func ifaceIndir(t *abi.Type) bool {
- return t.Kind_&kindDirectIface == 0
+ return t.Kind_&abi.KindDirectIface == 0
}
// Note: this type must agree with runtime.bitvector.
return
}
- switch Kind(t.Kind_ & kindMask) {
+ switch Kind(t.Kind_ & abi.KindMask) {
case Chan, Func, Map, Pointer, Slice, String, UnsafePointer:
// 1 pointer at start of representation
for bv.n < uint32(offset/uintptr(goarch.PtrSize)) {
return memhash(p, h, t.Size_)
}
}
- switch t.Kind_ & kindMask {
- case kindFloat32:
+ switch t.Kind_ & abi.KindMask {
+ case abi.Float32:
return f32hash(p, h)
- case kindFloat64:
+ case abi.Float64:
return f64hash(p, h)
- case kindComplex64:
+ case abi.Complex64:
return c64hash(p, h)
- case kindComplex128:
+ case abi.Complex128:
return c128hash(p, h)
- case kindString:
+ case abi.String:
return strhash(p, h)
- case kindInterface:
+ case abi.Interface:
i := (*interfacetype)(unsafe.Pointer(t))
if len(i.Methods) == 0 {
return nilinterhash(p, h)
}
return interhash(p, h)
- case kindArray:
+ case abi.Array:
a := (*arraytype)(unsafe.Pointer(t))
for i := uintptr(0); i < a.Len; i++ {
h = typehash(a.Elem, add(p, i*a.Elem.Size_), h)
}
return h
- case kindStruct:
+ case abi.Struct:
s := (*structtype)(unsafe.Pointer(t))
for _, f := range s.Fields {
if f.Name.IsBlank() {
if t.TFlag&abi.TFlagRegularMemory != 0 {
return nil
}
- switch t.Kind_ & kindMask {
- case kindFloat32, kindFloat64, kindComplex64, kindComplex128, kindString:
+ switch t.Kind_ & abi.KindMask {
+ case abi.Float32, abi.Float64, abi.Complex64, abi.Complex128, abi.String:
return nil
- case kindInterface:
+ case abi.Interface:
i := (*interfacetype)(unsafe.Pointer(t))
var t *_type
var pdata *unsafe.Pointer
} else {
return mapKeyError2(t, *pdata)
}
- case kindArray:
+ case abi.Array:
a := (*arraytype)(unsafe.Pointer(t))
for i := uintptr(0); i < a.Len; i++ {
if err := mapKeyError2(a.Elem, add(p, i*a.Elem.Size_)); err != nil {
}
}
return nil
- case kindStruct:
+ case abi.Struct:
s := (*structtype)(unsafe.Pointer(t))
for _, f := range s.Fields {
if f.Name.IsBlank() {
package runtime
import (
+ "internal/abi"
"internal/goarch"
"internal/goexperiment"
"internal/runtime/atomic"
//go:linkname arena_arena_New arena.runtime_arena_arena_New
func arena_arena_New(arena unsafe.Pointer, typ any) any {
t := (*_type)(efaceOf(&typ).data)
- if t.Kind_&kindMask != kindPtr {
+ if t.Kind_&abi.KindMask != abi.Pointer {
throw("arena_New: non-pointer type")
}
te := (*ptrtype)(unsafe.Pointer(t)).Elem
var v unsafe.Pointer
e := efaceOf(&s)
t := e._type
- switch t.Kind_ & kindMask {
- case kindString:
+ switch t.Kind_ & abi.KindMask {
+ case abi.String:
v = stringStructOf((*string)(e.data)).str
- case kindSlice:
+ case abi.Slice:
v = (*slice)(e.data).array
- case kindPtr:
+ case abi.Pointer:
v = e.data
default:
panic("arena: Clone only supports pointers, slices, and strings")
}
// Heap-allocate storage for a copy.
var x any
- switch t.Kind_ & kindMask {
- case kindString:
+ switch t.Kind_ & abi.KindMask {
+ case abi.String:
s1 := s.(string)
s2, b := rawstring(len(s1))
copy(b, s1)
x = s2
- case kindSlice:
+ case abi.Slice:
len := (*slice)(e.data).len
et := (*slicetype)(unsafe.Pointer(t)).Elem
sl := new(slice)
xe := efaceOf(&x)
xe._type = t
xe.data = unsafe.Pointer(sl)
- case kindPtr:
+ case abi.Pointer:
et := (*ptrtype)(unsafe.Pointer(t)).Elem
e2 := newobject(et)
typedmemmove(et, e2, e.data)
}
i := efaceOf(&sl)
typ := i._type
- if typ.Kind_&kindMask != kindPtr {
+ if typ.Kind_&abi.KindMask != abi.Pointer {
panic("slice result of non-ptr type")
}
typ = (*ptrtype)(unsafe.Pointer(typ)).Elem
- if typ.Kind_&kindMask != kindSlice {
+ if typ.Kind_&abi.KindMask != abi.Slice {
panic("slice of non-ptr-to-slice type")
}
typ = (*slicetype)(unsafe.Pointer(typ)).Elem
package runtime
import (
+ "internal/abi"
"internal/goarch"
"internal/goexperiment"
"runtime/internal/sys"
t := ep._type
top := true
- if arg != nil && (t.Kind_&kindMask == kindPtr || t.Kind_&kindMask == kindUnsafePointer) {
+ if arg != nil && (t.Kind_&abi.KindMask == abi.Pointer || t.Kind_&abi.KindMask == abi.UnsafePointer) {
p := ep.data
- if t.Kind_&kindDirectIface == 0 {
+ if t.Kind_&abi.KindDirectIface == 0 {
p = *(*unsafe.Pointer)(p)
}
if p == nil || !cgoIsGoPointer(p) {
return
}
aep := efaceOf(&arg)
- switch aep._type.Kind_ & kindMask {
- case kindBool:
- if t.Kind_&kindMask == kindUnsafePointer {
+ switch aep._type.Kind_ & abi.KindMask {
+ case abi.Bool:
+ if t.Kind_&abi.KindMask == abi.UnsafePointer {
// We don't know the type of the element.
break
}
pt := (*ptrtype)(unsafe.Pointer(t))
cgoCheckArg(pt.Elem, p, true, false, cgoCheckPointerFail)
return
- case kindSlice:
+ case abi.Slice:
// Check the slice rather than the pointer.
ep = aep
t = ep._type
- case kindArray:
+ case abi.Array:
// Check the array rather than the pointer.
// Pass top as false since we have a pointer
// to the array.
}
}
- cgoCheckArg(t, ep.data, t.Kind_&kindDirectIface == 0, top, cgoCheckPointerFail)
+ cgoCheckArg(t, ep.data, t.Kind_&abi.KindDirectIface == 0, top, cgoCheckPointerFail)
}
const cgoCheckPointerFail = "cgo argument has Go pointer to unpinned Go pointer"
return
}
- switch t.Kind_ & kindMask {
+ switch t.Kind_ & abi.KindMask {
default:
throw("can't happen")
- case kindArray:
+ case abi.Array:
at := (*arraytype)(unsafe.Pointer(t))
if !indir {
if at.Len != 1 {
throw("can't happen")
}
- cgoCheckArg(at.Elem, p, at.Elem.Kind_&kindDirectIface == 0, top, msg)
+ cgoCheckArg(at.Elem, p, at.Elem.Kind_&abi.KindDirectIface == 0, top, msg)
return
}
for i := uintptr(0); i < at.Len; i++ {
cgoCheckArg(at.Elem, p, true, top, msg)
p = add(p, at.Elem.Size_)
}
- case kindChan, kindMap:
+ case abi.Chan, abi.Map:
// These types contain internal pointers that will
// always be allocated in the Go heap. It's never OK
// to pass them to C.
panic(errorString(msg))
- case kindFunc:
+ case abi.Func:
if indir {
p = *(*unsafe.Pointer)(p)
}
return
}
panic(errorString(msg))
- case kindInterface:
+ case abi.Interface:
it := *(**_type)(p)
if it == nil {
return
if !top && !isPinned(p) {
panic(errorString(msg))
}
- cgoCheckArg(it, p, it.Kind_&kindDirectIface == 0, false, msg)
- case kindSlice:
+ cgoCheckArg(it, p, it.Kind_&abi.KindDirectIface == 0, false, msg)
+ case abi.Slice:
st := (*slicetype)(unsafe.Pointer(t))
s := (*slice)(p)
p = s.array
cgoCheckArg(st.Elem, p, true, false, msg)
p = add(p, st.Elem.Size_)
}
- case kindString:
+ case abi.String:
ss := (*stringStruct)(p)
if !cgoIsGoPointer(ss.str) {
return
if !top && !isPinned(ss.str) {
panic(errorString(msg))
}
- case kindStruct:
+ case abi.Struct:
st := (*structtype)(unsafe.Pointer(t))
if !indir {
if len(st.Fields) != 1 {
throw("can't happen")
}
- cgoCheckArg(st.Fields[0].Typ, p, st.Fields[0].Typ.Kind_&kindDirectIface == 0, top, msg)
+ cgoCheckArg(st.Fields[0].Typ, p, st.Fields[0].Typ.Kind_&abi.KindDirectIface == 0, top, msg)
return
}
for _, f := range st.Fields {
}
cgoCheckArg(f.Typ, add(p, f.Offset), true, top, msg)
}
- case kindPtr, kindUnsafePointer:
+ case abi.Pointer, abi.UnsafePointer:
if indir {
p = *(*unsafe.Pointer)(p)
if p == nil {
ep := efaceOf(&val)
t := ep._type
- cgoCheckArg(t, ep.data, t.Kind_&kindDirectIface == 0, false, cgoResultFail)
+ cgoCheckArg(t, ep.data, t.Kind_&abi.KindDirectIface == 0, false, cgoResultFail)
}
package runtime
import (
+ "internal/abi"
"internal/goarch"
"internal/goexperiment"
"unsafe"
size = ptrdataSize
}
- if typ.Kind_&kindGCProg == 0 {
+ if typ.Kind_&abi.KindGCProg == 0 {
cgoCheckBits(src, typ.GCData, off, size)
return
}
size = ptrdataSize
}
- if typ.Kind_&kindGCProg == 0 {
+ if typ.Kind_&abi.KindGCProg == 0 {
cgoCheckBits(src, typ.GCData, off, size)
return
}
- switch typ.Kind_ & kindMask {
+ switch typ.Kind_ & abi.KindMask {
default:
throw("can't happen")
- case kindArray:
+ case abi.Array:
at := (*arraytype)(unsafe.Pointer(typ))
for i := uintptr(0); i < at.Len; i++ {
if off < at.Elem.Size_ {
}
size -= checked
}
- case kindStruct:
+ case abi.Struct:
st := (*structtype)(unsafe.Pointer(typ))
for _, f := range st.Fields {
if off < f.Typ.Size_ {
package runtime
import (
+ "internal/abi"
"internal/runtime/atomic"
"runtime/internal/sys"
"unsafe"
l.w.uvarint(0)
} else {
v := efaceOf(&x)
- switch v._type.Kind_ & kindMask {
- case kindChan, kindFunc, kindMap, kindPtr, kindUnsafePointer:
+ switch v._type.Kind_ & abi.KindMask {
+ case abi.Chan, abi.Func, abi.Map, abi.Pointer, abi.UnsafePointer:
l.w.uvarint(uint64(uintptr(v.data)))
default:
throw("not a pointer type")
package runtime
-import "internal/bytealg"
+import (
+ "internal/abi"
+ "internal/bytealg"
+)
// The Error interface identifies a run time error.
type Error interface {
typestring := toRType(eface._type).string()
switch eface._type.Kind_ {
- case kindString:
+ case abi.String:
print(typestring, `("`, *(*string)(eface.data), `")`)
- case kindBool:
+ case abi.Bool:
print(typestring, "(", *(*bool)(eface.data), ")")
- case kindInt:
+ case abi.Int:
print(typestring, "(", *(*int)(eface.data), ")")
- case kindInt8:
+ case abi.Int8:
print(typestring, "(", *(*int8)(eface.data), ")")
- case kindInt16:
+ case abi.Int16:
print(typestring, "(", *(*int16)(eface.data), ")")
- case kindInt32:
+ case abi.Int32:
print(typestring, "(", *(*int32)(eface.data), ")")
- case kindInt64:
+ case abi.Int64:
print(typestring, "(", *(*int64)(eface.data), ")")
- case kindUint:
+ case abi.Uint:
print(typestring, "(", *(*uint)(eface.data), ")")
- case kindUint8:
+ case abi.Uint8:
print(typestring, "(", *(*uint8)(eface.data), ")")
- case kindUint16:
+ case abi.Uint16:
print(typestring, "(", *(*uint16)(eface.data), ")")
- case kindUint32:
+ case abi.Uint32:
print(typestring, "(", *(*uint32)(eface.data), ")")
- case kindUint64:
+ case abi.Uint64:
print(typestring, "(", *(*uint64)(eface.data), ")")
- case kindUintptr:
+ case abi.Uintptr:
print(typestring, "(", *(*uintptr)(eface.data), ")")
- case kindFloat32:
+ case abi.Float32:
print(typestring, "(", *(*float32)(eface.data), ")")
- case kindFloat64:
+ case abi.Float64:
print(typestring, "(", *(*float64)(eface.data), ")")
- case kindComplex64:
+ case abi.Complex64:
print(typestring, *(*complex64)(eface.data))
- case kindComplex128:
+ case abi.Complex128:
print(typestring, *(*complex128)(eface.data))
default:
print("(", typestring, ") ", eface.data)
}
f := efaceOf(&fn)
- if f._type == nil || f._type.Kind_&kindMask != kindFunc {
+ if f._type == nil || f._type.Kind_&abi.KindMask != abi.Func {
return nil, plainError("fn must be a function")
}
fv := (*funcval)(f.data)
a := efaceOf(&stackArgs)
- if a._type != nil && a._type.Kind_&kindMask != kindPtr {
+ if a._type != nil && a._type.Kind_&abi.KindMask != abi.Pointer {
return nil, plainError("args must be a pointer or nil")
}
argp := a.data
func (a *UserArena) New(out *any) {
i := efaceOf(out)
typ := i._type
- if typ.Kind_&kindMask != kindPtr {
+ if typ.Kind_&abi.KindMask != abi.Pointer {
panic("new result of non-ptr type")
}
typ = (*ptrtype)(unsafe.Pointer(typ)).Elem
dwritebyte('.')
dwrite(unsafe.Pointer(unsafe.StringData(name)), uintptr(len(name)))
}
- dumpbool(t.Kind_&kindDirectIface == 0 || t.Pointers())
+ dumpbool(t.Kind_&abi.KindDirectIface == 0 || t.PtrBytes != 0)
}
// dump an object.
package runtime
import (
+ "internal/abi"
"internal/goarch"
"internal/runtime/atomic"
"runtime/internal/sys"
println("runtime: typeBitsBulkBarrier with type ", toRType(typ).string(), " of size ", typ.Size_, " but memory size", size)
throw("runtime: invalid typeBitsBulkBarrier")
}
- if typ.Kind_&kindGCProg != 0 {
+ if typ.Kind_&abi.KindGCProg != 0 {
println("runtime: typeBitsBulkBarrier with type ", toRType(typ).string(), " with GC prog")
throw("runtime: invalid typeBitsBulkBarrier")
}
//go:nosplit
func (span *mspan) typePointersOfType(typ *abi.Type, addr uintptr) typePointers {
const doubleCheck = false
- if doubleCheck && (typ == nil || typ.Kind_&kindGCProg != 0) {
+ if doubleCheck && (typ == nil || typ.Kind_&abi.KindGCProg != 0) {
throw("bad type passed to typePointersOfType")
}
if span.spanclass.noscan() {
}
var tp typePointers
- if typ != nil && typ.Kind_&kindGCProg == 0 {
+ if typ != nil && typ.Kind_&abi.KindGCProg == 0 {
tp = s.typePointersOfType(typ, dst)
} else {
tp = s.typePointersOf(dst, size)
}
var tp typePointers
- if typ != nil && typ.Kind_&kindGCProg == 0 {
+ if typ != nil && typ.Kind_&abi.KindGCProg == 0 {
tp = s.typePointersOfType(typ, dst)
} else {
tp = s.typePointersOf(dst, size)
// Handle the case where we have no malloc header.
scanSize = span.writeHeapBitsSmall(x, dataSize, typ)
} else {
- if typ.Kind_&kindGCProg != 0 {
+ if typ.Kind_&abi.KindGCProg != 0 {
// Allocate space to unroll the gcprog. This space will consist of
// a dummy _type value and the unrolled gcprog. The dummy _type will
// refer to the bitmap, and the mspan will refer to the dummy _type.
}
println("runtime: extra pointer:", hex(addr))
}
- print("runtime: hasHeader=", header != nil, " typ.Size_=", typ.Size_, " hasGCProg=", typ.Kind_&kindGCProg != 0, "\n")
+ print("runtime: hasHeader=", header != nil, " typ.Size_=", typ.Size_, " hasGCProg=", typ.Kind_&abi.KindGCProg != 0, "\n")
print("runtime: x=", hex(x), " dataSize=", dataSize, " elemsize=", span.elemsize, "\n")
print("runtime: typ=", unsafe.Pointer(typ), " typ.PtrBytes=", typ.PtrBytes, "\n")
print("runtime: limit=", hex(x+span.elemsize), "\n")
//go:nosplit
func doubleCheckTypePointersOfType(s *mspan, typ *_type, addr, size uintptr) {
- if typ == nil || typ.Kind_&kindGCProg != 0 {
+ if typ == nil || typ.Kind_&abi.KindGCProg != 0 {
return
}
- if typ.Kind_&kindMask == kindInterface {
+ if typ.Kind_&abi.KindMask == abi.Interface {
// Interfaces are unfortunately inconsistently handled
// when it comes to the type pointer, so it's easy to
// produce a lot of false positives here.
t := e._type
var et *_type
- if t.Kind_&kindMask != kindPtr {
+ if t.Kind_&abi.KindMask != abi.Pointer {
throw("bad argument to getgcmask: expected type to be a pointer to the value type whose mask is being queried")
}
et = (*ptrtype)(unsafe.Pointer(t)).Elem
maskFromHeap = maskFromHeap[:len(maskFromHeap)-1]
}
- if et.Kind_&kindGCProg == 0 {
+ if et.Kind_&abi.KindGCProg == 0 {
// Unroll again, but this time from the type information.
maskFromType := make([]byte, (limit-base)/goarch.PtrSize)
tp = s.typePointersOfType(et, base)
p := typ.GCData // start of 1-bit pointer mask (or GC program)
var gcProgBits uintptr
- if typ.Kind_&kindGCProg != 0 {
+ if typ.Kind_&abi.KindGCProg != 0 {
// Expand gc program, using the object itself for storage.
gcProgBits = runGCProg(addb(p, 4), (*byte)(ptr))
p = (*byte)(ptr)
h = h.pad(s, typ.Size_-typ.PtrBytes)
h.flush(s, uintptr(ptr), typ.Size_)
- if typ.Kind_&kindGCProg != 0 {
+ if typ.Kind_&abi.KindGCProg != 0 {
// Zero out temporary ptrmask buffer inside object.
memclrNoHeapPointers(ptr, (gcProgBits+7)/8)
}
h := writeHeapBitsForAddr(x)
// Handle GC program.
- if typ.Kind_&kindGCProg != 0 {
+ if typ.Kind_&abi.KindGCProg != 0 {
// Expand the gc program into the storage we're going to use for the actual object.
obj := (*uint8)(unsafe.Pointer(x))
n := runGCProg(addb(typ.GCData, 4), obj)
p := typ.GCData // start of 1-bit pointer mask (or GC program)
var gcProgBits uintptr
- if typ.Kind_&kindGCProg != 0 {
+ if typ.Kind_&abi.KindGCProg != 0 {
// Expand gc program, using the object itself for storage.
gcProgBits = runGCProg(addb(p, 4), (*byte)(ptr))
p = (*byte)(ptr)
h = h.pad(typ.Size_ - typ.PtrBytes)
h.flush(uintptr(ptr), typ.Size_)
- if typ.Kind_&kindGCProg != 0 {
+ if typ.Kind_&abi.KindGCProg != 0 {
// Zero out temporary ptrmask buffer inside object.
memclrNoHeapPointers(ptr, (gcProgBits+7)/8)
}
// confusing the write barrier.
*(*[2]uintptr)(frame) = [2]uintptr{}
}
- switch f.fint.Kind_ & kindMask {
- case kindPtr:
+ switch f.fint.Kind_ & abi.KindMask {
+ case abi.Pointer:
// direct use of pointer
*(*unsafe.Pointer)(r) = f.arg
- case kindInterface:
+ case abi.Interface:
ityp := (*interfacetype)(unsafe.Pointer(f.fint))
// set up with empty interface
(*eface)(r)._type = &f.ot.Type
if etyp == nil {
throw("runtime.SetFinalizer: first argument is nil")
}
- if etyp.Kind_&kindMask != kindPtr {
+ if etyp.Kind_&abi.KindMask != abi.Pointer {
throw("runtime.SetFinalizer: first argument is " + toRType(etyp).string() + ", not pointer")
}
ot := (*ptrtype)(unsafe.Pointer(etyp))
return
}
- if ftyp.Kind_&kindMask != kindFunc {
+ if ftyp.Kind_&abi.KindMask != abi.Func {
throw("runtime.SetFinalizer: second argument is " + toRType(ftyp).string() + ", not a function")
}
ft := (*functype)(unsafe.Pointer(ftyp))
case fint == etyp:
// ok - same type
goto okarg
- case fint.Kind_&kindMask == kindPtr:
+ case fint.Kind_&abi.KindMask == abi.Pointer:
if (fint.Uncommon() == nil || etyp.Uncommon() == nil) && (*ptrtype)(unsafe.Pointer(fint)).Elem == ot.Elem {
// ok - not same type, but both pointers,
// one or the other is unnamed, and same element type, so assignable.
goto okarg
}
- case fint.Kind_&kindMask == kindInterface:
+ case fint.Kind_&abi.KindMask == abi.Interface:
ityp := (*interfacetype)(unsafe.Pointer(fint))
if len(ityp.Methods) == 0 {
// ok - satisfies empty interface
package runtime
import (
+ "internal/abi"
"internal/runtime/atomic"
"unsafe"
)
if etyp == nil {
panic(errorString("runtime.Pinner: argument is nil"))
}
- if kind := etyp.Kind_ & kindMask; kind != kindPtr && kind != kindUnsafePointer {
+ if kind := etyp.Kind_ & abi.KindMask; kind != abi.Pointer && kind != abi.UnsafePointer {
panic(errorString("runtime.Pinner: argument is not a pointer: " + toRType(etyp).string()))
}
if inUserArenaChunk(uintptr(e.data)) {
package runtime
-import "unsafe"
+import (
+ "internal/abi"
+ "unsafe"
+)
//go:linkname plugin_lastmoduleinit plugin.lastmoduleinit
func plugin_lastmoduleinit() (path string, syms map[string]any, initTasks []*initTask, errstr string) {
(*valp)[0] = unsafe.Pointer(t)
name := symName.Name()
- if t.Kind_&kindMask == kindFunc {
+ if t.Kind_&abi.KindMask == abi.Func {
name = "." + name
}
syms[name] = val
// callerpc is a return PC of the function that calls this function,
// pc is start PC of the function that calls this function.
func raceReadObjectPC(t *_type, addr unsafe.Pointer, callerpc, pc uintptr) {
- kind := t.Kind_ & kindMask
- if kind == kindArray || kind == kindStruct {
+ kind := t.Kind_ & abi.KindMask
+ if kind == abi.Array || kind == abi.Struct {
// for composite objects we have to read every address
// because a write might happen to any subobject.
racereadrangepc(addr, t.Size_, callerpc, pc)
}
func raceWriteObjectPC(t *_type, addr unsafe.Pointer, callerpc, pc uintptr) {
- kind := t.Kind_ & kindMask
- if kind == kindArray || kind == kindStruct {
+ kind := t.Kind_ & abi.KindMask
+ if kind == abi.Array || kind == abi.Struct {
// for composite objects we have to write every address
// because a write might happen to any subobject.
racewriterangepc(addr, t.Size_, callerpc, pc)
func stkobjinit() {
var abiRegArgsEface any = abi.RegArgs{}
abiRegArgsType := efaceOf(&abiRegArgsEface)._type
- if abiRegArgsType.Kind_&kindGCProg != 0 {
+ if abiRegArgsType.Kind_&abi.KindGCProg != 0 {
throw("abiRegArgsType needs GC Prog, update methodValueCallFrameObjs")
}
// Set methodValueCallFrameObjs[0].gcdataoff so that
// registers and the stack.
panic("compileCallback: argument size is larger than uintptr")
}
- if k := t.Kind_ & kindMask; GOARCH != "386" && (k == kindFloat32 || k == kindFloat64) {
+ if k := t.Kind_ & abi.KindMask; GOARCH != "386" && (k == abi.Float32 || k == abi.Float64) {
// In fastcall, floating-point arguments in
// the first four positions are passed in
// floating-point registers, which we don't
//
// Returns whether the assignment succeeded.
func (p *abiDesc) tryRegAssignArg(t *_type, offset uintptr) bool {
- switch k := t.Kind_ & kindMask; k {
- case kindBool, kindInt, kindInt8, kindInt16, kindInt32, kindUint, kindUint8, kindUint16, kindUint32, kindUintptr, kindPtr, kindUnsafePointer:
+ switch k := t.Kind_ & abi.KindMask; k {
+ case abi.Bool, abi.Int, abi.Int8, abi.Int16, abi.Int32, abi.Uint, abi.Uint8, abi.Uint16, abi.Uint32, abi.Uintptr, abi.Pointer, abi.UnsafePointer:
// Assign a register for all these types.
return p.assignReg(t.Size_, offset)
- case kindInt64, kindUint64:
+ case abi.Int64, abi.Uint64:
// Only register-assign if the registers are big enough.
if goarch.PtrSize == 8 {
return p.assignReg(t.Size_, offset)
}
- case kindArray:
+ case abi.Array:
at := (*arraytype)(unsafe.Pointer(t))
if at.Len == 1 {
return p.tryRegAssignArg(at.Elem, offset) // TODO fix when runtime is fully commoned up w/ abi.Type
}
- case kindStruct:
+ case abi.Struct:
st := (*structtype)(unsafe.Pointer(t))
for i := range st.Fields {
f := &st.Fields[i]
cdecl = false
}
- if fn._type == nil || (fn._type.Kind_&kindMask) != kindFunc {
+ if fn._type == nil || (fn._type.Kind_&abi.KindMask) != abi.Func {
panic("compileCallback: expected function with one uintptr-sized result")
}
ft := (*functype)(unsafe.Pointer(fn._type))
if ft.OutSlice()[0].Size_ != goarch.PtrSize {
panic("compileCallback: expected function with one uintptr-sized result")
}
- if k := ft.OutSlice()[0].Kind_ & kindMask; k == kindFloat32 || k == kindFloat64 {
+ if k := ft.OutSlice()[0].Kind_ & abi.KindMask; k == abi.Float32 || k == abi.Float64 {
// In cdecl and stdcall, float results are returned in
// ST(0). In fastcall, they're returned in XMM0.
// Either way, it's not AX.
if u := t.uncommon(); u != nil {
return t.nameOff(u.PkgPath).Name()
}
- switch t.Kind_ & kindMask {
- case kindStruct:
+ switch t.Kind_ & abi.KindMask {
+ case abi.Struct:
st := (*structtype)(unsafe.Pointer(t.Type))
return st.PkgPath.Name()
- case kindInterface:
+ case abi.Interface:
it := (*interfacetype)(unsafe.Pointer(t.Type))
return it.PkgPath.Name()
}
if t == v {
return true
}
- kind := t.Kind_ & kindMask
- if kind != v.Kind_&kindMask {
+ kind := t.Kind_ & abi.KindMask
+ if kind != v.Kind_&abi.KindMask {
return false
}
rt, rv := toRType(t), toRType(v)
return false
}
}
- if kindBool <= kind && kind <= kindComplex128 {
+ if abi.Bool <= kind && kind <= abi.Complex128 {
return true
}
switch kind {
- case kindString, kindUnsafePointer:
+ case abi.String, abi.UnsafePointer:
return true
- case kindArray:
+ case abi.Array:
at := (*arraytype)(unsafe.Pointer(t))
av := (*arraytype)(unsafe.Pointer(v))
return typesEqual(at.Elem, av.Elem, seen) && at.Len == av.Len
- case kindChan:
+ case abi.Chan:
ct := (*chantype)(unsafe.Pointer(t))
cv := (*chantype)(unsafe.Pointer(v))
return ct.Dir == cv.Dir && typesEqual(ct.Elem, cv.Elem, seen)
- case kindFunc:
+ case abi.Func:
ft := (*functype)(unsafe.Pointer(t))
fv := (*functype)(unsafe.Pointer(v))
if ft.OutCount != fv.OutCount || ft.InCount != fv.InCount {
}
}
return true
- case kindInterface:
+ case abi.Interface:
it := (*interfacetype)(unsafe.Pointer(t))
iv := (*interfacetype)(unsafe.Pointer(v))
if it.PkgPath.Name() != iv.PkgPath.Name() {
}
}
return true
- case kindMap:
+ case abi.Map:
mt := (*maptype)(unsafe.Pointer(t))
mv := (*maptype)(unsafe.Pointer(v))
return typesEqual(mt.Key, mv.Key, seen) && typesEqual(mt.Elem, mv.Elem, seen)
- case kindPtr:
+ case abi.Pointer:
pt := (*ptrtype)(unsafe.Pointer(t))
pv := (*ptrtype)(unsafe.Pointer(v))
return typesEqual(pt.Elem, pv.Elem, seen)
- case kindSlice:
+ case abi.Slice:
st := (*slicetype)(unsafe.Pointer(t))
sv := (*slicetype)(unsafe.Pointer(v))
return typesEqual(st.Elem, sv.Elem, seen)
- case kindStruct:
+ case abi.Struct:
st := (*structtype)(unsafe.Pointer(t))
sv := (*structtype)(unsafe.Pointer(v))
if len(st.Fields) != len(sv.Fields) {
package runtime
-const (
- kindBool = 1 + iota
- kindInt
- kindInt8
- kindInt16
- kindInt32
- kindInt64
- kindUint
- kindUint8
- kindUint16
- kindUint32
- kindUint64
- kindUintptr
- kindFloat32
- kindFloat64
- kindComplex64
- kindComplex128
- kindArray
- kindChan
- kindFunc
- kindInterface
- kindMap
- kindPtr
- kindSlice
- kindString
- kindStruct
- kindUnsafePointer
-
- kindDirectIface = 1 << 5
- kindGCProg = 1 << 6
- kindMask = (1 << 5) - 1
-)
+import "internal/abi"
// isDirectIface reports whether t is stored directly in an interface value.
func isDirectIface(t *_type) bool {
- return t.Kind_&kindDirectIface != 0
+ return t.Kind_&abi.KindDirectIface != 0
}