mirror of https://github.com/goccy/go-json.git
pass benchmark test
This commit is contained in:
parent
c9a4a47e1c
commit
f610966b65
|
@ -483,16 +483,17 @@ func linkRecursiveCode2(ctx *compileContext) {
|
||||||
beforeLastCode := code.End
|
beforeLastCode := code.End
|
||||||
lastCode := beforeLastCode.Next
|
lastCode := beforeLastCode.Next
|
||||||
|
|
||||||
lastCode.Idx = beforeLastCode.Idx + uintptrSize
|
totalLength := code.TotalLength()
|
||||||
|
lastCode.Idx = uint32((totalLength + 1) * uintptrSize)
|
||||||
lastCode.ElemIdx = lastCode.Idx + uintptrSize
|
lastCode.ElemIdx = lastCode.Idx + uintptrSize
|
||||||
lastCode.Length = lastCode.Idx + 2*uintptrSize
|
lastCode.Length = lastCode.Idx + 2*uintptrSize
|
||||||
code.End.Next.Op = OpRecursiveEnd
|
code.End.Next.Op = OpRecursiveEnd
|
||||||
|
|
||||||
// extend length to alloc slot for elemIdx + length
|
|
||||||
totalLength := uintptr(recursive.TotalLength()) + 3
|
|
||||||
nextTotalLength := uintptr(codes.First().TotalLength()) + 3
|
|
||||||
|
|
||||||
compiled.CurLen = totalLength
|
// extend length to alloc slot for elemIdx + length
|
||||||
|
curTotalLength := uintptr(recursive.TotalLength()) + 3
|
||||||
|
nextTotalLength := uintptr(totalLength) + 3
|
||||||
|
compiled.CurLen = curTotalLength
|
||||||
compiled.NextLen = nextTotalLength
|
compiled.NextLen = nextTotalLength
|
||||||
compiled.Linked = true
|
compiled.Linked = true
|
||||||
}
|
}
|
||||||
|
|
|
@ -490,7 +490,7 @@ func (c *Opcode) dumpHead(code *Opcode) string {
|
||||||
length = code.Length / uintptrSize
|
length = code.Length / uintptrSize
|
||||||
}
|
}
|
||||||
return fmt.Sprintf(
|
return fmt.Sprintf(
|
||||||
`[%02d]%s%s ([idx:%d][elemIdx:%d][length:%d])`,
|
`[%03d]%s%s ([idx:%d][elemIdx:%d][length:%d])`,
|
||||||
code.DisplayIdx,
|
code.DisplayIdx,
|
||||||
strings.Repeat("-", int(code.Indent)),
|
strings.Repeat("-", int(code.Indent)),
|
||||||
code.Op,
|
code.Op,
|
||||||
|
@ -502,7 +502,7 @@ 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(
|
||||||
`[%02d]%s%s ([idx:%d][elemIdx:%d][length:%d][mapIter:%d])`,
|
`[%03d]%s%s ([idx:%d][elemIdx:%d][length:%d][mapIter:%d])`,
|
||||||
code.DisplayIdx,
|
code.DisplayIdx,
|
||||||
strings.Repeat("-", int(code.Indent)),
|
strings.Repeat("-", int(code.Indent)),
|
||||||
code.Op,
|
code.Op,
|
||||||
|
@ -515,7 +515,7 @@ func (c *Opcode) dumpMapHead(code *Opcode) string {
|
||||||
|
|
||||||
func (c *Opcode) dumpMapEnd(code *Opcode) string {
|
func (c *Opcode) dumpMapEnd(code *Opcode) string {
|
||||||
return fmt.Sprintf(
|
return fmt.Sprintf(
|
||||||
`[%02d]%s%s ([idx:%d][mapPos:%d][length:%d])`,
|
`[%03d]%s%s ([idx:%d][mapPos:%d][length:%d])`,
|
||||||
code.DisplayIdx,
|
code.DisplayIdx,
|
||||||
strings.Repeat("-", int(code.Indent)),
|
strings.Repeat("-", int(code.Indent)),
|
||||||
code.Op,
|
code.Op,
|
||||||
|
@ -533,7 +533,7 @@ func (c *Opcode) dumpElem(code *Opcode) string {
|
||||||
length = code.Length / uintptrSize
|
length = code.Length / uintptrSize
|
||||||
}
|
}
|
||||||
return fmt.Sprintf(
|
return fmt.Sprintf(
|
||||||
`[%02d]%s%s ([idx:%d][elemIdx:%d][length:%d][size:%d])`,
|
`[%03d]%s%s ([idx:%d][elemIdx:%d][length:%d][size:%d])`,
|
||||||
code.DisplayIdx,
|
code.DisplayIdx,
|
||||||
strings.Repeat("-", int(code.Indent)),
|
strings.Repeat("-", int(code.Indent)),
|
||||||
code.Op,
|
code.Op,
|
||||||
|
@ -546,7 +546,7 @@ func (c *Opcode) dumpElem(code *Opcode) string {
|
||||||
|
|
||||||
func (c *Opcode) dumpField(code *Opcode) string {
|
func (c *Opcode) dumpField(code *Opcode) string {
|
||||||
return fmt.Sprintf(
|
return fmt.Sprintf(
|
||||||
`[%02d]%s%s ([idx:%d][key:%s][offset:%d])`,
|
`[%03d]%s%s ([idx:%d][key:%s][offset:%d])`,
|
||||||
code.DisplayIdx,
|
code.DisplayIdx,
|
||||||
strings.Repeat("-", int(code.Indent)),
|
strings.Repeat("-", int(code.Indent)),
|
||||||
code.Op,
|
code.Op,
|
||||||
|
@ -558,7 +558,7 @@ 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(
|
||||||
`[%02d]%s%s ([idx:%d][elemIdx:%d][length:%d][mapIter:%d])`,
|
`[%03d]%s%s ([idx:%d][elemIdx:%d][length:%d][mapIter:%d])`,
|
||||||
code.DisplayIdx,
|
code.DisplayIdx,
|
||||||
strings.Repeat("-", int(code.Indent)),
|
strings.Repeat("-", int(code.Indent)),
|
||||||
code.Op,
|
code.Op,
|
||||||
|
@ -571,7 +571,7 @@ func (c *Opcode) dumpKey(code *Opcode) string {
|
||||||
|
|
||||||
func (c *Opcode) dumpValue(code *Opcode) string {
|
func (c *Opcode) dumpValue(code *Opcode) string {
|
||||||
return fmt.Sprintf(
|
return fmt.Sprintf(
|
||||||
`[%02d]%s%s ([idx:%d][mapIter:%d])`,
|
`[%03d]%s%s ([idx:%d][mapIter:%d])`,
|
||||||
code.DisplayIdx,
|
code.DisplayIdx,
|
||||||
strings.Repeat("-", int(code.Indent)),
|
strings.Repeat("-", int(code.Indent)),
|
||||||
code.Op,
|
code.Op,
|
||||||
|
@ -610,7 +610,7 @@ func (c *Opcode) Dump() string {
|
||||||
code = code.Next
|
code = code.Next
|
||||||
default:
|
default:
|
||||||
codes = append(codes, fmt.Sprintf(
|
codes = append(codes, fmt.Sprintf(
|
||||||
"[%02d]%s%s ([idx:%d])",
|
"[%03d]%s%s ([idx:%d])",
|
||||||
code.DisplayIdx,
|
code.DisplayIdx,
|
||||||
strings.Repeat("-", int(code.Indent)),
|
strings.Repeat("-", int(code.Indent)),
|
||||||
code.Op,
|
code.Op,
|
||||||
|
|
Loading…
Reference in New Issue