This commit is contained in:
Masaaki Goshima 2021-08-30 13:11:44 +09:00
parent 92d8dcd13b
commit 97c3cf6c55
5 changed files with 20 additions and 15 deletions

View File

@ -190,12 +190,13 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
typ *runtime.Type typ *runtime.Type
ifacePtr unsafe.Pointer ifacePtr unsafe.Pointer
) )
up := ptrToUnsafePtr(p)
if code.Flags&encoder.NonEmptyInterfaceFlags != 0 { if code.Flags&encoder.NonEmptyInterfaceFlags != 0 {
iface := (*nonEmptyInterface)(ptrToUnsafePtr(p)) iface := (*nonEmptyInterface)(up)
ifacePtr = iface.ptr ifacePtr = iface.ptr
typ = iface.itab.typ typ = iface.itab.typ
} else { } else {
iface := (*emptyInterface)(ptrToUnsafePtr(p)) iface := (*emptyInterface)(up)
ifacePtr = iface.ptr ifacePtr = iface.ptr
typ = iface.typ typ = iface.typ
} }
@ -205,7 +206,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
code = code.Next code = code.Next
break break
} }
ctx.KeepRefs = append(ctx.KeepRefs, unsafe.Pointer(p)) ctx.KeepRefs = append(ctx.KeepRefs, up)
ifaceCodeSet, err := encoder.CompileToGetCodeSet(uintptr(unsafe.Pointer(typ))) ifaceCodeSet, err := encoder.CompileToGetCodeSet(uintptr(unsafe.Pointer(typ)))
if err != nil { if err != nil {
return nil, err return nil, err

View File

@ -190,12 +190,13 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
typ *runtime.Type typ *runtime.Type
ifacePtr unsafe.Pointer ifacePtr unsafe.Pointer
) )
up := ptrToUnsafePtr(p)
if code.Flags&encoder.NonEmptyInterfaceFlags != 0 { if code.Flags&encoder.NonEmptyInterfaceFlags != 0 {
iface := (*nonEmptyInterface)(ptrToUnsafePtr(p)) iface := (*nonEmptyInterface)(up)
ifacePtr = iface.ptr ifacePtr = iface.ptr
typ = iface.itab.typ typ = iface.itab.typ
} else { } else {
iface := (*emptyInterface)(ptrToUnsafePtr(p)) iface := (*emptyInterface)(up)
ifacePtr = iface.ptr ifacePtr = iface.ptr
typ = iface.typ typ = iface.typ
} }
@ -205,7 +206,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
code = code.Next code = code.Next
break break
} }
ctx.KeepRefs = append(ctx.KeepRefs, unsafe.Pointer(p)) ctx.KeepRefs = append(ctx.KeepRefs, up)
ifaceCodeSet, err := encoder.CompileToGetCodeSet(uintptr(unsafe.Pointer(typ))) ifaceCodeSet, err := encoder.CompileToGetCodeSet(uintptr(unsafe.Pointer(typ)))
if err != nil { if err != nil {
return nil, err return nil, err

View File

@ -190,12 +190,13 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
typ *runtime.Type typ *runtime.Type
ifacePtr unsafe.Pointer ifacePtr unsafe.Pointer
) )
up := ptrToUnsafePtr(p)
if code.Flags&encoder.NonEmptyInterfaceFlags != 0 { if code.Flags&encoder.NonEmptyInterfaceFlags != 0 {
iface := (*nonEmptyInterface)(ptrToUnsafePtr(p)) iface := (*nonEmptyInterface)(up)
ifacePtr = iface.ptr ifacePtr = iface.ptr
typ = iface.itab.typ typ = iface.itab.typ
} else { } else {
iface := (*emptyInterface)(ptrToUnsafePtr(p)) iface := (*emptyInterface)(up)
ifacePtr = iface.ptr ifacePtr = iface.ptr
typ = iface.typ typ = iface.typ
} }
@ -205,7 +206,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
code = code.Next code = code.Next
break break
} }
ctx.KeepRefs = append(ctx.KeepRefs, unsafe.Pointer(p)) ctx.KeepRefs = append(ctx.KeepRefs, up)
ifaceCodeSet, err := encoder.CompileToGetCodeSet(uintptr(unsafe.Pointer(typ))) ifaceCodeSet, err := encoder.CompileToGetCodeSet(uintptr(unsafe.Pointer(typ)))
if err != nil { if err != nil {
return nil, err return nil, err

View File

@ -190,12 +190,13 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
typ *runtime.Type typ *runtime.Type
ifacePtr unsafe.Pointer ifacePtr unsafe.Pointer
) )
up := ptrToUnsafePtr(p)
if code.Flags&encoder.NonEmptyInterfaceFlags != 0 { if code.Flags&encoder.NonEmptyInterfaceFlags != 0 {
iface := (*nonEmptyInterface)(ptrToUnsafePtr(p)) iface := (*nonEmptyInterface)(up)
ifacePtr = iface.ptr ifacePtr = iface.ptr
typ = iface.itab.typ typ = iface.itab.typ
} else { } else {
iface := (*emptyInterface)(ptrToUnsafePtr(p)) iface := (*emptyInterface)(up)
ifacePtr = iface.ptr ifacePtr = iface.ptr
typ = iface.typ typ = iface.typ
} }
@ -205,7 +206,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
code = code.Next code = code.Next
break break
} }
ctx.KeepRefs = append(ctx.KeepRefs, unsafe.Pointer(p)) ctx.KeepRefs = append(ctx.KeepRefs, up)
ifaceCodeSet, err := encoder.CompileToGetCodeSet(uintptr(unsafe.Pointer(typ))) ifaceCodeSet, err := encoder.CompileToGetCodeSet(uintptr(unsafe.Pointer(typ)))
if err != nil { if err != nil {
return nil, err return nil, err

View File

@ -190,12 +190,13 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
typ *runtime.Type typ *runtime.Type
ifacePtr unsafe.Pointer ifacePtr unsafe.Pointer
) )
up := ptrToUnsafePtr(p)
if code.Flags&encoder.NonEmptyInterfaceFlags != 0 { if code.Flags&encoder.NonEmptyInterfaceFlags != 0 {
iface := (*nonEmptyInterface)(ptrToUnsafePtr(p)) iface := (*nonEmptyInterface)(up)
ifacePtr = iface.ptr ifacePtr = iface.ptr
typ = iface.itab.typ typ = iface.itab.typ
} else { } else {
iface := (*emptyInterface)(ptrToUnsafePtr(p)) iface := (*emptyInterface)(up)
ifacePtr = iface.ptr ifacePtr = iface.ptr
typ = iface.typ typ = iface.typ
} }
@ -205,7 +206,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
code = code.Next code = code.Next
break break
} }
ctx.KeepRefs = append(ctx.KeepRefs, unsafe.Pointer(p)) ctx.KeepRefs = append(ctx.KeepRefs, up)
ifaceCodeSet, err := encoder.CompileToGetCodeSet(uintptr(unsafe.Pointer(typ))) ifaceCodeSet, err := encoder.CompileToGetCodeSet(uintptr(unsafe.Pointer(typ)))
if err != nil { if err != nil {
return nil, err return nil, err