github.com/primecitizens/pcz/std@v0.2.1/core/gc/wb_s390x.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 s390x
     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 R9, and returns a pointer
    16  // to the buffer space in R9.
    17  // It clobbers R10 (the temp register) and R1 (used by PLT stub).
    18  // It does not clobber any other general-purpose registers,
    19  // but may clobber others (e.g., floating point registers).
    20  TEXT gcWriteBarrier<>(SB),NOSPLIT,$96
    21  	// Save the registers clobbered by the fast path.
    22  	MOVD R4, 96(R15)
    23  retry:
    24  	MOVD g_m(g), R1
    25  	MOVD m_p(R1), R1
    26  	// Increment wbBuf.next position.
    27  	MOVD R9, R4
    28  	ADD (p_wbBuf+wbBuf_next)(R1), R4
    29  	// Is the buffer full?
    30  	MOVD (p_wbBuf+wbBuf_end)(R1), R10
    31  	CMPUBGT R4, R10, flush
    32  	// Commit to the larger buffer.
    33  	MOVD R4, (p_wbBuf+wbBuf_next)(R1)
    34  	// Make return value (the original next position)
    35  	SUB R9, R4, R9
    36  	// Restore registers.
    37  	MOVD 96(R15), R4
    38  	RET
    39  
    40  flush:
    41  	// Save all general purpose registers since these could be
    42  	// clobbered by wbBufFlush and were not saved by the caller.
    43  	STMG R2, R3, 8(R15)
    44  	MOVD R0, 24(R15)
    45  	// R1 already saved.
    46  	// R4 already saved.
    47  	STMG R5, R12, 32(R15) // save R5 - R12
    48  	// R13 is g.
    49  	// R14 is LR.
    50  	// R15 is SP.
    51  
    52  	CALL runtime·wbBufFlush(SB)
    53  
    54  	LMG 8(R15), R2, R3   // restore R2 - R3
    55  	MOVD 24(R15), R0      // restore R0
    56  	LMG 32(R15), R5, R12 // restore R5 - R12
    57  	JMP retry
    58  
    59  TEXT runtime·gcWriteBarrier1<ABIInternal>(SB),NOSPLIT,$0
    60  	MOVD $8, R9
    61  	JMP gcWriteBarrier<>(SB)
    62  TEXT runtime·gcWriteBarrier2<ABIInternal>(SB),NOSPLIT,$0
    63  	MOVD $16, R9
    64  	JMP gcWriteBarrier<>(SB)
    65  TEXT runtime·gcWriteBarrier3<ABIInternal>(SB),NOSPLIT,$0
    66  	MOVD $24, R9
    67  	JMP gcWriteBarrier<>(SB)
    68  TEXT runtime·gcWriteBarrier4<ABIInternal>(SB),NOSPLIT,$0
    69  	MOVD $32, R9
    70  	JMP gcWriteBarrier<>(SB)
    71  TEXT runtime·gcWriteBarrier5<ABIInternal>(SB),NOSPLIT,$0
    72  	MOVD $40, R9
    73  	JMP gcWriteBarrier<>(SB)
    74  TEXT runtime·gcWriteBarrier6<ABIInternal>(SB),NOSPLIT,$0
    75  	MOVD $48, R9
    76  	JMP gcWriteBarrier<>(SB)
    77  TEXT runtime·gcWriteBarrier7<ABIInternal>(SB),NOSPLIT,$0
    78  	MOVD $56, R9
    79  	JMP gcWriteBarrier<>(SB)
    80  TEXT runtime·gcWriteBarrier8<ABIInternal>(SB),NOSPLIT,$0
    81  	MOVD $64, R9
    82  	JMP gcWriteBarrier<>(SB)