...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package encoder
18
19 import (
20 `strconv`
21 `unsafe`
22
23 `github.com/bytedance/sonic/internal/jit`
24 `github.com/twitchyliquid64/golang-asm/obj`
25 `github.com/twitchyliquid64/golang-asm/obj/x86`
26 )
27
28 var (
29 _V_writeBarrier = jit.Imm(int64(uintptr(unsafe.Pointer(&_runtime_writeBarrier))))
30
31 _F_gcWriteBarrier2 = jit.Func(gcWriteBarrier2)
32 )
33
34 func (self *_Assembler) WritePtr(i int, ptr obj.Addr, old obj.Addr) {
35 if old.Reg == x86.REG_AX || old.Index == x86.REG_AX {
36 panic("rec contains AX!")
37 }
38 self.Emit("MOVQ", _V_writeBarrier, _BX)
39 self.Emit("CMPL", jit.Ptr(_BX, 0), jit.Imm(0))
40 self.Sjmp("JE", "_no_writeBarrier" + strconv.Itoa(i) + "_{n}")
41 self.xsave(_SP_q)
42 self.Emit("MOVQ", _F_gcWriteBarrier2, _BX)
43 self.Rjmp("CALL", _BX)
44 self.Emit("MOVQ", ptr, jit.Ptr(_SP_q, 0))
45 self.Emit("MOVQ", old, _AX)
46 self.Emit("MOVQ", _AX, jit.Ptr(_SP_q, 8))
47 self.xload(_SP_q)
48 self.Link("_no_writeBarrier" + strconv.Itoa(i) + "_{n}")
49 self.Emit("MOVQ", ptr, old)
50 }
51
View as plain text