internal/runtime: check abi.KindDirectIface
This commit is contained in:
@@ -674,15 +674,12 @@ bucketloop:
|
||||
kmem := newobject(t.Key)
|
||||
*(*unsafe.Pointer)(insertk) = kmem
|
||||
insertk = kmem
|
||||
*(*unsafe.Pointer)(insertk) = key
|
||||
}
|
||||
if t.IndirectElem() {
|
||||
vmem := newobject(t.Elem)
|
||||
*(*unsafe.Pointer)(elem) = vmem
|
||||
}
|
||||
|
||||
typedmemmove(t.Key, insertk, key)
|
||||
|
||||
*inserti = top
|
||||
h.count++
|
||||
|
||||
|
||||
@@ -302,10 +302,6 @@ func IfacePtrData(i iface) unsafe.Pointer {
|
||||
return i.data
|
||||
}
|
||||
|
||||
func SetDirectIface(t *abi.Type) {
|
||||
t.Kind_ |= abi.KindDirectIface
|
||||
}
|
||||
|
||||
// Implements reports whether the type V implements the interface type T.
|
||||
func Implements(T, V *abi.Type) bool {
|
||||
if V == nil {
|
||||
|
||||
@@ -68,7 +68,8 @@ func basicFlags(kind Kind) abi.TFlag {
|
||||
return abi.TFlagRegularMemory
|
||||
}
|
||||
|
||||
func Basic(kind Kind) *Type {
|
||||
func Basic(_kind Kind) *Type {
|
||||
kind := _kind & abi.KindMask
|
||||
if tyBasic[kind] == nil {
|
||||
name, size, align := basicTypeInfo(kind)
|
||||
tyBasic[kind] = &Type{
|
||||
@@ -76,7 +77,7 @@ func Basic(kind Kind) *Type {
|
||||
Hash: uint32(kind), // TODO(xsw): hash
|
||||
Align_: uint8(align),
|
||||
FieldAlign_: uint8(align),
|
||||
Kind_: uint8(kind),
|
||||
Kind_: uint8(_kind),
|
||||
Equal: basicEqual(kind, size),
|
||||
TFlag: basicFlags(kind),
|
||||
Str_: name,
|
||||
@@ -182,6 +183,9 @@ func Struct(pkgPath string, size uintptr, fields ...abi.StructField) *Type {
|
||||
if isRegularMemory(&ret.Type) {
|
||||
ret.TFlag = abi.TFlagRegularMemory
|
||||
}
|
||||
if len(fields) == 1 && isDirectIface(fields[0].Typ) {
|
||||
ret.Kind_ |= abi.KindDirectIface
|
||||
}
|
||||
return &ret.Type
|
||||
}
|
||||
|
||||
@@ -271,6 +275,9 @@ func ArrayOf(length uintptr, elem *Type) *Type {
|
||||
if ret.Len == 0 || ret.Elem.TFlag&abi.TFlagRegularMemory != 0 {
|
||||
ret.TFlag = abi.TFlagRegularMemory
|
||||
}
|
||||
if ret.Len == 1 && isDirectIface(ret.Elem) {
|
||||
ret.Kind_ |= abi.KindDirectIface
|
||||
}
|
||||
return &ret.Type
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user