mirror of
https://github.com/ii64/sonic.git
synced 2026-06-23 01:46:44 +08:00
fix: add stack memory at _VAR_vp to pass the address of vp while recursing (#129)
Co-authored-by: duanyi.aster <duanyi.aster@bytedance.com>
This commit is contained in:
parent
442ce696fb
commit
0f66ab7211
2 changed files with 60 additions and 3 deletions
|
|
@ -72,7 +72,7 @@ const (
|
||||||
_FP_args = 48 // 48 bytes for passing arguments to this function
|
_FP_args = 48 // 48 bytes for passing arguments to this function
|
||||||
_FP_fargs = 64 // 64 bytes for passing arguments to other Go functions
|
_FP_fargs = 64 // 64 bytes for passing arguments to other Go functions
|
||||||
_FP_saves = 64 // 64 bytes for saving the registers before CALL instructions
|
_FP_saves = 64 // 64 bytes for saving the registers before CALL instructions
|
||||||
_FP_locals = 16 // 16 bytes for local variables
|
_FP_locals = 24 // 24 bytes for local variables
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|
@ -157,6 +157,7 @@ var (
|
||||||
var (
|
var (
|
||||||
_VAR_sp = jit.Ptr(_SP, _FP_fargs + _FP_saves)
|
_VAR_sp = jit.Ptr(_SP, _FP_fargs + _FP_saves)
|
||||||
_VAR_dn = jit.Ptr(_SP, _FP_fargs + _FP_saves + 8)
|
_VAR_dn = jit.Ptr(_SP, _FP_fargs + _FP_saves + 8)
|
||||||
|
_VAR_vp = jit.Ptr(_SP, _FP_fargs + _FP_saves + 16)
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|
@ -963,8 +964,8 @@ func (self *_Assembler) _asm_OP_recurse(p *_Instr) {
|
||||||
if (p.vf() & rt.F_direct) != 0 {
|
if (p.vf() & rt.F_direct) != 0 {
|
||||||
self.Emit("MOVQ", _SP_p, _AX) // MOVQ SP.p, AX
|
self.Emit("MOVQ", _SP_p, _AX) // MOVQ SP.p, AX
|
||||||
} else {
|
} else {
|
||||||
self.Emit("MOVQ", _SP_p, jit.Ptr(_SP, 48)) // MOVQ SP.p, 48(SP)
|
self.Emit("MOVQ", _SP_p, _VAR_vp) // MOVQ SP.p, 48(SP)
|
||||||
self.Emit("LEAQ", jit.Ptr(_SP, 48), _AX) // LEAQ 48(SP), AX
|
self.Emit("LEAQ", _VAR_vp, _AX) // LEAQ 48(SP), AX
|
||||||
}
|
}
|
||||||
|
|
||||||
/* call the encoder */
|
/* call the encoder */
|
||||||
|
|
|
||||||
56
issue_test/issue128_test.go
Normal file
56
issue_test/issue128_test.go
Normal file
|
|
@ -0,0 +1,56 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2021 ByteDance Inc.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package issue_test
|
||||||
|
|
||||||
|
import (
|
||||||
|
`runtime/debug`
|
||||||
|
`testing`
|
||||||
|
|
||||||
|
`github.com/bytedance/sonic`
|
||||||
|
)
|
||||||
|
|
||||||
|
//NOTICE: only DEBUG mode can reproduce problem
|
||||||
|
func TestDebug(t *testing.T) {
|
||||||
|
debug.SetGCPercent(-1)
|
||||||
|
data := &Data{
|
||||||
|
Details: []*Detail{
|
||||||
|
{
|
||||||
|
Info: Info{},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
body, err := sonic.Marshal(data)
|
||||||
|
if err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
t.Log(string(body))
|
||||||
|
}
|
||||||
|
|
||||||
|
type Detail struct {
|
||||||
|
Info Info
|
||||||
|
}
|
||||||
|
|
||||||
|
type Info struct {
|
||||||
|
A int
|
||||||
|
}
|
||||||
|
|
||||||
|
type Data struct {
|
||||||
|
Details []*Detail
|
||||||
|
}
|
||||||
|
|
||||||
Loading…
Reference in a new issue