Text file src/runtime/tls_s390x.s

     1  // Copyright 2016 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  #include "go_asm.h"
     6  #include "go_tls.h"
     7  #include "funcdata.h"
     8  #include "textflag.h"
     9  
    10  // We have to resort to TLS variable to save g (R13).
    11  // One reason is that external code might trigger
    12  // SIGSEGV, and our runtime.sigtramp don't even know we
    13  // are in external code, and will continue to use R13,
    14  // this might well result in another SIGSEGV.
    15  
    16  // save_g saves the g register into pthread-provided
    17  // thread-local memory, so that we can call externally compiled
    18  // s390x code that will overwrite this register.
    19  //
    20  // If !iscgo, this is a no-op.
    21  //
    22  // NOTE: setg_gcc<> assume this clobbers only R10 and R11.
    23  TEXT runtime·save_g(SB),NOSPLIT|NOFRAME,$0-0
    24  	MOVB	runtime·iscgo(SB),  R10
    25  	CMPBEQ	R10, $0, nocgo
    26  	MOVW	AR0, R11
    27  	SLD	$32, R11
    28  	MOVW	AR1, R11
    29  	MOVD	runtime·tls_g(SB), R10
    30  	MOVD	g, 0(R10)(R11*1)
    31  nocgo:
    32  	RET
    33  
    34  // load_g loads the g register from pthread-provided
    35  // thread-local memory, for use after calling externally compiled
    36  // s390x code that overwrote those registers.
    37  //
    38  // This is never called directly from C code (it doesn't have to
    39  // follow the C ABI), but it may be called from a C context, where the
    40  // usual Go registers aren't set up.
    41  //
    42  // NOTE: _cgo_topofstack assumes this only clobbers g (R13), R10 and R11.
    43  TEXT runtime·load_g(SB),NOSPLIT|NOFRAME,$0-0
    44  	MOVW	AR0, R11
    45  	SLD	$32, R11
    46  	MOVW	AR1, R11
    47  	MOVD	runtime·tls_g(SB), R10
    48  	MOVD	0(R10)(R11*1), g
    49  	RET
    50  
    51  GLOBL runtime·tls_g+0(SB),TLSBSS,$8
    52  

View as plain text