diff --git a/internal/encoder/assembler_regabi_amd64.go b/internal/encoder/assembler_regabi_amd64.go index 4584c6d29..80f600a62 100644 --- a/internal/encoder/assembler_regabi_amd64.go +++ b/internal/encoder/assembler_regabi_amd64.go @@ -356,7 +356,19 @@ func (self *_Assembler) store_int(nd int, fn obj.Addr, ins string) { self.rbuf_di() // MOVQ RP, DI self.Emit(ins, jit.Ptr(_SP_p, 0), _SI) // $ins (SP.p), SI self.call_c(fn) // CALL_C $fn + if fn == _F_i64toa { + self.check_int64(ins) + } else { + self.Emit("ADDQ", _AX, _RL) // ADDQ AX, RL + } +} + +func (self *_Assembler) check_int64(ins string) { + self.Emit("LEAQ", jit.Sib(_RP, _RL, 1, 0), _BX) + self.Emit("MOVQ", _AX, _CX) self.Emit("ADDQ", _AX, _RL) // ADDQ AX, RL + self.Emit(ins, jit.Ptr(_SP_p, 0), _AX) + self.call_go(_F_check_int64) } func (self *_Assembler) store_str(s string) { diff --git a/internal/encoder/debug_go117.go b/internal/encoder/debug_go117.go index 37e6f7d4f..39fabfa53 100644 --- a/internal/encoder/debug_go117.go +++ b/internal/encoder/debug_go117.go @@ -1,3 +1,4 @@ +//go:build go1.17 && !go1.23 // +build go1.17,!go1.23 /* @@ -19,14 +20,15 @@ package encoder import ( - `fmt` - `os` - `runtime` - `strings` - `unsafe` - - `github.com/bytedance/sonic/internal/jit` - `github.com/twitchyliquid64/golang-asm/obj` + "fmt" + "os" + "runtime" + "strconv" + "strings" + "unsafe" + + "github.com/bytedance/sonic/internal/jit" + "github.com/twitchyliquid64/golang-asm/obj" ) const _FP_debug = 128 @@ -73,6 +75,19 @@ func print(i int){ println(i) } +var _F_check_int64 = jit.Func(checkInt64) + +func checkInt64(i int64, s string) { + // println("checkInt64", i, s) + a, err := strconv.ParseInt(s, 10, 64) + if err != nil { + panic(err) + } + if a != i { + panic(fmt.Sprintf("checkInt64: %d != %d", a, i)) + } +} + func gc() { if !debugSyncGC { return