From 97c3cf6c55286ae5a34f8c04ed77bac72d399658 Mon Sep 17 00:00:00 2001 From: Masaaki Goshima Date: Mon, 30 Aug 2021 13:11:44 +0900 Subject: [PATCH] Fix test --- internal/cmd/generator/vm.go.tmpl | 7 ++++--- internal/encoder/vm/vm.go | 7 ++++--- internal/encoder/vm_color/vm.go | 7 ++++--- internal/encoder/vm_color_indent/vm.go | 7 ++++--- internal/encoder/vm_indent/vm.go | 7 ++++--- 5 files changed, 20 insertions(+), 15 deletions(-) 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