...
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
22 `github.com/bytedance/sonic/internal/jit`
23 `github.com/twitchyliquid64/golang-asm/obj`
24 `github.com/twitchyliquid64/golang-asm/obj/x86`
25 )
26
27 var (
28 _V_writeBarrier = jit.Imm(int64(_runtime_writeBarrier))
29
30 _F_gcWriteBarrierAX = jit.Func(gcWriteBarrierAX)
31 )
32
33 func (self *_Assembler) WritePtr(i int, ptr obj.Addr, rec obj.Addr) {
34 if rec.Reg == x86.REG_AX || rec.Index == x86.REG_AX {
35 panic("rec contains AX!")
36 }
37 self.Emit("MOVQ", _V_writeBarrier, _R10)
38 self.Emit("CMPL", jit.Ptr(_R10, 0), jit.Imm(0))
39 self.Sjmp("JE", "_no_writeBarrier" + strconv.Itoa(i) + "_{n}")
40 self.Emit("MOVQ", ptr, _AX)
41 self.xsave(_DI)
42 self.Emit("LEAQ", rec, _DI)
43 self.Emit("MOVQ", _F_gcWriteBarrierAX, _R10)
44 self.Rjmp("CALL", _R10)
45 self.xload(_DI)
46 self.Sjmp("JMP", "_end_writeBarrier" + strconv.Itoa(i) + "_{n}")
47 self.Link("_no_writeBarrier" + strconv.Itoa(i) + "_{n}")
48 self.Emit("MOVQ", ptr, rec)
49 self.Link("_end_writeBarrier" + strconv.Itoa(i) + "_{n}")
50 }
51
52
View as plain text