github.com/primecitizens/pcz/std@v0.2.1/core/gc/wb_mipsx.s (about)

     1  // SPDX-License-Identifier: Apache-2.0
     2  // Copyright 2023 The Prime Citizens
     3  //
     4  // Copyright 2016 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 mips || mipsle
     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,$104
    22  	// Save the registers clobbered by the fast path.
    23  	MOVW R1, 100(R29)
    24  	MOVW R2, 104(R29)
    25  retry:
    26  	MOVW g_m(g), R1
    27  	MOVW m_p(R1), R1
    28  	MOVW (p_wbBuf+wbBuf_next)(R1), R2
    29  	MOVW (p_wbBuf+wbBuf_end)(R1), R23 // R23 is linker temp register
    30  	// Increment wbBuf.next position.
    31  	ADD R25, R2
    32  	// Is the buffer full?
    33  	SGTU R2, R23, R23
    34  	BNE R23, flush
    35  	// Commit to the larger buffer.
    36  	MOVW R2, (p_wbBuf+wbBuf_next)(R1)
    37  	// Make return value (the original next position)
    38  	SUB R25, R2, R25
    39  	// Restore registers.
    40  	MOVW 100(R29), R1
    41  	MOVW 104(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  	MOVW R20, 4(R29)
    48  	MOVW R21, 8(R29)
    49  	// R1 already saved
    50  	// R2 already saved
    51  	MOVW R3, 12(R29)
    52  	MOVW R4, 16(R29)
    53  	MOVW R5, 20(R29)
    54  	MOVW R6, 24(R29)
    55  	MOVW R7, 28(R29)
    56  	MOVW R8, 32(R29)
    57  	MOVW R9, 36(R29)
    58  	MOVW R10, 40(R29)
    59  	MOVW R11, 44(R29)
    60  	MOVW R12, 48(R29)
    61  	MOVW R13, 52(R29)
    62  	MOVW R14, 56(R29)
    63  	MOVW R15, 60(R29)
    64  	MOVW R16, 64(R29)
    65  	MOVW R17, 68(R29)
    66  	MOVW R18, 72(R29)
    67  	MOVW R19, 76(R29)
    68  	MOVW R20, 80(R29)
    69  	// R21 already saved
    70  	// R22 already saved.
    71  	MOVW R22, 84(R29)
    72  	// R23 is tmp register.
    73  	MOVW R24, 88(R29)
    74  	MOVW R25, 92(R29)
    75  	// R26 is reserved by kernel.
    76  	// R27 is reserved by kernel.
    77  	MOVW R28, 96(R29)
    78  	// R29 is SP.
    79  	// R30 is g.
    80  	// R31 is LR, which was saved by the prologue.
    81  
    82  	CALL runtime·wbBufFlush(SB)
    83  
    84  	MOVW 4(R29), R20
    85  	MOVW 8(R29), R21
    86  	MOVW 12(R29), R3
    87  	MOVW 16(R29), R4
    88  	MOVW 20(R29), R5
    89  	MOVW 24(R29), R6
    90  	MOVW 28(R29), R7
    91  	MOVW 32(R29), R8
    92  	MOVW 36(R29), R9
    93  	MOVW 40(R29), R10
    94  	MOVW 44(R29), R11
    95  	MOVW 48(R29), R12
    96  	MOVW 52(R29), R13
    97  	MOVW 56(R29), R14
    98  	MOVW 60(R29), R15
    99  	MOVW 64(R29), R16
   100  	MOVW 68(R29), R17
   101  	MOVW 72(R29), R18
   102  	MOVW 76(R29), R19
   103  	MOVW 80(R29), R20
   104  	MOVW 84(R29), R22
   105  	MOVW 88(R29), R24
   106  	MOVW 92(R29), R25
   107  	MOVW 96(R29), R28
   108  	JMP retry
   109  
   110  TEXT runtime·gcWriteBarrier1<ABIInternal>(SB),NOSPLIT,$0
   111  	MOVW $4, R25
   112  	JMP gcWriteBarrier<>(SB)
   113  TEXT runtime·gcWriteBarrier2<ABIInternal>(SB),NOSPLIT,$0
   114  	MOVW $8, R25
   115  	JMP gcWriteBarrier<>(SB)
   116  TEXT runtime·gcWriteBarrier3<ABIInternal>(SB),NOSPLIT,$0
   117  	MOVW $12, R25
   118  	JMP gcWriteBarrier<>(SB)
   119  TEXT runtime·gcWriteBarrier4<ABIInternal>(SB),NOSPLIT,$0
   120  	MOVW $16, R25
   121  	JMP gcWriteBarrier<>(SB)
   122  TEXT runtime·gcWriteBarrier5<ABIInternal>(SB),NOSPLIT,$0
   123  	MOVW $20, R25
   124  	JMP gcWriteBarrier<>(SB)
   125  TEXT runtime·gcWriteBarrier6<ABIInternal>(SB),NOSPLIT,$0
   126  	MOVW $24, R25
   127  	JMP gcWriteBarrier<>(SB)
   128  TEXT runtime·gcWriteBarrier7<ABIInternal>(SB),NOSPLIT,$0
   129  	MOVW $28, R25
   130  	JMP gcWriteBarrier<>(SB)
   131  TEXT runtime·gcWriteBarrier8<ABIInternal>(SB),NOSPLIT,$0
   132  	MOVW $32, R25
   133  	JMP gcWriteBarrier<>(SB)