diff --git a/internal/cmd/generator/vm.go.tmpl b/internal/cmd/generator/vm.go.tmpl index ccbbfdd..5857249 100644 --- a/internal/cmd/generator/vm.go.tmpl +++ b/internal/cmd/generator/vm.go.tmpl @@ -190,12 +190,13 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b typ *runtime.Type ifacePtr unsafe.Pointer ) + up := ptrToUnsafePtr(p) if code.Flags&encoder.NonEmptyInterfaceFlags != 0 { - iface := (*nonEmptyInterface)(ptrToUnsafePtr(p)) + iface := (*nonEmptyInterface)(up) ifacePtr = iface.ptr typ = iface.itab.typ } else { - iface := (*emptyInterface)(ptrToUnsafePtr(p)) + iface := (*emptyInterface)(up) ifacePtr = iface.ptr typ = iface.typ } @@ -205,7 +206,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b code = code.Next break } - ctx.KeepRefs = append(ctx.KeepRefs, unsafe.Pointer(p)) + ctx.KeepRefs = append(ctx.KeepRefs, up) ifaceCodeSet, err := encoder.CompileToGetCodeSet(uintptr(unsafe.Pointer(typ))) if err != nil { return nil, err diff --git a/internal/encoder/vm/vm.go b/internal/encoder/vm/vm.go index ccbbfdd..5857249 100644 --- a/internal/encoder/vm/vm.go +++ b/internal/encoder/vm/vm.go @@ -190,12 +190,13 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b typ *runtime.Type ifacePtr unsafe.Pointer ) + up := ptrToUnsafePtr(p) if code.Flags&encoder.NonEmptyInterfaceFlags != 0 { - iface := (*nonEmptyInterface)(ptrToUnsafePtr(p)) + iface := (*nonEmptyInterface)(up) ifacePtr = iface.ptr typ = iface.itab.typ } else { - iface := (*emptyInterface)(ptrToUnsafePtr(p)) + iface := (*emptyInterface)(up) ifacePtr = iface.ptr typ = iface.typ } @@ -205,7 +206,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b code = code.Next break } - ctx.KeepRefs = append(ctx.KeepRefs, unsafe.Pointer(p)) + ctx.KeepRefs = append(ctx.KeepRefs, up) ifaceCodeSet, err := encoder.CompileToGetCodeSet(uintptr(unsafe.Pointer(typ))) if err != nil { return nil, err diff --git a/internal/encoder/vm_color/vm.go b/internal/encoder/vm_color/vm.go index b7f6560..73af884 100644 --- a/internal/encoder/vm_color/vm.go +++ b/internal/encoder/vm_color/vm.go @@ -190,12 +190,13 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b typ *runtime.Type ifacePtr unsafe.Pointer ) + up := ptrToUnsafePtr(p) if code.Flags&encoder.NonEmptyInterfaceFlags != 0 { - iface := (*nonEmptyInterface)(ptrToUnsafePtr(p)) + iface := (*nonEmptyInterface)(up) ifacePtr = iface.ptr typ = iface.itab.typ } else { - iface := (*emptyInterface)(ptrToUnsafePtr(p)) + iface := (*emptyInterface)(up) ifacePtr = iface.ptr typ = iface.typ } @@ -205,7 +206,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b code = code.Next break } - ctx.KeepRefs = append(ctx.KeepRefs, unsafe.Pointer(p)) + ctx.KeepRefs = append(ctx.KeepRefs, up) ifaceCodeSet, err := encoder.CompileToGetCodeSet(uintptr(unsafe.Pointer(typ))) if err != nil { return nil, err diff --git a/internal/encoder/vm_color_indent/vm.go b/internal/encoder/vm_color_indent/vm.go index 9e17654..7b7844e 100644 --- a/internal/encoder/vm_color_indent/vm.go +++ b/internal/encoder/vm_color_indent/vm.go @@ -190,12 +190,13 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b typ *runtime.Type ifacePtr unsafe.Pointer ) + up := ptrToUnsafePtr(p) if code.Flags&encoder.NonEmptyInterfaceFlags != 0 { - iface := (*nonEmptyInterface)(ptrToUnsafePtr(p)) + iface := (*nonEmptyInterface)(up) ifacePtr = iface.ptr typ = iface.itab.typ } else { - iface := (*emptyInterface)(ptrToUnsafePtr(p)) + iface := (*emptyInterface)(up) ifacePtr = iface.ptr typ = iface.typ } @@ -205,7 +206,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b code = code.Next break } - ctx.KeepRefs = append(ctx.KeepRefs, unsafe.Pointer(p)) + ctx.KeepRefs = append(ctx.KeepRefs, up) ifaceCodeSet, err := encoder.CompileToGetCodeSet(uintptr(unsafe.Pointer(typ))) if err != nil { return nil, err diff --git a/internal/encoder/vm_indent/vm.go b/internal/encoder/vm_indent/vm.go index ac1285a..6e05155 100644 --- a/internal/encoder/vm_indent/vm.go +++ b/internal/encoder/vm_indent/vm.go @@ -190,12 +190,13 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b typ *runtime.Type ifacePtr unsafe.Pointer ) + up := ptrToUnsafePtr(p) if code.Flags&encoder.NonEmptyInterfaceFlags != 0 { - iface := (*nonEmptyInterface)(ptrToUnsafePtr(p)) + iface := (*nonEmptyInterface)(up) ifacePtr = iface.ptr typ = iface.itab.typ } else { - iface := (*emptyInterface)(ptrToUnsafePtr(p)) + iface := (*emptyInterface)(up) ifacePtr = iface.ptr typ = iface.typ } @@ -205,7 +206,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b code = code.Next break } - ctx.KeepRefs = append(ctx.KeepRefs, unsafe.Pointer(p)) + ctx.KeepRefs = append(ctx.KeepRefs, up) ifaceCodeSet, err := encoder.CompileToGetCodeSet(uintptr(unsafe.Pointer(typ))) if err != nil { return nil, err