github.com/goshafaq/sonic@v0.0.0-20231026082336-871835fb94c6/internal/encoder/asm_stubs_amd64_go116.go (about) 1 //go:build go1.16 && !go1.17 2 // +build go1.16,!go1.17 3 4 // Copyright 2023 CloudWeGo Authors 5 // 6 // Licensed under the Apache License, Version 2.0 (the "License"); 7 // you may not use this file except in compliance with the License. 8 // You may obtain a copy of the License at 9 // 10 // http://www.apache.org/licenses/LICENSE-2.0 11 // 12 // Unless required by applicable law or agreed to in writing, software 13 // distributed under the License is distributed on an "AS IS" BASIS, 14 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 // See the License for the specific language governing permissions and 16 // limitations under the License. 17 18 package encoder 19 20 import ( 21 "strconv" 22 23 "github.com/goshafaq/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(_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, _R10) 39 self.Emit("CMPL", jit.Ptr(_R10, 0), jit.Imm(0)) 40 self.Sjmp("JE", "_no_writeBarrier"+strconv.Itoa(i)+"_{n}") 41 self.Emit("MOVQ", ptr, _AX) 42 self.xsave(_DI) 43 self.Emit("LEAQ", rec, _DI) 44 self.Emit("MOVQ", _F_gcWriteBarrierAX, _R10) // MOVQ ${fn}, AX 45 self.Rjmp("CALL", _R10) 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 }