github.com/primecitizens/pcz/std@v0.2.1/core/gc/wb_mips64x.s (about) 1 // SPDX-License-Identifier: Apache-2.0 2 // Copyright 2023 The Prime Citizens 3 // 4 // Copyright 2015 The Go Authors. All rights reserved. 5 // Use of this source code is governed by a BSD-style 6 // license that can be found in the LICENSE file. 7 8 //go:build mips64 || mips64le 9 10 #include "textflag.h" 11 12 // gcWriteBarrier informs the GC about heap pointer writes. 13 // 14 // gcWriteBarrier does NOT follow the Go ABI. It accepts the 15 // number of bytes of buffer needed in R25, and returns a pointer 16 // to the buffer space in R25. 17 // It clobbers R23 (the linker temp register). 18 // The act of CALLing gcWriteBarrier will clobber R31 (LR). 19 // It does not clobber any other general-purpose registers, 20 // but may clobber others (e.g., floating point registers). 21 TEXT gcWriteBarrier<>(SB),NOSPLIT,$192 22 // Save the registers clobbered by the fast path. 23 MOVV R1, 184(R29) 24 MOVV R2, 192(R29) 25 retry: 26 MOVV g_m(g), R1 27 MOVV m_p(R1), R1 28 MOVV (p_wbBuf+wbBuf_next)(R1), R2 29 MOVV (p_wbBuf+wbBuf_end)(R1), R23 // R23 is linker temp register 30 // Increment wbBuf.next position. 31 ADDV R25, R2 32 // Is the buffer full? 33 SGTU R2, R23, R23 34 BNE R23, flush 35 // Commit to the larger buffer. 36 MOVV R2, (p_wbBuf+wbBuf_next)(R1) 37 // Make return value (the original next position) 38 SUBV R25, R2, R25 39 // Restore registers. 40 MOVV 184(R29), R1 41 MOVV 192(R29), R2 42 RET 43 44 flush: 45 // Save all general purpose registers since these could be 46 // clobbered by wbBufFlush and were not saved by the caller. 47 MOVV R20, 8(R29) 48 MOVV R21, 16(R29) 49 // R1 already saved 50 // R2 already saved 51 MOVV R3, 24(R29) 52 MOVV R4, 32(R29) 53 MOVV R5, 40(R29) 54 MOVV R6, 48(R29) 55 MOVV R7, 56(R29) 56 MOVV R8, 64(R29) 57 MOVV R9, 72(R29) 58 MOVV R10, 80(R29) 59 MOVV R11, 88(R29) 60 MOVV R12, 96(R29) 61 MOVV R13, 104(R29) 62 MOVV R14, 112(R29) 63 MOVV R15, 120(R29) 64 MOVV R16, 128(R29) 65 MOVV R17, 136(R29) 66 MOVV R18, 144(R29) 67 MOVV R19, 152(R29) 68 // R20 already saved 69 // R21 already saved. 70 MOVV R22, 160(R29) 71 // R23 is tmp register. 72 MOVV R24, 168(R29) 73 MOVV R25, 176(R29) 74 // R26 is reserved by kernel. 75 // R27 is reserved by kernel. 76 // R28 is REGSB (not modified by Go code). 77 // R29 is SP. 78 // R30 is g. 79 // R31 is LR, which was saved by the prologue. 80 81 CALL runtime·wbBufFlush(SB) 82 83 MOVV 8(R29), R20 84 MOVV 16(R29), R21 85 MOVV 24(R29), R3 86 MOVV 32(R29), R4 87 MOVV 40(R29), R5 88 MOVV 48(R29), R6 89 MOVV 56(R29), R7 90 MOVV 64(R29), R8 91 MOVV 72(R29), R9 92 MOVV 80(R29), R10 93 MOVV 88(R29), R11 94 MOVV 96(R29), R12 95 MOVV 104(R29), R13 96 MOVV 112(R29), R14 97 MOVV 120(R29), R15 98 MOVV 128(R29), R16 99 MOVV 136(R29), R17 100 MOVV 144(R29), R18 101 MOVV 152(R29), R19 102 MOVV 160(R29), R22 103 MOVV 168(R29), R24 104 MOVV 176(R29), R25 105 JMP retry 106 107 TEXT runtime·gcWriteBarrier1<ABIInternal>(SB),NOSPLIT,$0 108 MOVV $8, R25 109 JMP gcWriteBarrier<>(SB) 110 TEXT runtime·gcWriteBarrier2<ABIInternal>(SB),NOSPLIT,$0 111 MOVV $16, R25 112 JMP gcWriteBarrier<>(SB) 113 TEXT runtime·gcWriteBarrier3<ABIInternal>(SB),NOSPLIT,$0 114 MOVV $24, R25 115 JMP gcWriteBarrier<>(SB) 116 TEXT runtime·gcWriteBarrier4<ABIInternal>(SB),NOSPLIT,$0 117 MOVV $32, R25 118 JMP gcWriteBarrier<>(SB) 119 TEXT runtime·gcWriteBarrier5<ABIInternal>(SB),NOSPLIT,$0 120 MOVV $40, R25 121 JMP gcWriteBarrier<>(SB) 122 TEXT runtime·gcWriteBarrier6<ABIInternal>(SB),NOSPLIT,$0 123 MOVV $48, R25 124 JMP gcWriteBarrier<>(SB) 125 TEXT runtime·gcWriteBarrier7<ABIInternal>(SB),NOSPLIT,$0 126 MOVV $56, R25 127 JMP gcWriteBarrier<>(SB) 128 TEXT runtime·gcWriteBarrier8<ABIInternal>(SB),NOSPLIT,$0 129 MOVV $64, R25 130 JMP gcWriteBarrier<>(SB)