Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: add int64 check in JIT #693

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions internal/encoder/assembler_regabi_amd64.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
31 changes: 23 additions & 8 deletions internal/encoder/debug_go117.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build go1.17 && !go1.23
// +build go1.17,!go1.23

/*
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
Loading