...
1
16
17 package decoder
18
19 import (
20 `os`
21 `runtime`
22 `runtime/debug`
23 `strings`
24
25 `github.com/bytedance/sonic/internal/jit`
26 )
27
28
29 var (
30 debugSyncGC = os.Getenv("SONIC_SYNC_GC") != ""
31 debugAsyncGC = os.Getenv("SONIC_NO_ASYNC_GC") == ""
32 )
33
34 var (
35 _Instr_End _Instr = newInsOp(_OP_nil_1)
36
37 _F_gc = jit.Func(runtime.GC)
38 _F_force_gc = jit.Func(debug.FreeOSMemory)
39 _F_println = jit.Func(println_wrapper)
40 _F_print = jit.Func(print)
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 print(i int){
48 println(i)
49 }
50
51 func (self *_Assembler) force_gc() {
52 self.call_go(_F_gc)
53 self.call_go(_F_force_gc)
54 }
55
56 func (self *_Assembler) debug_instr(i int, v *_Instr) {
57 if debugSyncGC {
58 if (i+1 == len(self.p)) {
59 self.print_gc(i, v, &_Instr_End)
60 } else {
61 next := &(self.p[i+1])
62 self.print_gc(i, v, next)
63 name := _OpNames[next.op()]
64 if strings.Contains(name, "save") {
65 return
66 }
67 }
68 self.force_gc()
69 }
70 }
71
View as plain text