4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
22 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
26 .file "tls_get_addr.s"
29 * To make thread-local storage accesses as fast as possible, we
30 * hand-craft the __tls_get_addr() function below, from this C code:
32 * __tls_get_addr(TLS_index *tls_index)
34 * ulwp_t *self = curthread;
35 * tls_t *tlsent = self->ul_tlsent;
39 * if ((moduleid = tls_index->ti_moduleid) < self->ul_ntlsent &&
40 * (base = tlsent[moduleid].tls_data) != NULL)
41 * return (base + tls_index->ti_tlsoffset);
43 * return (slow_tls_get_addr(tls_index));
46 * ___tls_get_addr() is identical to __tls_get_addr() except that it
47 * assumes its argument is passed in %eax rather than on the stack.
53 ENTRY_NP
(__tls_get_addr
)
54 ALTENTRY
(___tls_get_addr
)
55 movq
%fs:UL_TLSENT
, %rax
56 movq TI_MODULEID
(%rdi
), %rdx
57 cmpq
%fs:UL_NTLSENT
, %rdx
58 jae slow_tls_get_addr
/* tail call */
59 /* movq TLS_DATA (%rax,%rdx,SIZEOF_TLS_T), %rax */
60 shlq $
4, %rdx
/* SIZEOF_TLS_T == 16 */
61 movq TLS_DATA
(%rax
,%rdx
), %rax
63 je slow_tls_get_addr
/* tail call */
64 addq TI_TLSOFFSET
(%rdi
), %rax
66 SET_SIZE
(___tls_get_addr
)
67 SET_SIZE
(__tls_get_addr
)