...
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_gcWriteBarrierAX = jit.Func(gcWriteBarrierAX)
32 )
33
34 func (self *_Assembler) WritePtr(i int, ptr obj.Addr, rec obj.Addr) {
35 if rec.Reg == x86.REG_AX || rec.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(_DI)
42 self.Emit("MOVQ", ptr, _AX)
43 self.Emit("LEAQ", rec, _DI)
44 self.Emit("MOVQ", _F_gcWriteBarrierAX, _BX)
45 self.Rjmp("CALL", _BX)
46 self.xload(_DI)
47 self.Sjmp("JMP", "_end_writeBarrier" + strconv.Itoa(i) + "_{n}")
48 self.Link("_no_writeBarrier" + strconv.Itoa(i) + "_{n}")
49 self.Emit("MOVQ", ptr, rec)
50 self.Link("_end_writeBarrier" + strconv.Itoa(i) + "_{n}")
51 }
52
View as plain text