github.com/geraldss/go/src@v0.0.0-20210511222824-ac7d0ebfc235/runtime/tls_arm64.s (about)

     1  // Copyright 2015 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  #include "tls_arm64.h"
    10  
    11  TEXT runtime·load_g(SB),NOSPLIT,$0
    12  #ifndef TLS_darwin
    13  #ifndef GOOS_openbsd
    14  	MOVB	runtime·iscgo(SB), R0
    15  	CBZ	R0, nocgo
    16  #endif
    17  #endif
    18  
    19  	MRS_TPIDR_R0
    20  #ifdef TLS_darwin
    21  	// Darwin sometimes returns unaligned pointers
    22  	AND	$0xfffffffffffffff8, R0
    23  #endif
    24  	MOVD	runtime·tls_g(SB), R27
    25  	MOVD	(R0)(R27), g
    26  
    27  nocgo:
    28  	RET
    29  
    30  TEXT runtime·save_g(SB),NOSPLIT,$0
    31  #ifndef TLS_darwin
    32  #ifndef GOOS_openbsd
    33  	MOVB	runtime·iscgo(SB), R0
    34  	CBZ	R0, nocgo
    35  #endif
    36  #endif
    37  
    38  	MRS_TPIDR_R0
    39  #ifdef TLS_darwin
    40  	// Darwin sometimes returns unaligned pointers
    41  	AND	$0xfffffffffffffff8, R0
    42  #endif
    43  	MOVD	runtime·tls_g(SB), R27
    44  	MOVD	g, (R0)(R27)
    45  
    46  nocgo:
    47  	RET
    48  
    49  #ifdef TLSG_IS_VARIABLE
    50  #ifdef GOOS_android
    51  // Use the free TLS_SLOT_APP slot #2 on Android Q.
    52  // Earlier androids are set up in gcc_android.c.
    53  DATA runtime·tls_g+0(SB)/8, $16
    54  #endif
    55  GLOBL runtime·tls_g+0(SB), NOPTR, $8
    56  #else
    57  GLOBL runtime·tls_g+0(SB), TLSBSS, $8
    58  #endif