github.com/primecitizens/pcz/std@v0.2.1/core/stack/asm_riscv64.s (about)

     1  // SPDX-License-Identifier: Apache-2.0
     2  // Copyright 2023 The Prime Citizens
     3  //
     4  // Copyright 2017 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 pcz && riscv64
     9  
    10  #include "textflag.h"
    11  
    12  // X2 is the stack pointer
    13  
    14  TEXT ·GetSP<ABIInternal>(SB),NOSPLIT|NOFRAME,$0
    15  	MOVD X2, X10
    16  	RET
    17  
    18  TEXT ·SetSP<ABIInternal>(SB),NOSPLIT|NOFRAME,$0
    19  	MOVD X10, X2
    20  	RET
    21  
    22  // Called during function prolog when more stack is needed.
    23  // Called with return address (i.e. caller's PC) in X5 (aka T0),
    24  // and the LR register contains the caller's LR.
    25  //
    26  // The traceback routines see morestack on a g0 as being
    27  // the top of a stack (for example, morestack calling newstack
    28  // calling the scheduler calling newm calling gc), so we must
    29  // record an argument size. For that purpose, it has no arguments.
    30  TEXT runtime·morestack(SB),NOSPLIT|NOFRAME,$0-0
    31  	// TODO: implement
    32  	UNDEF // crash
    33  
    34  // morestack but not preserving ctxt.
    35  TEXT runtime·morestack_noctxt(SB),NOSPLIT|NOFRAME,$0-0
    36  	// Force SPWRITE. This function doesn't actually write SP,
    37  	// but it is called with a special calling convention where
    38  	// the caller doesn't save LR on stack but passes it as a
    39  	// register, and the unwinder currently doesn't understand.
    40  	// Make it SPWRITE to stop unwinding. (See issue 54332)
    41  	MOV X2, X2
    42  
    43  	MOV ZERO, CTXT
    44  	JMP runtime·morestack(SB)