...

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
     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.
    25TEXT runtime·save_g(SB),NOSPLIT|NOFRAME,$0-0
    26#ifndef GOOS_aix
    27#ifndef GOOS_openbsd
    28	MOVBZ	runtime·iscgo(SB), R31
    29	CMP	R31, $0
    30	BEQ	nocgo
    31#endif
    32#endif
    33	MOVD	runtime·tls_g(SB), R31
    34	MOVD	g, 0(R31)
    35
    36nocgo:
    37	RET
    38
    39// load_g loads the g register from pthread-provided
    40// thread-local memory, for use after calling externally compiled
    41// ppc64 code that overwrote those registers.
    42//
    43// This is never called directly from C code (it doesn't have to
    44// follow the C ABI), but it may be called from a C context, where the
    45// usual Go registers aren't set up.
    46//
    47// NOTE: _cgo_topofstack assumes this only clobbers g (R30), and R31.
    48TEXT runtime·load_g(SB),NOSPLIT|NOFRAME,$0-0
    49	MOVD	runtime·tls_g(SB), R31
    50	MOVD	0(R31), g
    51	RET
    52
    53GLOBL runtime·tls_g+0(SB), TLSBSS+DUPOK, $8

View as plain text