Black Lives Matter. Support the Equal Justice Initiative.

Text file src/runtime/tls_ppc64x.s

Documentation: runtime

     1  // Copyright 2014 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  //go:build ppc64 || ppc64le
     6  // +build ppc64 ppc64le
     7  
     8  #include "go_asm.h"
     9  #include "go_tls.h"
    10  #include "funcdata.h"
    11  #include "textflag.h"
    12  
    13  // We have to resort to TLS variable to save g (R30).
    14  // One reason is that external code might trigger
    15  // SIGSEGV, and our runtime.sigtramp don't even know we
    16  // are in external code, and will continue to use R30,
    17  // this might well result in another SIGSEGV.
    18  
    19  // save_g saves the g register into pthread-provided
    20  // thread-local memory, so that we can call externally compiled
    21  // ppc64 code that will overwrite this register.
    22  //
    23  // If !iscgo, this is a no-op.
    24  //
    25  // NOTE: setg_gcc<> assume this clobbers only R31.
    26  TEXT runtime·save_g(SB),NOSPLIT|NOFRAME,$0-0
    27  #ifndef GOOS_aix
    28  	MOVBZ	runtime·iscgo(SB), R31
    29  	CMP	R31, $0
    30  	BEQ	nocgo
    31  #endif
    32  	MOVD	runtime·tls_g(SB), R31
    33  	MOVD	g, 0(R31)
    34  
    35  nocgo:
    36  	RET
    37  
    38  // load_g loads the g register from pthread-provided
    39  // thread-local memory, for use after calling externally compiled
    40  // ppc64 code that overwrote those registers.
    41  //
    42  // This is never called directly from C code (it doesn't have to
    43  // follow the C ABI), but it may be called from a C context, where the
    44  // usual Go registers aren't set up.
    45  //
    46  // NOTE: _cgo_topofstack assumes this only clobbers g (R30), and R31.
    47  TEXT runtime·load_g(SB),NOSPLIT|NOFRAME,$0-0
    48  	MOVD	runtime·tls_g(SB), R31
    49  	MOVD	0(R31), g
    50  	RET
    51  
    52  GLOBL runtime·tls_g+0(SB), TLSBSS+DUPOK, $8
    53  

View as plain text