Fix opcode

This commit is contained in:
Masaaki Goshima 2021-03-10 02:12:53 +09:00
parent 37fb74bbb8
commit d0fb2a9a4e
9 changed files with 484 additions and 774 deletions

View File

@ -234,7 +234,7 @@ func (t opType) fieldToStringTagField() opType {
}
primitiveTypes := []string{
"int", "uint", "float32", "float64", "bool", "string", "bytes",
"array", "map", "mapLoad", "slice", "struct", "MarshalJSON", "MarshalText", "recursive",
"array", "map", "slice", "struct", "MarshalJSON", "MarshalText", "recursive",
"intString", "uintString",
"intPtr", "uintPtr", "float32Ptr", "float64Ptr", "boolPtr", "stringPtr", "bytesPtr",
"arrayPtr", "slicePtr", "mapPtr", "marshalJSONPtr", "marshalTextPtr", "interfacePtr",
@ -253,7 +253,6 @@ func (t opType) fieldToStringTagField() opType {
createOpType("SliceEnd", "Op"),
createOpType("ArrayElem", "ArrayElem"),
createOpType("ArrayEnd", "Op"),
createOpType("MapHeadLoad", "MapHead"),
createOpType("MapKey", "MapKey"),
createOpType("MapValue", "MapValue"),
createOpType("MapEnd", "Op"),
@ -334,7 +333,7 @@ func (t opType) fieldToStringTagField() opType {
PtrHeadToHead: func() string { return op },
FieldToEnd: func() string {
switch typ {
case "", "Array", "Map", "MapLoad", "Slice", "Struct", "Recursive":
case "", "Array", "Map", "Slice", "Struct", "Recursive":
return op
}
return fmt.Sprintf(

View File

@ -368,7 +368,12 @@ func appendIndent(ctx *encodeRuntimeContext, b []byte, indent int) []byte {
}
func encodeMarshalJSON(b []byte, v interface{}) ([]byte, error) {
bb, err := v.(Marshaler).MarshalJSON()
v = reflect.ValueOf(v).Interface() // convert by dynamic interface type
marshaler, ok := v.(Marshaler)
if !ok {
return encodeNull(b), nil
}
bb, err := marshaler.MarshalJSON()
if err != nil {
return nil, &MarshalerError{Type: reflect.TypeOf(v), Err: err}
}
@ -387,7 +392,12 @@ func encodeMarshalJSON(b []byte, v interface{}) ([]byte, error) {
}
func encodeMarshalJSONIndent(ctx *encodeRuntimeContext, b []byte, v interface{}, indent int) ([]byte, error) {
bb, err := v.(Marshaler).MarshalJSON()
v = reflect.ValueOf(v).Interface() // convert by dynamic interface type
marshaler, ok := v.(Marshaler)
if !ok {
return encodeNull(b), nil
}
bb, err := marshaler.MarshalJSON()
if err != nil {
return nil, &MarshalerError{Type: reflect.TypeOf(v), Err: err}
}
@ -414,7 +424,12 @@ func encodeMarshalJSONIndent(ctx *encodeRuntimeContext, b []byte, v interface{},
}
func encodeMarshalText(b []byte, v interface{}) ([]byte, error) {
bytes, err := v.(encoding.TextMarshaler).MarshalText()
v = reflect.ValueOf(v).Interface() // convert by dynamic interface type
marshaler, ok := v.(encoding.TextMarshaler)
if !ok {
return encodeNull(b), nil
}
bytes, err := marshaler.MarshalText()
if err != nil {
return nil, &MarshalerError{Type: reflect.TypeOf(v), Err: err}
}
@ -422,7 +437,12 @@ func encodeMarshalText(b []byte, v interface{}) ([]byte, error) {
}
func encodeMarshalTextIndent(b []byte, v interface{}) ([]byte, error) {
bytes, err := v.(encoding.TextMarshaler).MarshalText()
v = reflect.ValueOf(v).Interface() // convert by dynamic interface type
marshaler, ok := v.(encoding.TextMarshaler)
if !ok {
return encodeNull(b), nil
}
bytes, err := marshaler.MarshalText()
if err != nil {
return nil, &MarshalerError{Type: reflect.TypeOf(v), Err: err}
}

View File

@ -72,7 +72,10 @@ func encodeCompileHead(ctx *encodeCompileContext) (*opcode, error) {
isPtr = true
}
if typ.Kind() == reflect.Map {
return encodeCompileMap(ctx.withType(typ), isPtr)
if isPtr {
return encodeCompilePtr(ctx.withType(rtype_ptrTo(typ)))
}
return encodeCompileMap(ctx.withType(typ))
} else if typ.Kind() == reflect.Struct {
code, err := encodeCompileStruct(ctx.withType(typ), isPtr)
if err != nil {
@ -212,7 +215,7 @@ func encodeCompile(ctx *encodeCompileContext, isPtr bool) (*opcode, error) {
case reflect.Array:
return encodeCompileArray(ctx)
case reflect.Map:
return encodeCompileMap(ctx, isPtr)
return encodeCompileMap(ctx)
case reflect.Struct:
return encodeCompileStruct(ctx, isPtr)
case reflect.Interface:
@ -665,12 +668,12 @@ func mapiternext(it unsafe.Pointer)
//go:noescape
func maplen(m unsafe.Pointer) int
func encodeCompileMap(ctx *encodeCompileContext, withLoad bool) (*opcode, error) {
func encodeCompileMap(ctx *encodeCompileContext) (*opcode, error) {
// header => code => value => code => key => code => value => code => end
// ^ |
// |_______________________|
ctx = ctx.incIndent()
header := newMapHeaderCode(ctx, false) //withLoad)
header := newMapHeaderCode(ctx)
ctx.incIndex()
typ := ctx.typ
@ -744,8 +747,6 @@ func encodeTypeToHeaderType(ctx *encodeCompileContext, code *opcode) opType {
case opMapPtr:
code.op = opMap
return opStructFieldHeadMapPtr
case opMapHeadLoad:
return opStructFieldHeadMapLoad
case opArray:
return opStructFieldHeadArray
case opArrayPtr:
@ -799,8 +800,6 @@ func encodeTypeToFieldType(ctx *encodeCompileContext, code *opcode) opType {
case opMapPtr:
code.op = opMap
return opStructFieldMapPtr
case opMapHeadLoad:
return opStructFieldMapLoad
case opArray:
return opStructFieldArray
case opArrayPtr:
@ -874,7 +873,6 @@ func encodeStructHeader(ctx *encodeCompileContext, fieldCode *opcode, valueCode
opStructFieldHeadSlice,
opStructFieldHeadArray,
opStructFieldHeadMap,
opStructFieldHeadMapLoad,
opStructFieldHeadStruct,
opStructFieldHeadOmitEmpty,
opStructFieldHeadOmitEmptySlice,
@ -882,9 +880,7 @@ func encodeStructHeader(ctx *encodeCompileContext, fieldCode *opcode, valueCode
opStructFieldHeadOmitEmptyArray,
opStructFieldHeadStringTagArray,
opStructFieldHeadOmitEmptyMap,
opStructFieldHeadOmitEmptyMapLoad,
opStructFieldHeadStringTagMap,
opStructFieldHeadStringTagMapLoad,
opStructFieldHeadOmitEmptyStruct,
opStructFieldHeadStringTag:
return valueCode.beforeLastCode()
@ -923,7 +919,6 @@ func encodeStructField(ctx *encodeCompileContext, fieldCode *opcode, valueCode *
opStructFieldSlice,
opStructFieldArray,
opStructFieldMap,
opStructFieldMapLoad,
opStructFieldStruct,
opStructFieldOmitEmpty,
opStructFieldOmitEmptySlice,
@ -931,9 +926,7 @@ func encodeStructField(ctx *encodeCompileContext, fieldCode *opcode, valueCode *
opStructFieldOmitEmptyArray,
opStructFieldStringTagArray,
opStructFieldOmitEmptyMap,
opStructFieldOmitEmptyMapLoad,
opStructFieldStringTagMap,
opStructFieldStringTagMapLoad,
opStructFieldOmitEmptyStruct,
opStructFieldStringTag:
return valueCode.beforeLastCode()
@ -1176,8 +1169,11 @@ func encodeCompileStruct(ctx *encodeCompileContext, isPtr bool) (*opcode, error)
ctx.incIndex()
nilcheck := true
var valueCode *opcode
if i == 0 && fieldNum == 1 && isPtr && fieldType.Kind() != reflect.Ptr && rtype_ptrTo(fieldType).Implements(marshalJSONType) && !fieldType.Implements(marshalJSONType) {
// *struct{ field implementedMarshalJSONType } => struct { field *implementedMarshalJSONType }
fmt.Println("fieldType.Kind() = ", fieldType.Kind())
isNilValue := fieldType.Kind() == reflect.Ptr || fieldType.Kind() == reflect.Interface
if i == 0 && fieldNum == 1 && isPtr && !isNilValue && rtype_ptrTo(fieldType).Implements(marshalJSONType) && !fieldType.Implements(marshalJSONType) {
// *struct{ field T } => struct { field *T }
// func (*T) MarshalJSON() ([]byte, error)
// move pointer position from head to first field
code, err := encodeCompileMarshalJSON(ctx.withType(rtype_ptrTo(fieldType)))
if err != nil {
@ -1187,7 +1183,10 @@ func encodeCompileStruct(ctx *encodeCompileContext, isPtr bool) (*opcode, error)
nilcheck = false
indirect = false
disableIndirectConversion = true
} else if i == 0 && fieldNum == 1 && isPtr && fieldType.Kind() != reflect.Ptr && rtype_ptrTo(fieldType).Implements(marshalTextType) && !fieldType.Implements(marshalTextType) {
} else if i == 0 && fieldNum == 1 && isPtr && !isNilValue && rtype_ptrTo(fieldType).Implements(marshalTextType) && !fieldType.Implements(marshalTextType) {
// *struct{ field T } => struct { field *T }
// func (*T) MarshalText() ([]byte, error)
// move pointer position from head to first field
code, err := encodeCompileMarshalText(ctx.withType(rtype_ptrTo(fieldType)))
if err != nil {
return nil, err
@ -1196,14 +1195,18 @@ func encodeCompileStruct(ctx *encodeCompileContext, isPtr bool) (*opcode, error)
nilcheck = false
indirect = false
disableIndirectConversion = true
} else if isPtr && fieldType.Kind() != reflect.Ptr && !fieldType.Implements(marshalJSONType) && rtype_ptrTo(fieldType).Implements(marshalJSONType) {
} else if isPtr && !isNilValue && !fieldType.Implements(marshalJSONType) && rtype_ptrTo(fieldType).Implements(marshalJSONType) {
// *struct{ field T }
// func (*T) MarshalJSON() ([]byte, error)
code, err := encodeCompileMarshalJSON(ctx.withType(rtype_ptrTo(fieldType)))
if err != nil {
return nil, err
}
nilcheck = false
valueCode = code
} else if isPtr && fieldType.Kind() != reflect.Ptr && !fieldType.Implements(marshalTextType) && rtype_ptrTo(fieldType).Implements(marshalTextType) {
} else if isPtr && !isNilValue && !fieldType.Implements(marshalTextType) && rtype_ptrTo(fieldType).Implements(marshalTextType) {
// *struct{ field T }
// func (*T) MarshalText() ([]byte, error)
code, err := encodeCompileMarshalText(ctx.withType(rtype_ptrTo(fieldType)))
if err != nil {
return nil, err

View File

@ -429,13 +429,7 @@ func newArrayElemCode(ctx *encodeCompileContext, head *opcode, length int, size
}
}
func newMapHeaderCode(ctx *encodeCompileContext, withLoad bool) *opcode {
var op opType
if withLoad {
op = opMapHeadLoad
} else {
op = opMap
}
func newMapHeaderCode(ctx *encodeCompileContext) *opcode {
idx := opcodeOffset(ctx.ptrIndex)
ctx.incPtrIndex()
elemIdx := opcodeOffset(ctx.ptrIndex)
@ -444,7 +438,7 @@ func newMapHeaderCode(ctx *encodeCompileContext, withLoad bool) *opcode {
ctx.incPtrIndex()
mapIter := opcodeOffset(ctx.ptrIndex)
return &opcode{
op: op,
op: opMap,
typ: ctx.typ,
displayIdx: ctx.opcodeIndex,
idx: idx,

View File

@ -22,7 +22,7 @@ const (
codeStructEnd codeType = 11
)
var opTypeStrings = [417]string{
var opTypeStrings = [403]string{
"End",
"Interface",
"Ptr",
@ -32,7 +32,6 @@ var opTypeStrings = [417]string{
"SliceEnd",
"ArrayElem",
"ArrayEnd",
"MapHeadLoad",
"MapKey",
"MapValue",
"MapEnd",
@ -47,7 +46,6 @@ var opTypeStrings = [417]string{
"Bytes",
"Array",
"Map",
"MapLoad",
"Slice",
"Struct",
"MarshalJSON",
@ -122,12 +120,6 @@ var opTypeStrings = [417]string{
"StructFieldPtrHeadMap",
"StructFieldPtrHeadOmitEmptyMap",
"StructFieldPtrHeadStringTagMap",
"StructFieldHeadMapLoad",
"StructFieldHeadOmitEmptyMapLoad",
"StructFieldHeadStringTagMapLoad",
"StructFieldPtrHeadMapLoad",
"StructFieldPtrHeadOmitEmptyMapLoad",
"StructFieldPtrHeadStringTagMapLoad",
"StructFieldHeadSlice",
"StructFieldHeadOmitEmptySlice",
"StructFieldHeadStringTagSlice",
@ -281,9 +273,6 @@ var opTypeStrings = [417]string{
"StructFieldMap",
"StructFieldOmitEmptyMap",
"StructFieldStringTagMap",
"StructFieldMapLoad",
"StructFieldOmitEmptyMapLoad",
"StructFieldStringTagMapLoad",
"StructFieldSlice",
"StructFieldOmitEmptySlice",
"StructFieldStringTagSlice",
@ -374,9 +363,6 @@ var opTypeStrings = [417]string{
"StructEndMap",
"StructEndOmitEmptyMap",
"StructEndStringTagMap",
"StructEndMapLoad",
"StructEndOmitEmptyMapLoad",
"StructEndStringTagMapLoad",
"StructEndSlice",
"StructEndOmitEmptySlice",
"StructEndStringTagSlice",
@ -454,418 +440,404 @@ const (
opSliceEnd opType = 6
opArrayElem opType = 7
opArrayEnd opType = 8
opMapHeadLoad opType = 9
opMapKey opType = 10
opMapValue opType = 11
opMapEnd opType = 12
opStructFieldRecursiveEnd opType = 13
opStructAnonymousEnd opType = 14
opInt opType = 15
opUint opType = 16
opFloat32 opType = 17
opFloat64 opType = 18
opBool opType = 19
opString opType = 20
opBytes opType = 21
opArray opType = 22
opMap opType = 23
opMapLoad opType = 24
opSlice opType = 25
opStruct opType = 26
opMarshalJSON opType = 27
opMarshalText opType = 28
opRecursive opType = 29
opIntString opType = 30
opUintString opType = 31
opIntPtr opType = 32
opUintPtr opType = 33
opFloat32Ptr opType = 34
opFloat64Ptr opType = 35
opBoolPtr opType = 36
opStringPtr opType = 37
opBytesPtr opType = 38
opArrayPtr opType = 39
opSlicePtr opType = 40
opMapPtr opType = 41
opMarshalJSONPtr opType = 42
opMarshalTextPtr opType = 43
opInterfacePtr opType = 44
opStructFieldHeadInt opType = 45
opStructFieldHeadOmitEmptyInt opType = 46
opStructFieldHeadStringTagInt opType = 47
opStructFieldPtrHeadInt opType = 48
opStructFieldPtrHeadOmitEmptyInt opType = 49
opStructFieldPtrHeadStringTagInt opType = 50
opStructFieldHeadUint opType = 51
opStructFieldHeadOmitEmptyUint opType = 52
opStructFieldHeadStringTagUint opType = 53
opStructFieldPtrHeadUint opType = 54
opStructFieldPtrHeadOmitEmptyUint opType = 55
opStructFieldPtrHeadStringTagUint opType = 56
opStructFieldHeadFloat32 opType = 57
opStructFieldHeadOmitEmptyFloat32 opType = 58
opStructFieldHeadStringTagFloat32 opType = 59
opStructFieldPtrHeadFloat32 opType = 60
opStructFieldPtrHeadOmitEmptyFloat32 opType = 61
opStructFieldPtrHeadStringTagFloat32 opType = 62
opStructFieldHeadFloat64 opType = 63
opStructFieldHeadOmitEmptyFloat64 opType = 64
opStructFieldHeadStringTagFloat64 opType = 65
opStructFieldPtrHeadFloat64 opType = 66
opStructFieldPtrHeadOmitEmptyFloat64 opType = 67
opStructFieldPtrHeadStringTagFloat64 opType = 68
opStructFieldHeadBool opType = 69
opStructFieldHeadOmitEmptyBool opType = 70
opStructFieldHeadStringTagBool opType = 71
opStructFieldPtrHeadBool opType = 72
opStructFieldPtrHeadOmitEmptyBool opType = 73
opStructFieldPtrHeadStringTagBool opType = 74
opStructFieldHeadString opType = 75
opStructFieldHeadOmitEmptyString opType = 76
opStructFieldHeadStringTagString opType = 77
opStructFieldPtrHeadString opType = 78
opStructFieldPtrHeadOmitEmptyString opType = 79
opStructFieldPtrHeadStringTagString opType = 80
opStructFieldHeadBytes opType = 81
opStructFieldHeadOmitEmptyBytes opType = 82
opStructFieldHeadStringTagBytes opType = 83
opStructFieldPtrHeadBytes opType = 84
opStructFieldPtrHeadOmitEmptyBytes opType = 85
opStructFieldPtrHeadStringTagBytes opType = 86
opStructFieldHeadArray opType = 87
opStructFieldHeadOmitEmptyArray opType = 88
opStructFieldHeadStringTagArray opType = 89
opStructFieldPtrHeadArray opType = 90
opStructFieldPtrHeadOmitEmptyArray opType = 91
opStructFieldPtrHeadStringTagArray opType = 92
opStructFieldHeadMap opType = 93
opStructFieldHeadOmitEmptyMap opType = 94
opStructFieldHeadStringTagMap opType = 95
opStructFieldPtrHeadMap opType = 96
opStructFieldPtrHeadOmitEmptyMap opType = 97
opStructFieldPtrHeadStringTagMap opType = 98
opStructFieldHeadMapLoad opType = 99
opStructFieldHeadOmitEmptyMapLoad opType = 100
opStructFieldHeadStringTagMapLoad opType = 101
opStructFieldPtrHeadMapLoad opType = 102
opStructFieldPtrHeadOmitEmptyMapLoad opType = 103
opStructFieldPtrHeadStringTagMapLoad opType = 104
opStructFieldHeadSlice opType = 105
opStructFieldHeadOmitEmptySlice opType = 106
opStructFieldHeadStringTagSlice opType = 107
opStructFieldPtrHeadSlice opType = 108
opStructFieldPtrHeadOmitEmptySlice opType = 109
opStructFieldPtrHeadStringTagSlice opType = 110
opStructFieldHeadStruct opType = 111
opStructFieldHeadOmitEmptyStruct opType = 112
opStructFieldHeadStringTagStruct opType = 113
opStructFieldPtrHeadStruct opType = 114
opStructFieldPtrHeadOmitEmptyStruct opType = 115
opStructFieldPtrHeadStringTagStruct opType = 116
opStructFieldHeadMarshalJSON opType = 117
opStructFieldHeadOmitEmptyMarshalJSON opType = 118
opStructFieldHeadStringTagMarshalJSON opType = 119
opStructFieldPtrHeadMarshalJSON opType = 120
opStructFieldPtrHeadOmitEmptyMarshalJSON opType = 121
opStructFieldPtrHeadStringTagMarshalJSON opType = 122
opStructFieldHeadMarshalText opType = 123
opStructFieldHeadOmitEmptyMarshalText opType = 124
opStructFieldHeadStringTagMarshalText opType = 125
opStructFieldPtrHeadMarshalText opType = 126
opStructFieldPtrHeadOmitEmptyMarshalText opType = 127
opStructFieldPtrHeadStringTagMarshalText opType = 128
opStructFieldHeadRecursive opType = 129
opStructFieldHeadOmitEmptyRecursive opType = 130
opStructFieldHeadStringTagRecursive opType = 131
opStructFieldPtrHeadRecursive opType = 132
opStructFieldPtrHeadOmitEmptyRecursive opType = 133
opStructFieldPtrHeadStringTagRecursive opType = 134
opStructFieldHeadIntString opType = 135
opStructFieldHeadOmitEmptyIntString opType = 136
opStructFieldHeadStringTagIntString opType = 137
opStructFieldPtrHeadIntString opType = 138
opStructFieldPtrHeadOmitEmptyIntString opType = 139
opStructFieldPtrHeadStringTagIntString opType = 140
opStructFieldHeadUintString opType = 141
opStructFieldHeadOmitEmptyUintString opType = 142
opStructFieldHeadStringTagUintString opType = 143
opStructFieldPtrHeadUintString opType = 144
opStructFieldPtrHeadOmitEmptyUintString opType = 145
opStructFieldPtrHeadStringTagUintString opType = 146
opStructFieldHeadIntPtr opType = 147
opStructFieldHeadOmitEmptyIntPtr opType = 148
opStructFieldHeadStringTagIntPtr opType = 149
opStructFieldPtrHeadIntPtr opType = 150
opStructFieldPtrHeadOmitEmptyIntPtr opType = 151
opStructFieldPtrHeadStringTagIntPtr opType = 152
opStructFieldHeadUintPtr opType = 153
opStructFieldHeadOmitEmptyUintPtr opType = 154
opStructFieldHeadStringTagUintPtr opType = 155
opStructFieldPtrHeadUintPtr opType = 156
opStructFieldPtrHeadOmitEmptyUintPtr opType = 157
opStructFieldPtrHeadStringTagUintPtr opType = 158
opStructFieldHeadFloat32Ptr opType = 159
opStructFieldHeadOmitEmptyFloat32Ptr opType = 160
opStructFieldHeadStringTagFloat32Ptr opType = 161
opStructFieldPtrHeadFloat32Ptr opType = 162
opStructFieldPtrHeadOmitEmptyFloat32Ptr opType = 163
opStructFieldPtrHeadStringTagFloat32Ptr opType = 164
opStructFieldHeadFloat64Ptr opType = 165
opStructFieldHeadOmitEmptyFloat64Ptr opType = 166
opStructFieldHeadStringTagFloat64Ptr opType = 167
opStructFieldPtrHeadFloat64Ptr opType = 168
opStructFieldPtrHeadOmitEmptyFloat64Ptr opType = 169
opStructFieldPtrHeadStringTagFloat64Ptr opType = 170
opStructFieldHeadBoolPtr opType = 171
opStructFieldHeadOmitEmptyBoolPtr opType = 172
opStructFieldHeadStringTagBoolPtr opType = 173
opStructFieldPtrHeadBoolPtr opType = 174
opStructFieldPtrHeadOmitEmptyBoolPtr opType = 175
opStructFieldPtrHeadStringTagBoolPtr opType = 176
opStructFieldHeadStringPtr opType = 177
opStructFieldHeadOmitEmptyStringPtr opType = 178
opStructFieldHeadStringTagStringPtr opType = 179
opStructFieldPtrHeadStringPtr opType = 180
opStructFieldPtrHeadOmitEmptyStringPtr opType = 181
opStructFieldPtrHeadStringTagStringPtr opType = 182
opStructFieldHeadBytesPtr opType = 183
opStructFieldHeadOmitEmptyBytesPtr opType = 184
opStructFieldHeadStringTagBytesPtr opType = 185
opStructFieldPtrHeadBytesPtr opType = 186
opStructFieldPtrHeadOmitEmptyBytesPtr opType = 187
opStructFieldPtrHeadStringTagBytesPtr opType = 188
opStructFieldHeadArrayPtr opType = 189
opStructFieldHeadOmitEmptyArrayPtr opType = 190
opStructFieldHeadStringTagArrayPtr opType = 191
opStructFieldPtrHeadArrayPtr opType = 192
opStructFieldPtrHeadOmitEmptyArrayPtr opType = 193
opStructFieldPtrHeadStringTagArrayPtr opType = 194
opStructFieldHeadSlicePtr opType = 195
opStructFieldHeadOmitEmptySlicePtr opType = 196
opStructFieldHeadStringTagSlicePtr opType = 197
opStructFieldPtrHeadSlicePtr opType = 198
opStructFieldPtrHeadOmitEmptySlicePtr opType = 199
opStructFieldPtrHeadStringTagSlicePtr opType = 200
opStructFieldHeadMapPtr opType = 201
opStructFieldHeadOmitEmptyMapPtr opType = 202
opStructFieldHeadStringTagMapPtr opType = 203
opStructFieldPtrHeadMapPtr opType = 204
opStructFieldPtrHeadOmitEmptyMapPtr opType = 205
opStructFieldPtrHeadStringTagMapPtr opType = 206
opStructFieldHeadMarshalJSONPtr opType = 207
opStructFieldHeadOmitEmptyMarshalJSONPtr opType = 208
opStructFieldHeadStringTagMarshalJSONPtr opType = 209
opStructFieldPtrHeadMarshalJSONPtr opType = 210
opStructFieldPtrHeadOmitEmptyMarshalJSONPtr opType = 211
opStructFieldPtrHeadStringTagMarshalJSONPtr opType = 212
opStructFieldHeadMarshalTextPtr opType = 213
opStructFieldHeadOmitEmptyMarshalTextPtr opType = 214
opStructFieldHeadStringTagMarshalTextPtr opType = 215
opStructFieldPtrHeadMarshalTextPtr opType = 216
opStructFieldPtrHeadOmitEmptyMarshalTextPtr opType = 217
opStructFieldPtrHeadStringTagMarshalTextPtr opType = 218
opStructFieldHeadInterfacePtr opType = 219
opStructFieldHeadOmitEmptyInterfacePtr opType = 220
opStructFieldHeadStringTagInterfacePtr opType = 221
opStructFieldPtrHeadInterfacePtr opType = 222
opStructFieldPtrHeadOmitEmptyInterfacePtr opType = 223
opStructFieldPtrHeadStringTagInterfacePtr opType = 224
opStructFieldHead opType = 225
opStructFieldHeadOmitEmpty opType = 226
opStructFieldHeadStringTag opType = 227
opStructFieldPtrHead opType = 228
opStructFieldPtrHeadOmitEmpty opType = 229
opStructFieldPtrHeadStringTag opType = 230
opStructFieldInt opType = 231
opStructFieldOmitEmptyInt opType = 232
opStructFieldStringTagInt opType = 233
opStructFieldUint opType = 234
opStructFieldOmitEmptyUint opType = 235
opStructFieldStringTagUint opType = 236
opStructFieldFloat32 opType = 237
opStructFieldOmitEmptyFloat32 opType = 238
opStructFieldStringTagFloat32 opType = 239
opStructFieldFloat64 opType = 240
opStructFieldOmitEmptyFloat64 opType = 241
opStructFieldStringTagFloat64 opType = 242
opStructFieldBool opType = 243
opStructFieldOmitEmptyBool opType = 244
opStructFieldStringTagBool opType = 245
opStructFieldString opType = 246
opStructFieldOmitEmptyString opType = 247
opStructFieldStringTagString opType = 248
opStructFieldBytes opType = 249
opStructFieldOmitEmptyBytes opType = 250
opStructFieldStringTagBytes opType = 251
opStructFieldArray opType = 252
opStructFieldOmitEmptyArray opType = 253
opStructFieldStringTagArray opType = 254
opStructFieldMap opType = 255
opStructFieldOmitEmptyMap opType = 256
opStructFieldStringTagMap opType = 257
opStructFieldMapLoad opType = 258
opStructFieldOmitEmptyMapLoad opType = 259
opStructFieldStringTagMapLoad opType = 260
opStructFieldSlice opType = 261
opStructFieldOmitEmptySlice opType = 262
opStructFieldStringTagSlice opType = 263
opStructFieldStruct opType = 264
opStructFieldOmitEmptyStruct opType = 265
opStructFieldStringTagStruct opType = 266
opStructFieldMarshalJSON opType = 267
opStructFieldOmitEmptyMarshalJSON opType = 268
opStructFieldStringTagMarshalJSON opType = 269
opStructFieldMarshalText opType = 270
opStructFieldOmitEmptyMarshalText opType = 271
opStructFieldStringTagMarshalText opType = 272
opStructFieldRecursive opType = 273
opStructFieldOmitEmptyRecursive opType = 274
opStructFieldStringTagRecursive opType = 275
opStructFieldIntString opType = 276
opStructFieldOmitEmptyIntString opType = 277
opStructFieldStringTagIntString opType = 278
opStructFieldUintString opType = 279
opStructFieldOmitEmptyUintString opType = 280
opStructFieldStringTagUintString opType = 281
opStructFieldIntPtr opType = 282
opStructFieldOmitEmptyIntPtr opType = 283
opStructFieldStringTagIntPtr opType = 284
opStructFieldUintPtr opType = 285
opStructFieldOmitEmptyUintPtr opType = 286
opStructFieldStringTagUintPtr opType = 287
opStructFieldFloat32Ptr opType = 288
opStructFieldOmitEmptyFloat32Ptr opType = 289
opStructFieldStringTagFloat32Ptr opType = 290
opStructFieldFloat64Ptr opType = 291
opStructFieldOmitEmptyFloat64Ptr opType = 292
opStructFieldStringTagFloat64Ptr opType = 293
opStructFieldBoolPtr opType = 294
opStructFieldOmitEmptyBoolPtr opType = 295
opStructFieldStringTagBoolPtr opType = 296
opStructFieldStringPtr opType = 297
opStructFieldOmitEmptyStringPtr opType = 298
opStructFieldStringTagStringPtr opType = 299
opStructFieldBytesPtr opType = 300
opStructFieldOmitEmptyBytesPtr opType = 301
opStructFieldStringTagBytesPtr opType = 302
opStructFieldArrayPtr opType = 303
opStructFieldOmitEmptyArrayPtr opType = 304
opStructFieldStringTagArrayPtr opType = 305
opStructFieldSlicePtr opType = 306
opStructFieldOmitEmptySlicePtr opType = 307
opStructFieldStringTagSlicePtr opType = 308
opStructFieldMapPtr opType = 309
opStructFieldOmitEmptyMapPtr opType = 310
opStructFieldStringTagMapPtr opType = 311
opStructFieldMarshalJSONPtr opType = 312
opStructFieldOmitEmptyMarshalJSONPtr opType = 313
opStructFieldStringTagMarshalJSONPtr opType = 314
opStructFieldMarshalTextPtr opType = 315
opStructFieldOmitEmptyMarshalTextPtr opType = 316
opStructFieldStringTagMarshalTextPtr opType = 317
opStructFieldInterfacePtr opType = 318
opStructFieldOmitEmptyInterfacePtr opType = 319
opStructFieldStringTagInterfacePtr opType = 320
opStructField opType = 321
opStructFieldOmitEmpty opType = 322
opStructFieldStringTag opType = 323
opStructEndInt opType = 324
opStructEndOmitEmptyInt opType = 325
opStructEndStringTagInt opType = 326
opStructEndUint opType = 327
opStructEndOmitEmptyUint opType = 328
opStructEndStringTagUint opType = 329
opStructEndFloat32 opType = 330
opStructEndOmitEmptyFloat32 opType = 331
opStructEndStringTagFloat32 opType = 332
opStructEndFloat64 opType = 333
opStructEndOmitEmptyFloat64 opType = 334
opStructEndStringTagFloat64 opType = 335
opStructEndBool opType = 336
opStructEndOmitEmptyBool opType = 337
opStructEndStringTagBool opType = 338
opStructEndString opType = 339
opStructEndOmitEmptyString opType = 340
opStructEndStringTagString opType = 341
opStructEndBytes opType = 342
opStructEndOmitEmptyBytes opType = 343
opStructEndStringTagBytes opType = 344
opStructEndArray opType = 345
opStructEndOmitEmptyArray opType = 346
opStructEndStringTagArray opType = 347
opStructEndMap opType = 348
opStructEndOmitEmptyMap opType = 349
opStructEndStringTagMap opType = 350
opStructEndMapLoad opType = 351
opStructEndOmitEmptyMapLoad opType = 352
opStructEndStringTagMapLoad opType = 353
opStructEndSlice opType = 354
opStructEndOmitEmptySlice opType = 355
opStructEndStringTagSlice opType = 356
opStructEndStruct opType = 357
opStructEndOmitEmptyStruct opType = 358
opStructEndStringTagStruct opType = 359
opStructEndMarshalJSON opType = 360
opStructEndOmitEmptyMarshalJSON opType = 361
opStructEndStringTagMarshalJSON opType = 362
opStructEndMarshalText opType = 363
opStructEndOmitEmptyMarshalText opType = 364
opStructEndStringTagMarshalText opType = 365
opStructEndRecursive opType = 366
opStructEndOmitEmptyRecursive opType = 367
opStructEndStringTagRecursive opType = 368
opStructEndIntString opType = 369
opStructEndOmitEmptyIntString opType = 370
opStructEndStringTagIntString opType = 371
opStructEndUintString opType = 372
opStructEndOmitEmptyUintString opType = 373
opStructEndStringTagUintString opType = 374
opStructEndIntPtr opType = 375
opStructEndOmitEmptyIntPtr opType = 376
opStructEndStringTagIntPtr opType = 377
opStructEndUintPtr opType = 378
opStructEndOmitEmptyUintPtr opType = 379
opStructEndStringTagUintPtr opType = 380
opStructEndFloat32Ptr opType = 381
opStructEndOmitEmptyFloat32Ptr opType = 382
opStructEndStringTagFloat32Ptr opType = 383
opStructEndFloat64Ptr opType = 384
opStructEndOmitEmptyFloat64Ptr opType = 385
opStructEndStringTagFloat64Ptr opType = 386
opStructEndBoolPtr opType = 387
opStructEndOmitEmptyBoolPtr opType = 388
opStructEndStringTagBoolPtr opType = 389
opStructEndStringPtr opType = 390
opStructEndOmitEmptyStringPtr opType = 391
opStructEndStringTagStringPtr opType = 392
opStructEndBytesPtr opType = 393
opStructEndOmitEmptyBytesPtr opType = 394
opStructEndStringTagBytesPtr opType = 395
opStructEndArrayPtr opType = 396
opStructEndOmitEmptyArrayPtr opType = 397
opStructEndStringTagArrayPtr opType = 398
opStructEndSlicePtr opType = 399
opStructEndOmitEmptySlicePtr opType = 400
opStructEndStringTagSlicePtr opType = 401
opStructEndMapPtr opType = 402
opStructEndOmitEmptyMapPtr opType = 403
opStructEndStringTagMapPtr opType = 404
opStructEndMarshalJSONPtr opType = 405
opStructEndOmitEmptyMarshalJSONPtr opType = 406
opStructEndStringTagMarshalJSONPtr opType = 407
opStructEndMarshalTextPtr opType = 408
opStructEndOmitEmptyMarshalTextPtr opType = 409
opStructEndStringTagMarshalTextPtr opType = 410
opStructEndInterfacePtr opType = 411
opStructEndOmitEmptyInterfacePtr opType = 412
opStructEndStringTagInterfacePtr opType = 413
opStructEnd opType = 414
opStructEndOmitEmpty opType = 415
opStructEndStringTag opType = 416
opMapKey opType = 9
opMapValue opType = 10
opMapEnd opType = 11
opStructFieldRecursiveEnd opType = 12
opStructAnonymousEnd opType = 13
opInt opType = 14
opUint opType = 15
opFloat32 opType = 16
opFloat64 opType = 17
opBool opType = 18
opString opType = 19
opBytes opType = 20
opArray opType = 21
opMap opType = 22
opSlice opType = 23
opStruct opType = 24
opMarshalJSON opType = 25
opMarshalText opType = 26
opRecursive opType = 27
opIntString opType = 28
opUintString opType = 29
opIntPtr opType = 30
opUintPtr opType = 31
opFloat32Ptr opType = 32
opFloat64Ptr opType = 33
opBoolPtr opType = 34
opStringPtr opType = 35
opBytesPtr opType = 36
opArrayPtr opType = 37
opSlicePtr opType = 38
opMapPtr opType = 39
opMarshalJSONPtr opType = 40
opMarshalTextPtr opType = 41
opInterfacePtr opType = 42
opStructFieldHeadInt opType = 43
opStructFieldHeadOmitEmptyInt opType = 44
opStructFieldHeadStringTagInt opType = 45
opStructFieldPtrHeadInt opType = 46
opStructFieldPtrHeadOmitEmptyInt opType = 47
opStructFieldPtrHeadStringTagInt opType = 48
opStructFieldHeadUint opType = 49
opStructFieldHeadOmitEmptyUint opType = 50
opStructFieldHeadStringTagUint opType = 51
opStructFieldPtrHeadUint opType = 52
opStructFieldPtrHeadOmitEmptyUint opType = 53
opStructFieldPtrHeadStringTagUint opType = 54
opStructFieldHeadFloat32 opType = 55
opStructFieldHeadOmitEmptyFloat32 opType = 56
opStructFieldHeadStringTagFloat32 opType = 57
opStructFieldPtrHeadFloat32 opType = 58
opStructFieldPtrHeadOmitEmptyFloat32 opType = 59
opStructFieldPtrHeadStringTagFloat32 opType = 60
opStructFieldHeadFloat64 opType = 61
opStructFieldHeadOmitEmptyFloat64 opType = 62
opStructFieldHeadStringTagFloat64 opType = 63
opStructFieldPtrHeadFloat64 opType = 64
opStructFieldPtrHeadOmitEmptyFloat64 opType = 65
opStructFieldPtrHeadStringTagFloat64 opType = 66
opStructFieldHeadBool opType = 67
opStructFieldHeadOmitEmptyBool opType = 68
opStructFieldHeadStringTagBool opType = 69
opStructFieldPtrHeadBool opType = 70
opStructFieldPtrHeadOmitEmptyBool opType = 71
opStructFieldPtrHeadStringTagBool opType = 72
opStructFieldHeadString opType = 73
opStructFieldHeadOmitEmptyString opType = 74
opStructFieldHeadStringTagString opType = 75
opStructFieldPtrHeadString opType = 76
opStructFieldPtrHeadOmitEmptyString opType = 77
opStructFieldPtrHeadStringTagString opType = 78
opStructFieldHeadBytes opType = 79
opStructFieldHeadOmitEmptyBytes opType = 80
opStructFieldHeadStringTagBytes opType = 81
opStructFieldPtrHeadBytes opType = 82
opStructFieldPtrHeadOmitEmptyBytes opType = 83
opStructFieldPtrHeadStringTagBytes opType = 84
opStructFieldHeadArray opType = 85
opStructFieldHeadOmitEmptyArray opType = 86
opStructFieldHeadStringTagArray opType = 87
opStructFieldPtrHeadArray opType = 88
opStructFieldPtrHeadOmitEmptyArray opType = 89
opStructFieldPtrHeadStringTagArray opType = 90
opStructFieldHeadMap opType = 91
opStructFieldHeadOmitEmptyMap opType = 92
opStructFieldHeadStringTagMap opType = 93
opStructFieldPtrHeadMap opType = 94
opStructFieldPtrHeadOmitEmptyMap opType = 95
opStructFieldPtrHeadStringTagMap opType = 96
opStructFieldHeadSlice opType = 97
opStructFieldHeadOmitEmptySlice opType = 98
opStructFieldHeadStringTagSlice opType = 99
opStructFieldPtrHeadSlice opType = 100
opStructFieldPtrHeadOmitEmptySlice opType = 101
opStructFieldPtrHeadStringTagSlice opType = 102
opStructFieldHeadStruct opType = 103
opStructFieldHeadOmitEmptyStruct opType = 104
opStructFieldHeadStringTagStruct opType = 105
opStructFieldPtrHeadStruct opType = 106
opStructFieldPtrHeadOmitEmptyStruct opType = 107
opStructFieldPtrHeadStringTagStruct opType = 108
opStructFieldHeadMarshalJSON opType = 109
opStructFieldHeadOmitEmptyMarshalJSON opType = 110
opStructFieldHeadStringTagMarshalJSON opType = 111
opStructFieldPtrHeadMarshalJSON opType = 112
opStructFieldPtrHeadOmitEmptyMarshalJSON opType = 113
opStructFieldPtrHeadStringTagMarshalJSON opType = 114
opStructFieldHeadMarshalText opType = 115
opStructFieldHeadOmitEmptyMarshalText opType = 116
opStructFieldHeadStringTagMarshalText opType = 117
opStructFieldPtrHeadMarshalText opType = 118
opStructFieldPtrHeadOmitEmptyMarshalText opType = 119
opStructFieldPtrHeadStringTagMarshalText opType = 120
opStructFieldHeadRecursive opType = 121
opStructFieldHeadOmitEmptyRecursive opType = 122
opStructFieldHeadStringTagRecursive opType = 123
opStructFieldPtrHeadRecursive opType = 124
opStructFieldPtrHeadOmitEmptyRecursive opType = 125
opStructFieldPtrHeadStringTagRecursive opType = 126
opStructFieldHeadIntString opType = 127
opStructFieldHeadOmitEmptyIntString opType = 128
opStructFieldHeadStringTagIntString opType = 129
opStructFieldPtrHeadIntString opType = 130
opStructFieldPtrHeadOmitEmptyIntString opType = 131
opStructFieldPtrHeadStringTagIntString opType = 132
opStructFieldHeadUintString opType = 133
opStructFieldHeadOmitEmptyUintString opType = 134
opStructFieldHeadStringTagUintString opType = 135
opStructFieldPtrHeadUintString opType = 136
opStructFieldPtrHeadOmitEmptyUintString opType = 137
opStructFieldPtrHeadStringTagUintString opType = 138
opStructFieldHeadIntPtr opType = 139
opStructFieldHeadOmitEmptyIntPtr opType = 140
opStructFieldHeadStringTagIntPtr opType = 141
opStructFieldPtrHeadIntPtr opType = 142
opStructFieldPtrHeadOmitEmptyIntPtr opType = 143
opStructFieldPtrHeadStringTagIntPtr opType = 144
opStructFieldHeadUintPtr opType = 145
opStructFieldHeadOmitEmptyUintPtr opType = 146
opStructFieldHeadStringTagUintPtr opType = 147
opStructFieldPtrHeadUintPtr opType = 148
opStructFieldPtrHeadOmitEmptyUintPtr opType = 149
opStructFieldPtrHeadStringTagUintPtr opType = 150
opStructFieldHeadFloat32Ptr opType = 151
opStructFieldHeadOmitEmptyFloat32Ptr opType = 152
opStructFieldHeadStringTagFloat32Ptr opType = 153
opStructFieldPtrHeadFloat32Ptr opType = 154
opStructFieldPtrHeadOmitEmptyFloat32Ptr opType = 155
opStructFieldPtrHeadStringTagFloat32Ptr opType = 156
opStructFieldHeadFloat64Ptr opType = 157
opStructFieldHeadOmitEmptyFloat64Ptr opType = 158
opStructFieldHeadStringTagFloat64Ptr opType = 159
opStructFieldPtrHeadFloat64Ptr opType = 160
opStructFieldPtrHeadOmitEmptyFloat64Ptr opType = 161
opStructFieldPtrHeadStringTagFloat64Ptr opType = 162
opStructFieldHeadBoolPtr opType = 163
opStructFieldHeadOmitEmptyBoolPtr opType = 164
opStructFieldHeadStringTagBoolPtr opType = 165
opStructFieldPtrHeadBoolPtr opType = 166
opStructFieldPtrHeadOmitEmptyBoolPtr opType = 167
opStructFieldPtrHeadStringTagBoolPtr opType = 168
opStructFieldHeadStringPtr opType = 169
opStructFieldHeadOmitEmptyStringPtr opType = 170
opStructFieldHeadStringTagStringPtr opType = 171
opStructFieldPtrHeadStringPtr opType = 172
opStructFieldPtrHeadOmitEmptyStringPtr opType = 173
opStructFieldPtrHeadStringTagStringPtr opType = 174
opStructFieldHeadBytesPtr opType = 175
opStructFieldHeadOmitEmptyBytesPtr opType = 176
opStructFieldHeadStringTagBytesPtr opType = 177
opStructFieldPtrHeadBytesPtr opType = 178
opStructFieldPtrHeadOmitEmptyBytesPtr opType = 179
opStructFieldPtrHeadStringTagBytesPtr opType = 180
opStructFieldHeadArrayPtr opType = 181
opStructFieldHeadOmitEmptyArrayPtr opType = 182
opStructFieldHeadStringTagArrayPtr opType = 183
opStructFieldPtrHeadArrayPtr opType = 184
opStructFieldPtrHeadOmitEmptyArrayPtr opType = 185
opStructFieldPtrHeadStringTagArrayPtr opType = 186
opStructFieldHeadSlicePtr opType = 187
opStructFieldHeadOmitEmptySlicePtr opType = 188
opStructFieldHeadStringTagSlicePtr opType = 189
opStructFieldPtrHeadSlicePtr opType = 190
opStructFieldPtrHeadOmitEmptySlicePtr opType = 191
opStructFieldPtrHeadStringTagSlicePtr opType = 192
opStructFieldHeadMapPtr opType = 193
opStructFieldHeadOmitEmptyMapPtr opType = 194
opStructFieldHeadStringTagMapPtr opType = 195
opStructFieldPtrHeadMapPtr opType = 196
opStructFieldPtrHeadOmitEmptyMapPtr opType = 197
opStructFieldPtrHeadStringTagMapPtr opType = 198
opStructFieldHeadMarshalJSONPtr opType = 199
opStructFieldHeadOmitEmptyMarshalJSONPtr opType = 200
opStructFieldHeadStringTagMarshalJSONPtr opType = 201
opStructFieldPtrHeadMarshalJSONPtr opType = 202
opStructFieldPtrHeadOmitEmptyMarshalJSONPtr opType = 203
opStructFieldPtrHeadStringTagMarshalJSONPtr opType = 204
opStructFieldHeadMarshalTextPtr opType = 205
opStructFieldHeadOmitEmptyMarshalTextPtr opType = 206
opStructFieldHeadStringTagMarshalTextPtr opType = 207
opStructFieldPtrHeadMarshalTextPtr opType = 208
opStructFieldPtrHeadOmitEmptyMarshalTextPtr opType = 209
opStructFieldPtrHeadStringTagMarshalTextPtr opType = 210
opStructFieldHeadInterfacePtr opType = 211
opStructFieldHeadOmitEmptyInterfacePtr opType = 212
opStructFieldHeadStringTagInterfacePtr opType = 213
opStructFieldPtrHeadInterfacePtr opType = 214
opStructFieldPtrHeadOmitEmptyInterfacePtr opType = 215
opStructFieldPtrHeadStringTagInterfacePtr opType = 216
opStructFieldHead opType = 217
opStructFieldHeadOmitEmpty opType = 218
opStructFieldHeadStringTag opType = 219
opStructFieldPtrHead opType = 220
opStructFieldPtrHeadOmitEmpty opType = 221
opStructFieldPtrHeadStringTag opType = 222
opStructFieldInt opType = 223
opStructFieldOmitEmptyInt opType = 224
opStructFieldStringTagInt opType = 225
opStructFieldUint opType = 226
opStructFieldOmitEmptyUint opType = 227
opStructFieldStringTagUint opType = 228
opStructFieldFloat32 opType = 229
opStructFieldOmitEmptyFloat32 opType = 230
opStructFieldStringTagFloat32 opType = 231
opStructFieldFloat64 opType = 232
opStructFieldOmitEmptyFloat64 opType = 233
opStructFieldStringTagFloat64 opType = 234
opStructFieldBool opType = 235
opStructFieldOmitEmptyBool opType = 236
opStructFieldStringTagBool opType = 237
opStructFieldString opType = 238
opStructFieldOmitEmptyString opType = 239
opStructFieldStringTagString opType = 240
opStructFieldBytes opType = 241
opStructFieldOmitEmptyBytes opType = 242
opStructFieldStringTagBytes opType = 243
opStructFieldArray opType = 244
opStructFieldOmitEmptyArray opType = 245
opStructFieldStringTagArray opType = 246
opStructFieldMap opType = 247
opStructFieldOmitEmptyMap opType = 248
opStructFieldStringTagMap opType = 249
opStructFieldSlice opType = 250
opStructFieldOmitEmptySlice opType = 251
opStructFieldStringTagSlice opType = 252
opStructFieldStruct opType = 253
opStructFieldOmitEmptyStruct opType = 254
opStructFieldStringTagStruct opType = 255
opStructFieldMarshalJSON opType = 256
opStructFieldOmitEmptyMarshalJSON opType = 257
opStructFieldStringTagMarshalJSON opType = 258
opStructFieldMarshalText opType = 259
opStructFieldOmitEmptyMarshalText opType = 260
opStructFieldStringTagMarshalText opType = 261
opStructFieldRecursive opType = 262
opStructFieldOmitEmptyRecursive opType = 263
opStructFieldStringTagRecursive opType = 264
opStructFieldIntString opType = 265
opStructFieldOmitEmptyIntString opType = 266
opStructFieldStringTagIntString opType = 267
opStructFieldUintString opType = 268
opStructFieldOmitEmptyUintString opType = 269
opStructFieldStringTagUintString opType = 270
opStructFieldIntPtr opType = 271
opStructFieldOmitEmptyIntPtr opType = 272
opStructFieldStringTagIntPtr opType = 273
opStructFieldUintPtr opType = 274
opStructFieldOmitEmptyUintPtr opType = 275
opStructFieldStringTagUintPtr opType = 276
opStructFieldFloat32Ptr opType = 277
opStructFieldOmitEmptyFloat32Ptr opType = 278
opStructFieldStringTagFloat32Ptr opType = 279
opStructFieldFloat64Ptr opType = 280
opStructFieldOmitEmptyFloat64Ptr opType = 281
opStructFieldStringTagFloat64Ptr opType = 282
opStructFieldBoolPtr opType = 283
opStructFieldOmitEmptyBoolPtr opType = 284
opStructFieldStringTagBoolPtr opType = 285
opStructFieldStringPtr opType = 286
opStructFieldOmitEmptyStringPtr opType = 287
opStructFieldStringTagStringPtr opType = 288
opStructFieldBytesPtr opType = 289
opStructFieldOmitEmptyBytesPtr opType = 290
opStructFieldStringTagBytesPtr opType = 291
opStructFieldArrayPtr opType = 292
opStructFieldOmitEmptyArrayPtr opType = 293
opStructFieldStringTagArrayPtr opType = 294
opStructFieldSlicePtr opType = 295
opStructFieldOmitEmptySlicePtr opType = 296
opStructFieldStringTagSlicePtr opType = 297
opStructFieldMapPtr opType = 298
opStructFieldOmitEmptyMapPtr opType = 299
opStructFieldStringTagMapPtr opType = 300
opStructFieldMarshalJSONPtr opType = 301
opStructFieldOmitEmptyMarshalJSONPtr opType = 302
opStructFieldStringTagMarshalJSONPtr opType = 303
opStructFieldMarshalTextPtr opType = 304
opStructFieldOmitEmptyMarshalTextPtr opType = 305
opStructFieldStringTagMarshalTextPtr opType = 306
opStructFieldInterfacePtr opType = 307
opStructFieldOmitEmptyInterfacePtr opType = 308
opStructFieldStringTagInterfacePtr opType = 309
opStructField opType = 310
opStructFieldOmitEmpty opType = 311
opStructFieldStringTag opType = 312
opStructEndInt opType = 313
opStructEndOmitEmptyInt opType = 314
opStructEndStringTagInt opType = 315
opStructEndUint opType = 316
opStructEndOmitEmptyUint opType = 317
opStructEndStringTagUint opType = 318
opStructEndFloat32 opType = 319
opStructEndOmitEmptyFloat32 opType = 320
opStructEndStringTagFloat32 opType = 321
opStructEndFloat64 opType = 322
opStructEndOmitEmptyFloat64 opType = 323
opStructEndStringTagFloat64 opType = 324
opStructEndBool opType = 325
opStructEndOmitEmptyBool opType = 326
opStructEndStringTagBool opType = 327
opStructEndString opType = 328
opStructEndOmitEmptyString opType = 329
opStructEndStringTagString opType = 330
opStructEndBytes opType = 331
opStructEndOmitEmptyBytes opType = 332
opStructEndStringTagBytes opType = 333
opStructEndArray opType = 334
opStructEndOmitEmptyArray opType = 335
opStructEndStringTagArray opType = 336
opStructEndMap opType = 337
opStructEndOmitEmptyMap opType = 338
opStructEndStringTagMap opType = 339
opStructEndSlice opType = 340
opStructEndOmitEmptySlice opType = 341
opStructEndStringTagSlice opType = 342
opStructEndStruct opType = 343
opStructEndOmitEmptyStruct opType = 344
opStructEndStringTagStruct opType = 345
opStructEndMarshalJSON opType = 346
opStructEndOmitEmptyMarshalJSON opType = 347
opStructEndStringTagMarshalJSON opType = 348
opStructEndMarshalText opType = 349
opStructEndOmitEmptyMarshalText opType = 350
opStructEndStringTagMarshalText opType = 351
opStructEndRecursive opType = 352
opStructEndOmitEmptyRecursive opType = 353
opStructEndStringTagRecursive opType = 354
opStructEndIntString opType = 355
opStructEndOmitEmptyIntString opType = 356
opStructEndStringTagIntString opType = 357
opStructEndUintString opType = 358
opStructEndOmitEmptyUintString opType = 359
opStructEndStringTagUintString opType = 360
opStructEndIntPtr opType = 361
opStructEndOmitEmptyIntPtr opType = 362
opStructEndStringTagIntPtr opType = 363
opStructEndUintPtr opType = 364
opStructEndOmitEmptyUintPtr opType = 365
opStructEndStringTagUintPtr opType = 366
opStructEndFloat32Ptr opType = 367
opStructEndOmitEmptyFloat32Ptr opType = 368
opStructEndStringTagFloat32Ptr opType = 369
opStructEndFloat64Ptr opType = 370
opStructEndOmitEmptyFloat64Ptr opType = 371
opStructEndStringTagFloat64Ptr opType = 372
opStructEndBoolPtr opType = 373
opStructEndOmitEmptyBoolPtr opType = 374
opStructEndStringTagBoolPtr opType = 375
opStructEndStringPtr opType = 376
opStructEndOmitEmptyStringPtr opType = 377
opStructEndStringTagStringPtr opType = 378
opStructEndBytesPtr opType = 379
opStructEndOmitEmptyBytesPtr opType = 380
opStructEndStringTagBytesPtr opType = 381
opStructEndArrayPtr opType = 382
opStructEndOmitEmptyArrayPtr opType = 383
opStructEndStringTagArrayPtr opType = 384
opStructEndSlicePtr opType = 385
opStructEndOmitEmptySlicePtr opType = 386
opStructEndStringTagSlicePtr opType = 387
opStructEndMapPtr opType = 388
opStructEndOmitEmptyMapPtr opType = 389
opStructEndStringTagMapPtr opType = 390
opStructEndMarshalJSONPtr opType = 391
opStructEndOmitEmptyMarshalJSONPtr opType = 392
opStructEndStringTagMarshalJSONPtr opType = 393
opStructEndMarshalTextPtr opType = 394
opStructEndOmitEmptyMarshalTextPtr opType = 395
opStructEndStringTagMarshalTextPtr opType = 396
opStructEndInterfacePtr opType = 397
opStructEndOmitEmptyInterfacePtr opType = 398
opStructEndStringTagInterfacePtr opType = 399
opStructEnd opType = 400
opStructEndOmitEmpty opType = 401
opStructEndStringTag opType = 402
)
func (t opType) String() string {
if int(t) >= 417 {
if int(t) >= 403 {
return ""
}
return opTypeStrings[int(t)]

View File

@ -335,44 +335,6 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco
code = code.end.next
}
}
case opMapHeadLoad:
ptr := load(ctxptr, code.idx)
if ptr == 0 {
b = encodeNull(b)
b = encodeComma(b)
code = code.end.next
} else {
// load pointer
ptr = ptrToPtr(ptr)
uptr := ptrToUnsafePtr(ptr)
if ptr == 0 {
b = encodeNull(b)
b = encodeComma(b)
code = code.end.next
break
}
mlen := maplen(uptr)
if mlen > 0 {
b = append(b, '{')
iter := mapiterinit(code.typ, uptr)
ctx.keepRefs = append(ctx.keepRefs, iter)
store(ctxptr, code.elemIdx, 0)
store(ctxptr, code.length, uintptr(mlen))
store(ctxptr, code.mapIter, uintptr(iter))
key := mapiterkey(iter)
store(ctxptr, code.next.idx, uintptr(key))
if (opt & EncodeOptionUnorderedMap) == 0 {
mapCtx := newMapContext(mlen)
mapCtx.pos = append(mapCtx.pos, len(b))
ctx.keepRefs = append(ctx.keepRefs, unsafe.Pointer(mapCtx))
store(ctxptr, code.end.mapPos, uintptr(unsafe.Pointer(mapCtx)))
}
code = code.next
} else {
b = append(b, '{', '}', ',')
code = code.end.next
}
}
case opMapKey:
idx := load(ctxptr, code.elemIdx)
length := load(ctxptr, code.length)
@ -3259,27 +3221,6 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco
} else {
code = code.nextField
}
case opStructFieldMapLoad:
b = append(b, code.key...)
ptr := load(ctxptr, code.headIdx)
p := ptr + code.offset
code = code.next
store(ctxptr, code.idx, p)
case opStructFieldOmitEmptyMapLoad:
ptr := load(ctxptr, code.headIdx)
p := ptr + code.offset
if p == 0 {
code = code.nextField
} else {
mlen := maplen(**(**unsafe.Pointer)(unsafe.Pointer(&p)))
if mlen == 0 {
code = code.nextField
} else {
b = append(b, code.key...)
code = code.next
store(ctxptr, code.idx, p)
}
}
case opStructFieldStruct:
b = append(b, code.key...)
ptr := load(ctxptr, code.headIdx)

View File

@ -1,12 +1,9 @@
package json
import (
"bytes"
"encoding"
"fmt"
"math"
"reflect"
"runtime"
"sort"
"strings"
"unsafe"
@ -17,7 +14,7 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o
ptrOffset := uintptr(0)
ctxptr := ctx.ptr()
code := codeSet.code
//fmt.Println(code.dump())
fmt.Println(code.dump())
for {
switch code.op {
@ -142,57 +139,57 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o
b = bb
code = code.next
case opMarshalJSON:
ptr := load(ctxptr, code.idx)
if ptr == 0 {
case opMarshalJSONPtr:
p := load(ctxptr, code.idx)
if p == 0 {
b = encodeNull(b)
b = encodeComma(b)
code = code.next
break
}
v := ptrToInterface(code, ptr)
bb, err := v.(Marshaler).MarshalJSON()
if err != nil {
return nil, errMarshaler(code, err)
}
runtime.KeepAlive(v)
if len(bb) == 0 {
return nil, errUnexpectedEndOfJSON(
fmt.Sprintf("error calling MarshalJSON for type %s", code.typ),
0,
)
}
buf := bytes.NewBuffer(b)
//TODO: we should validate buffer with `compact`
if err := compact(buf, bb, false); err != nil {
return nil, err
}
b = buf.Bytes()
store(ctxptr, code.idx, ptrToPtr(p))
fallthrough
case opMarshalJSON:
p := load(ctxptr, code.idx)
if p == 0 {
b = encodeNull(b)
b = encodeComma(b)
code = code.next
case opMarshalText:
ptr := load(ctxptr, code.idx)
isPtr := code.typ.Kind() == reflect.Ptr
p := ptrToUnsafePtr(ptr)
if p == nil || isPtr && *(*unsafe.Pointer)(p) == nil {
b = append(b, '"', '"', ',')
} else {
v := *(*interface{})(unsafe.Pointer(&interfaceHeader{
typ: code.typ,
ptr: p,
}))
bytes, err := v.(encoding.TextMarshaler).MarshalText()
break
}
bb, err := encodeMarshalJSON(b, ptrToInterface(code, p))
if err != nil {
return nil, errMarshaler(code, err)
return nil, err
}
b = encodeEscapedString(b, *(*string)(unsafe.Pointer(&bytes)))
b = encodeComma(bb)
code = code.next
case opMarshalTextPtr:
p := load(ctxptr, code.idx)
if p == 0 {
b = encodeNull(b)
b = encodeComma(b)
break
}
store(ctxptr, code.idx, ptrToPtr(p))
fallthrough
case opMarshalText:
p := load(ctxptr, code.idx)
if p == 0 {
b = append(b, `""`...)
b = encodeComma(b)
code = code.next
break
}
bb, err := encodeMarshalText(b, ptrToInterface(code, p))
if err != nil {
return nil, err
}
b = encodeComma(bb)
code = code.next
case opSlice:
p := load(ctxptr, code.idx)
slice := ptrToSlice(p)
if p == 0 || uintptr(slice.data) == 0 {
if p == 0 || slice.data == nil {
b = encodeNull(b)
b = encodeComma(b)
code = code.end.next
@ -287,44 +284,6 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o
code = code.end.next
}
}
case opMapHeadLoad:
ptr := load(ctxptr, code.idx)
if ptr == 0 {
b = encodeNull(b)
b = encodeComma(b)
code = code.end.next
} else {
// load pointer
ptr = ptrToPtr(ptr)
uptr := ptrToUnsafePtr(ptr)
if ptr == 0 {
b = encodeNull(b)
b = encodeComma(b)
code = code.end.next
break
}
mlen := maplen(uptr)
if mlen > 0 {
b = append(b, '{')
iter := mapiterinit(code.typ, uptr)
ctx.keepRefs = append(ctx.keepRefs, iter)
store(ctxptr, code.elemIdx, 0)
store(ctxptr, code.length, uintptr(mlen))
store(ctxptr, code.mapIter, uintptr(iter))
key := mapiterkey(iter)
store(ctxptr, code.next.idx, uintptr(key))
if (opt & EncodeOptionUnorderedMap) == 0 {
mapCtx := newMapContext(mlen)
mapCtx.pos = append(mapCtx.pos, len(b))
ctx.keepRefs = append(ctx.keepRefs, unsafe.Pointer(mapCtx))
store(ctxptr, code.end.mapPos, uintptr(unsafe.Pointer(mapCtx)))
}
code = code.next
} else {
b = append(b, '{', '}', ',')
code = code.end.next
}
}
case opMapKey:
idx := load(ctxptr, code.elemIdx)
length := load(ctxptr, code.length)
@ -3225,27 +3184,6 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o
} else {
code = code.nextField
}
case opStructFieldMapLoad:
b = append(b, code.escapedKey...)
ptr := load(ctxptr, code.headIdx)
p := ptr + code.offset
code = code.next
store(ctxptr, code.idx, p)
case opStructFieldOmitEmptyMapLoad:
ptr := load(ctxptr, code.headIdx)
p := ptr + code.offset
if p == 0 {
code = code.nextField
} else {
mlen := maplen(**(**unsafe.Pointer)(unsafe.Pointer(&p)))
if mlen == 0 {
code = code.nextField
} else {
b = append(b, code.escapedKey...)
code = code.next
store(ctxptr, code.idx, p)
}
}
case opStructFieldStruct:
b = append(b, code.escapedKey...)
ptr := load(ctxptr, code.headIdx)

View File

@ -17,6 +17,7 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode
ptrOffset := uintptr(0)
ctxptr := ctx.ptr()
code := codeSet.code
fmt.Println(code.dump())
for {
switch code.op {
@ -337,50 +338,6 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode
key := mapiterkey(iter)
store(ctxptr, code.next.idx, uintptr(key))
code = code.next
} else {
b = appendIndent(ctx, b, code.indent)
b = append(b, '{', '}', ',', '\n')
code = code.end.next
}
}
case opMapHeadLoad:
ptr := load(ctxptr, code.idx)
if ptr == 0 {
b = appendIndent(ctx, b, code.indent)
b = encodeNull(b)
code = code.end.next
} else {
// load pointer
ptr = ptrToPtr(ptr)
uptr := ptrToUnsafePtr(ptr)
if uintptr(uptr) == 0 {
b = appendIndent(ctx, b, code.indent)
b = encodeNull(b)
b = encodeIndentComma(b)
code = code.end.next
break
}
mlen := maplen(uptr)
if mlen > 0 {
b = append(b, '{', '\n')
iter := mapiterinit(code.typ, uptr)
ctx.keepRefs = append(ctx.keepRefs, iter)
store(ctxptr, code.elemIdx, 0)
store(ctxptr, code.length, uintptr(mlen))
store(ctxptr, code.mapIter, uintptr(iter))
key := mapiterkey(iter)
store(ctxptr, code.next.idx, uintptr(key))
if (opt & EncodeOptionUnorderedMap) == 0 {
mapCtx := newMapContext(mlen)
mapCtx.pos = append(mapCtx.pos, len(b))
ctx.keepRefs = append(ctx.keepRefs, unsafe.Pointer(mapCtx))
store(ctxptr, code.end.mapPos, uintptr(unsafe.Pointer(mapCtx)))
} else {
b = appendIndent(ctx, b, code.next.indent)
}
code = code.next
} else {
b = appendIndent(ctx, b, code.indent)
@ -3524,41 +3481,6 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode
} else {
code = code.nextField
}
case opStructFieldMapLoad:
b = appendIndent(ctx, b, code.indent)
b = append(b, code.escapedKey...)
b = append(b, ' ')
ptr := load(ctxptr, code.headIdx)
p := ptr + code.offset
if p == 0 {
b = encodeNull(b)
code = code.nextField
} else {
p = ptrToPtr(p)
mlen := maplen(ptrToUnsafePtr(p))
if mlen == 0 {
b = append(b, '{', '}', ',', '\n')
code = code.nextField
} else {
code = code.next
}
}
case opStructFieldOmitEmptyMapLoad:
ptr := load(ctxptr, code.headIdx)
p := ptr + code.offset
if p == 0 {
code = code.nextField
} else {
mlen := maplen(**(**unsafe.Pointer)(unsafe.Pointer(&p)))
if mlen == 0 {
code = code.nextField
} else {
b = appendIndent(ctx, b, code.indent)
b = append(b, code.escapedKey...)
b = append(b, ' ')
code = code.next
}
}
case opStructFieldStruct:
ptr := load(ctxptr, code.headIdx)
p := ptr + code.offset

View File

@ -337,50 +337,6 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op
key := mapiterkey(iter)
store(ctxptr, code.next.idx, uintptr(key))
code = code.next
} else {
b = appendIndent(ctx, b, code.indent)
b = append(b, '{', '}', ',', '\n')
code = code.end.next
}
}
case opMapHeadLoad:
ptr := load(ctxptr, code.idx)
if ptr == 0 {
b = appendIndent(ctx, b, code.indent)
b = encodeNull(b)
code = code.end.next
} else {
// load pointer
ptr = ptrToPtr(ptr)
uptr := ptrToUnsafePtr(ptr)
if uintptr(uptr) == 0 {
b = appendIndent(ctx, b, code.indent)
b = encodeNull(b)
b = encodeIndentComma(b)
code = code.end.next
break
}
mlen := maplen(uptr)
if mlen > 0 {
b = append(b, '{', '\n')
iter := mapiterinit(code.typ, uptr)
ctx.keepRefs = append(ctx.keepRefs, iter)
store(ctxptr, code.elemIdx, 0)
store(ctxptr, code.length, uintptr(mlen))
store(ctxptr, code.mapIter, uintptr(iter))
key := mapiterkey(iter)
store(ctxptr, code.next.idx, uintptr(key))
if (opt & EncodeOptionUnorderedMap) == 0 {
mapCtx := newMapContext(mlen)
mapCtx.pos = append(mapCtx.pos, len(b))
ctx.keepRefs = append(ctx.keepRefs, unsafe.Pointer(mapCtx))
store(ctxptr, code.end.mapPos, uintptr(unsafe.Pointer(mapCtx)))
} else {
b = appendIndent(ctx, b, code.next.indent)
}
code = code.next
} else {
b = appendIndent(ctx, b, code.indent)
@ -3525,41 +3481,6 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op
} else {
code = code.nextField
}
case opStructFieldMapLoad:
b = appendIndent(ctx, b, code.indent)
b = append(b, code.key...)
b = append(b, ' ')
ptr := load(ctxptr, code.headIdx)
p := ptr + code.offset
if p == 0 {
b = encodeNull(b)
code = code.nextField
} else {
p = ptrToPtr(p)
mlen := maplen(ptrToUnsafePtr(p))
if mlen == 0 {
b = append(b, '{', '}', ',', '\n')
code = code.nextField
} else {
code = code.next
}
}
case opStructFieldOmitEmptyMapLoad:
ptr := load(ctxptr, code.headIdx)
p := ptr + code.offset
if p == 0 {
code = code.nextField
} else {
mlen := maplen(**(**unsafe.Pointer)(unsafe.Pointer(&p)))
if mlen == 0 {
code = code.nextField
} else {
b = appendIndent(ctx, b, code.indent)
b = append(b, code.key...)
b = append(b, ' ')
code = code.next
}
}
case opStructFieldStruct:
ptr := load(ctxptr, code.headIdx)
p := ptr + code.offset