Text file src/runtime/tls_arm64.s

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

View as plain text