...
1
2
3
18
19 package encoder
20
21 import (
22 `os`
23 `strings`
24 `runtime`
25 `runtime/debug`
26
27 `github.com/bytedance/sonic/internal/jit`
28 )
29
30 var (
31 debugSyncGC = os.Getenv("SONIC_SYNC_GC") != ""
32 debugAsyncGC = os.Getenv("SONIC_NO_ASYNC_GC") == ""
33 )
34
35 var (
36 _Instr_End _Instr = newInsOp(_OP_null)
37
38 _F_gc = jit.Func(runtime.GC)
39 _F_force_gc = jit.Func(debug.FreeOSMemory)
40 _F_println = jit.Func(println_wrapper)
41 )
42
43 func println_wrapper(i int, op1 int, op2 int){
44 println(i, " Intrs ", op1, _OpNames[op1], "next: ", op2, _OpNames[op2])
45 }
46
47 func (self *_Assembler) force_gc() {
48 self.call_go(_F_gc)
49 self.call_go(_F_force_gc)
50 }
51
52 func (self *_Assembler) debug_instr(i int, v *_Instr) {
53 if debugSyncGC {
54 if (i+1 == len(self.p)) {
55 self.print_gc(i, v, &_Instr_End)
56 } else {
57 next := &(self.p[i+1])
58 self.print_gc(i, v, next)
59 name := _OpNames[next.op()]
60 if strings.Contains(name, "save") {
61 return
62 }
63 }
64 self.force_gc()
65 }
66 }
67
View as plain text