Merge pull request #313 from visualfc/globals

ssa: global use elem type
This commit is contained in:
xushiwei
2024-06-15 06:59:06 +08:00
committed by GitHub
87 changed files with 4623 additions and 3601 deletions

View File

@@ -342,7 +342,7 @@ func EfaceEqual(v, u eface) bool {
if v._type != u._type {
return false
}
if v._type.Kind_&abi.KindDirectIface != 0 {
if isDirectIface(v._type) {
return v.data == u.data
}
switch v.Kind() {
@@ -373,7 +373,11 @@ func EfaceEqual(v, u eface) bool {
case abi.Struct:
st := v._type.StructType()
field := func(data unsafe.Pointer, ft *abi.StructField) eface {
return eface{ft.Typ, c.Advance(data, int(ft.Offset))}
ptr := c.Advance(data, int(ft.Offset))
if isDirectIface(ft.Typ) {
ptr = *(*unsafe.Pointer)(ptr)
}
return eface{ft.Typ, ptr}
}
for _, ft := range st.Fields {
if !EfaceEqual(field(v.data, &ft), field(u.data, &ft)) {
@@ -409,7 +413,7 @@ func (v eface) Elem() eface {
return *(*eface)(unsafe.Pointer(&i))
case abi.Pointer:
ptr := v.data
if v._type.Kind_&abi.KindDirectIface != 0 {
if isDirectIface(v._type) {
ptr = *(*unsafe.Pointer)(ptr)
}
if ptr == nil {
@@ -420,4 +424,8 @@ func (v eface) Elem() eface {
panic("invalid eface elem")
}
func isDirectIface(t *_type) bool {
return t.Kind_&abi.KindDirectIface != 0
}
// -----------------------------------------------------------------------------