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