Refactor opcode fields

This commit is contained in:
Masaaki Goshima 2021-12-27 17:50:55 +09:00
parent c220d90e4c
commit 5418c49bcf
No known key found for this signature in database
GPG Key ID: 6A53785055537153
7 changed files with 32 additions and 67 deletions

View File

@ -405,7 +405,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
b = appendStructHead(ctx, b) b = appendStructHead(ctx, b)
mapCtx := encoder.NewMapContext(mlen) mapCtx := encoder.NewMapContext(mlen)
mapiterinit(code.Type, uptr, &mapCtx.Iter) mapiterinit(code.Type, uptr, &mapCtx.Iter)
store(ctxptr, code.MapIter, uintptr(unsafe.Pointer(mapCtx))) store(ctxptr, code.Idx, uintptr(unsafe.Pointer(mapCtx)))
ctx.KeepRefs = append(ctx.KeepRefs, unsafe.Pointer(mapCtx)) ctx.KeepRefs = append(ctx.KeepRefs, unsafe.Pointer(mapCtx))
if (ctx.Option.Flag & encoder.UnorderedMapOption) != 0 { if (ctx.Option.Flag & encoder.UnorderedMapOption) != 0 {
b = appendMapKeyIndent(ctx, code.Next, b) b = appendMapKeyIndent(ctx, code.Next, b)
@ -417,7 +417,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
store(ctxptr, code.Next.Idx, uintptr(key)) store(ctxptr, code.Next.Idx, uintptr(key))
code = code.Next code = code.Next
case encoder.OpMapKey: case encoder.OpMapKey:
mapCtx := (*encoder.MapContext)(ptrToUnsafePtr(load(ctxptr, code.MapIter))) mapCtx := (*encoder.MapContext)(ptrToUnsafePtr(load(ctxptr, code.Idx)))
idx := mapCtx.Idx idx := mapCtx.Idx
idx++ idx++
if (ctx.Option.Flag & encoder.UnorderedMapOption) != 0 { if (ctx.Option.Flag & encoder.UnorderedMapOption) != 0 {
@ -445,7 +445,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
} }
} }
case encoder.OpMapValue: case encoder.OpMapValue:
mapCtx := (*encoder.MapContext)(ptrToUnsafePtr(load(ctxptr, code.MapIter))) mapCtx := (*encoder.MapContext)(ptrToUnsafePtr(load(ctxptr, code.Idx)))
if (ctx.Option.Flag & encoder.UnorderedMapOption) != 0 { if (ctx.Option.Flag & encoder.UnorderedMapOption) != 0 {
b = appendColon(ctx, b) b = appendColon(ctx, b)
} else { } else {
@ -458,7 +458,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
code = code.Next code = code.Next
case encoder.OpMapEnd: case encoder.OpMapEnd:
// this operation only used by sorted map. // this operation only used by sorted map.
mapCtx := (*encoder.MapContext)(ptrToUnsafePtr(load(ctxptr, code.MapIter))) mapCtx := (*encoder.MapContext)(ptrToUnsafePtr(load(ctxptr, code.Idx)))
sort.Sort(mapCtx.Slice) sort.Sort(mapCtx.Slice)
buf := mapCtx.Buf buf := mapCtx.Buf
for _, item := range mapCtx.Slice.Items { for _, item := range mapCtx.Slice.Items {

View File

@ -39,10 +39,8 @@ type Opcode struct {
Type *runtime.Type // go type Type *runtime.Type // go type
Jmp *CompiledCode // for recursive call Jmp *CompiledCode // for recursive call
ElemIdx uint32 // offset to access array/slice/map elem ElemIdx uint32 // offset to access array/slice elem
Length uint32 // offset to access slice/map length or array length Length uint32 // offset to access slice length or array length
MapIter uint32 // offset to access map iterator
MapPos uint32 // offset to access position list for sorted map
Indent uint32 // indent number Indent uint32 // indent number
Size uint32 // array/slice elem size Size uint32 // array/slice elem size
DisplayIdx uint32 // opcode index DisplayIdx uint32 // opcode index
@ -91,8 +89,6 @@ func (c *Opcode) MaxIdx() uint32 {
c.Idx, c.Idx,
c.ElemIdx, c.ElemIdx,
c.Length, c.Length,
c.MapIter,
c.MapPos,
c.Size, c.Size,
} { } {
if max < value { if max < value {
@ -341,8 +337,6 @@ func copyOpcode(code *Opcode) *Opcode {
DisplayKey: c.DisplayKey, DisplayKey: c.DisplayKey,
ElemIdx: c.ElemIdx, ElemIdx: c.ElemIdx,
Length: c.Length, Length: c.Length,
MapIter: c.MapIter,
MapPos: c.MapPos,
Size: c.Size, Size: c.Size,
Indent: c.Indent, Indent: c.Indent,
Jmp: c.Jmp, Jmp: c.Jmp,
@ -448,26 +442,21 @@ func (c *Opcode) dumpHead(code *Opcode) string {
func (c *Opcode) dumpMapHead(code *Opcode) string { func (c *Opcode) dumpMapHead(code *Opcode) string {
return fmt.Sprintf( return fmt.Sprintf(
`[%03d]%s%s ([idx:%d][elemIdx:%d][length:%d][mapIter:%d])`, `[%03d]%s%s ([idx:%d])`,
code.DisplayIdx, code.DisplayIdx,
strings.Repeat("-", int(code.Indent)), strings.Repeat("-", int(code.Indent)),
code.Op, code.Op,
code.Idx/uintptrSize, code.Idx/uintptrSize,
code.ElemIdx/uintptrSize,
code.Length/uintptrSize,
code.MapIter/uintptrSize,
) )
} }
func (c *Opcode) dumpMapEnd(code *Opcode) string { func (c *Opcode) dumpMapEnd(code *Opcode) string {
return fmt.Sprintf( return fmt.Sprintf(
`[%03d]%s%s ([idx:%d][mapPos:%d][length:%d])`, `[%03d]%s%s ([idx:%d])`,
code.DisplayIdx, code.DisplayIdx,
strings.Repeat("-", int(code.Indent)), strings.Repeat("-", int(code.Indent)),
code.Op, code.Op,
code.Idx/uintptrSize, code.Idx/uintptrSize,
code.MapPos/uintptrSize,
code.Length/uintptrSize,
) )
} }
@ -504,25 +493,21 @@ func (c *Opcode) dumpField(code *Opcode) string {
func (c *Opcode) dumpKey(code *Opcode) string { func (c *Opcode) dumpKey(code *Opcode) string {
return fmt.Sprintf( return fmt.Sprintf(
`[%03d]%s%s ([idx:%d][elemIdx:%d][length:%d][mapIter:%d])`, `[%03d]%s%s ([idx:%d])`,
code.DisplayIdx, code.DisplayIdx,
strings.Repeat("-", int(code.Indent)), strings.Repeat("-", int(code.Indent)),
code.Op, code.Op,
code.Idx/uintptrSize, code.Idx/uintptrSize,
code.ElemIdx/uintptrSize,
code.Length/uintptrSize,
code.MapIter/uintptrSize,
) )
} }
func (c *Opcode) dumpValue(code *Opcode) string { func (c *Opcode) dumpValue(code *Opcode) string {
return fmt.Sprintf( return fmt.Sprintf(
`[%03d]%s%s ([idx:%d][mapIter:%d])`, `[%03d]%s%s ([idx:%d])`,
code.DisplayIdx, code.DisplayIdx,
strings.Repeat("-", int(code.Indent)), strings.Repeat("-", int(code.Indent)),
code.Op, code.Op,
code.Idx/uintptrSize, code.Idx/uintptrSize,
code.MapIter/uintptrSize,
) )
} }
@ -629,19 +614,11 @@ func newArrayElemCode(ctx *compileContext, typ *runtime.Type, head *Opcode, leng
func newMapHeaderCode(ctx *compileContext, typ *runtime.Type) *Opcode { func newMapHeaderCode(ctx *compileContext, typ *runtime.Type) *Opcode {
idx := opcodeOffset(ctx.ptrIndex) idx := opcodeOffset(ctx.ptrIndex)
ctx.incPtrIndex() ctx.incPtrIndex()
elemIdx := opcodeOffset(ctx.ptrIndex)
ctx.incPtrIndex()
length := opcodeOffset(ctx.ptrIndex)
ctx.incPtrIndex()
mapIter := opcodeOffset(ctx.ptrIndex)
return &Opcode{ return &Opcode{
Op: OpMap, Op: OpMap,
Type: typ, Type: typ,
Idx: idx, Idx: idx,
DisplayIdx: ctx.opcodeIndex, DisplayIdx: ctx.opcodeIndex,
ElemIdx: elemIdx,
Length: length,
MapIter: mapIter,
Indent: ctx.indent, Indent: ctx.indent,
} }
} }
@ -650,11 +627,8 @@ func newMapKeyCode(ctx *compileContext, typ *runtime.Type, head *Opcode) *Opcode
return &Opcode{ return &Opcode{
Op: OpMapKey, Op: OpMapKey,
Type: typ, Type: typ,
Idx: opcodeOffset(ctx.ptrIndex), Idx: head.Idx,
DisplayIdx: ctx.opcodeIndex, DisplayIdx: ctx.opcodeIndex,
ElemIdx: head.ElemIdx,
Length: head.Length,
MapIter: head.MapIter,
Indent: ctx.indent, Indent: ctx.indent,
} }
} }
@ -663,29 +637,20 @@ func newMapValueCode(ctx *compileContext, typ *runtime.Type, head *Opcode) *Opco
return &Opcode{ return &Opcode{
Op: OpMapValue, Op: OpMapValue,
Type: typ, Type: typ,
Idx: opcodeOffset(ctx.ptrIndex), Idx: head.Idx,
DisplayIdx: ctx.opcodeIndex, DisplayIdx: ctx.opcodeIndex,
ElemIdx: head.ElemIdx,
Length: head.Length,
MapIter: head.MapIter,
Indent: ctx.indent, Indent: ctx.indent,
} }
} }
func newMapEndCode(ctx *compileContext, typ *runtime.Type, head *Opcode) *Opcode { func newMapEndCode(ctx *compileContext, typ *runtime.Type, head *Opcode) *Opcode {
mapPos := opcodeOffset(ctx.ptrIndex)
ctx.incPtrIndex()
idx := opcodeOffset(ctx.ptrIndex)
return &Opcode{ return &Opcode{
Op: OpMapEnd, Op: OpMapEnd,
Type: typ, Type: typ,
Idx: idx, Idx: head.Idx,
Next: newEndOp(ctx, typ),
DisplayIdx: ctx.opcodeIndex, DisplayIdx: ctx.opcodeIndex,
Length: head.Length,
MapPos: mapPos,
Indent: ctx.indent, Indent: ctx.indent,
MapIter: head.MapIter, Next: newEndOp(ctx, typ),
} }
} }

View File

@ -405,7 +405,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
b = appendStructHead(ctx, b) b = appendStructHead(ctx, b)
mapCtx := encoder.NewMapContext(mlen) mapCtx := encoder.NewMapContext(mlen)
mapiterinit(code.Type, uptr, &mapCtx.Iter) mapiterinit(code.Type, uptr, &mapCtx.Iter)
store(ctxptr, code.MapIter, uintptr(unsafe.Pointer(mapCtx))) store(ctxptr, code.Idx, uintptr(unsafe.Pointer(mapCtx)))
ctx.KeepRefs = append(ctx.KeepRefs, unsafe.Pointer(mapCtx)) ctx.KeepRefs = append(ctx.KeepRefs, unsafe.Pointer(mapCtx))
if (ctx.Option.Flag & encoder.UnorderedMapOption) != 0 { if (ctx.Option.Flag & encoder.UnorderedMapOption) != 0 {
b = appendMapKeyIndent(ctx, code.Next, b) b = appendMapKeyIndent(ctx, code.Next, b)
@ -417,7 +417,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
store(ctxptr, code.Next.Idx, uintptr(key)) store(ctxptr, code.Next.Idx, uintptr(key))
code = code.Next code = code.Next
case encoder.OpMapKey: case encoder.OpMapKey:
mapCtx := (*encoder.MapContext)(ptrToUnsafePtr(load(ctxptr, code.MapIter))) mapCtx := (*encoder.MapContext)(ptrToUnsafePtr(load(ctxptr, code.Idx)))
idx := mapCtx.Idx idx := mapCtx.Idx
idx++ idx++
if (ctx.Option.Flag & encoder.UnorderedMapOption) != 0 { if (ctx.Option.Flag & encoder.UnorderedMapOption) != 0 {
@ -445,7 +445,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
} }
} }
case encoder.OpMapValue: case encoder.OpMapValue:
mapCtx := (*encoder.MapContext)(ptrToUnsafePtr(load(ctxptr, code.MapIter))) mapCtx := (*encoder.MapContext)(ptrToUnsafePtr(load(ctxptr, code.Idx)))
if (ctx.Option.Flag & encoder.UnorderedMapOption) != 0 { if (ctx.Option.Flag & encoder.UnorderedMapOption) != 0 {
b = appendColon(ctx, b) b = appendColon(ctx, b)
} else { } else {
@ -458,7 +458,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
code = code.Next code = code.Next
case encoder.OpMapEnd: case encoder.OpMapEnd:
// this operation only used by sorted map. // this operation only used by sorted map.
mapCtx := (*encoder.MapContext)(ptrToUnsafePtr(load(ctxptr, code.MapIter))) mapCtx := (*encoder.MapContext)(ptrToUnsafePtr(load(ctxptr, code.Idx)))
sort.Sort(mapCtx.Slice) sort.Sort(mapCtx.Slice)
buf := mapCtx.Buf buf := mapCtx.Buf
for _, item := range mapCtx.Slice.Items { for _, item := range mapCtx.Slice.Items {

View File

@ -405,7 +405,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
b = appendStructHead(ctx, b) b = appendStructHead(ctx, b)
mapCtx := encoder.NewMapContext(mlen) mapCtx := encoder.NewMapContext(mlen)
mapiterinit(code.Type, uptr, &mapCtx.Iter) mapiterinit(code.Type, uptr, &mapCtx.Iter)
store(ctxptr, code.MapIter, uintptr(unsafe.Pointer(mapCtx))) store(ctxptr, code.Idx, uintptr(unsafe.Pointer(mapCtx)))
ctx.KeepRefs = append(ctx.KeepRefs, unsafe.Pointer(mapCtx)) ctx.KeepRefs = append(ctx.KeepRefs, unsafe.Pointer(mapCtx))
if (ctx.Option.Flag & encoder.UnorderedMapOption) != 0 { if (ctx.Option.Flag & encoder.UnorderedMapOption) != 0 {
b = appendMapKeyIndent(ctx, code.Next, b) b = appendMapKeyIndent(ctx, code.Next, b)
@ -417,7 +417,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
store(ctxptr, code.Next.Idx, uintptr(key)) store(ctxptr, code.Next.Idx, uintptr(key))
code = code.Next code = code.Next
case encoder.OpMapKey: case encoder.OpMapKey:
mapCtx := (*encoder.MapContext)(ptrToUnsafePtr(load(ctxptr, code.MapIter))) mapCtx := (*encoder.MapContext)(ptrToUnsafePtr(load(ctxptr, code.Idx)))
idx := mapCtx.Idx idx := mapCtx.Idx
idx++ idx++
if (ctx.Option.Flag & encoder.UnorderedMapOption) != 0 { if (ctx.Option.Flag & encoder.UnorderedMapOption) != 0 {
@ -445,7 +445,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
} }
} }
case encoder.OpMapValue: case encoder.OpMapValue:
mapCtx := (*encoder.MapContext)(ptrToUnsafePtr(load(ctxptr, code.MapIter))) mapCtx := (*encoder.MapContext)(ptrToUnsafePtr(load(ctxptr, code.Idx)))
if (ctx.Option.Flag & encoder.UnorderedMapOption) != 0 { if (ctx.Option.Flag & encoder.UnorderedMapOption) != 0 {
b = appendColon(ctx, b) b = appendColon(ctx, b)
} else { } else {
@ -458,7 +458,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
code = code.Next code = code.Next
case encoder.OpMapEnd: case encoder.OpMapEnd:
// this operation only used by sorted map. // this operation only used by sorted map.
mapCtx := (*encoder.MapContext)(ptrToUnsafePtr(load(ctxptr, code.MapIter))) mapCtx := (*encoder.MapContext)(ptrToUnsafePtr(load(ctxptr, code.Idx)))
sort.Sort(mapCtx.Slice) sort.Sort(mapCtx.Slice)
buf := mapCtx.Buf buf := mapCtx.Buf
for _, item := range mapCtx.Slice.Items { for _, item := range mapCtx.Slice.Items {

View File

@ -405,7 +405,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
b = appendStructHead(ctx, b) b = appendStructHead(ctx, b)
mapCtx := encoder.NewMapContext(mlen) mapCtx := encoder.NewMapContext(mlen)
mapiterinit(code.Type, uptr, &mapCtx.Iter) mapiterinit(code.Type, uptr, &mapCtx.Iter)
store(ctxptr, code.MapIter, uintptr(unsafe.Pointer(mapCtx))) store(ctxptr, code.Idx, uintptr(unsafe.Pointer(mapCtx)))
ctx.KeepRefs = append(ctx.KeepRefs, unsafe.Pointer(mapCtx)) ctx.KeepRefs = append(ctx.KeepRefs, unsafe.Pointer(mapCtx))
if (ctx.Option.Flag & encoder.UnorderedMapOption) != 0 { if (ctx.Option.Flag & encoder.UnorderedMapOption) != 0 {
b = appendMapKeyIndent(ctx, code.Next, b) b = appendMapKeyIndent(ctx, code.Next, b)
@ -417,7 +417,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
store(ctxptr, code.Next.Idx, uintptr(key)) store(ctxptr, code.Next.Idx, uintptr(key))
code = code.Next code = code.Next
case encoder.OpMapKey: case encoder.OpMapKey:
mapCtx := (*encoder.MapContext)(ptrToUnsafePtr(load(ctxptr, code.MapIter))) mapCtx := (*encoder.MapContext)(ptrToUnsafePtr(load(ctxptr, code.Idx)))
idx := mapCtx.Idx idx := mapCtx.Idx
idx++ idx++
if (ctx.Option.Flag & encoder.UnorderedMapOption) != 0 { if (ctx.Option.Flag & encoder.UnorderedMapOption) != 0 {
@ -445,7 +445,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
} }
} }
case encoder.OpMapValue: case encoder.OpMapValue:
mapCtx := (*encoder.MapContext)(ptrToUnsafePtr(load(ctxptr, code.MapIter))) mapCtx := (*encoder.MapContext)(ptrToUnsafePtr(load(ctxptr, code.Idx)))
if (ctx.Option.Flag & encoder.UnorderedMapOption) != 0 { if (ctx.Option.Flag & encoder.UnorderedMapOption) != 0 {
b = appendColon(ctx, b) b = appendColon(ctx, b)
} else { } else {
@ -458,7 +458,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
code = code.Next code = code.Next
case encoder.OpMapEnd: case encoder.OpMapEnd:
// this operation only used by sorted map. // this operation only used by sorted map.
mapCtx := (*encoder.MapContext)(ptrToUnsafePtr(load(ctxptr, code.MapIter))) mapCtx := (*encoder.MapContext)(ptrToUnsafePtr(load(ctxptr, code.Idx)))
sort.Sort(mapCtx.Slice) sort.Sort(mapCtx.Slice)
buf := mapCtx.Buf buf := mapCtx.Buf
for _, item := range mapCtx.Slice.Items { for _, item := range mapCtx.Slice.Items {

View File

@ -405,7 +405,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
b = appendStructHead(ctx, b) b = appendStructHead(ctx, b)
mapCtx := encoder.NewMapContext(mlen) mapCtx := encoder.NewMapContext(mlen)
mapiterinit(code.Type, uptr, &mapCtx.Iter) mapiterinit(code.Type, uptr, &mapCtx.Iter)
store(ctxptr, code.MapIter, uintptr(unsafe.Pointer(mapCtx))) store(ctxptr, code.Idx, uintptr(unsafe.Pointer(mapCtx)))
ctx.KeepRefs = append(ctx.KeepRefs, unsafe.Pointer(mapCtx)) ctx.KeepRefs = append(ctx.KeepRefs, unsafe.Pointer(mapCtx))
if (ctx.Option.Flag & encoder.UnorderedMapOption) != 0 { if (ctx.Option.Flag & encoder.UnorderedMapOption) != 0 {
b = appendMapKeyIndent(ctx, code.Next, b) b = appendMapKeyIndent(ctx, code.Next, b)
@ -417,7 +417,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
store(ctxptr, code.Next.Idx, uintptr(key)) store(ctxptr, code.Next.Idx, uintptr(key))
code = code.Next code = code.Next
case encoder.OpMapKey: case encoder.OpMapKey:
mapCtx := (*encoder.MapContext)(ptrToUnsafePtr(load(ctxptr, code.MapIter))) mapCtx := (*encoder.MapContext)(ptrToUnsafePtr(load(ctxptr, code.Idx)))
idx := mapCtx.Idx idx := mapCtx.Idx
idx++ idx++
if (ctx.Option.Flag & encoder.UnorderedMapOption) != 0 { if (ctx.Option.Flag & encoder.UnorderedMapOption) != 0 {
@ -445,7 +445,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
} }
} }
case encoder.OpMapValue: case encoder.OpMapValue:
mapCtx := (*encoder.MapContext)(ptrToUnsafePtr(load(ctxptr, code.MapIter))) mapCtx := (*encoder.MapContext)(ptrToUnsafePtr(load(ctxptr, code.Idx)))
if (ctx.Option.Flag & encoder.UnorderedMapOption) != 0 { if (ctx.Option.Flag & encoder.UnorderedMapOption) != 0 {
b = appendColon(ctx, b) b = appendColon(ctx, b)
} else { } else {
@ -458,7 +458,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
code = code.Next code = code.Next
case encoder.OpMapEnd: case encoder.OpMapEnd:
// this operation only used by sorted map. // this operation only used by sorted map.
mapCtx := (*encoder.MapContext)(ptrToUnsafePtr(load(ctxptr, code.MapIter))) mapCtx := (*encoder.MapContext)(ptrToUnsafePtr(load(ctxptr, code.Idx)))
sort.Sort(mapCtx.Slice) sort.Sort(mapCtx.Slice)
buf := mapCtx.Buf buf := mapCtx.Buf
for _, item := range mapCtx.Slice.Items { for _, item := range mapCtx.Slice.Items {

View File

@ -11,8 +11,8 @@ func TestOpcodeSize(t *testing.T) {
const uintptrSize = 4 << (^uintptr(0) >> 63) const uintptrSize = 4 << (^uintptr(0) >> 63)
if uintptrSize == 8 { if uintptrSize == 8 {
size := unsafe.Sizeof(encoder.Opcode{}) size := unsafe.Sizeof(encoder.Opcode{})
if size != 120 { if size != 112 {
t.Fatalf("unexpected opcode size: expected 120bytes but got %dbytes", size) t.Fatalf("unexpected opcode size: expected 112bytes but got %dbytes", size)
} }
} }
} }