From: Jakub Jelinek <jakub@redhat.com>
To: Ulrich Drepper <drepper@redhat.com>, Roland McGrath <roland@redhat.com>
Cc: Glibc hackers <libc-hacker@sources.redhat.com>
Subject: [PATCH] Save a few bytes in assembly for TLS accesses in assembly
Date: Wed, 26 Jan 2005 18:35:00 -0000 [thread overview]
Message-ID: <20050126183509.GP4777@sunsite.mff.cuni.cz> (raw)
Hi!
movl %edx, %gs:0(%ecx)
is one byte longer than
movl %edx, %gs(%ecx)
while it does the same thing. This is the first hunk (should save 151 bytes
in libc.so and 19 bytes in libpthread.so).
The other change is that sem_*.S seems to be really old and using the
GOTTPOFF reloc rather than GOTNTPOFF and of course no direct segment access.
This patch uses direct %gs access unless NO_TLS_DIRECT_SEG_REFS.
2005-01-26 Jakub Jelinek <jakub@redhat.com>
* sysdeps/unix/sysv/linux/i386/sysdep.h
(SYSCALL_ERROR_HANDLER_TLS_STORE): Remove unnecessary 0 imm.
nptl/
* sysdeps/unix/sysv/linux/i386/i486/sem_trywait.S (__new_sem_trywait):
Use direct %gs segment access or, if NO_TLS_DIRECT_SEG_REFS,
at least gotntpoff relocation and addition.
* sysdeps/unix/sysv/linux/i386/i486/sem_timedwait.S (sem_timedwait):
Likewise.
* sysdeps/unix/sysv/linux/i386/i486/sem_post.S (__new_sem_post):
Likewise.
* sysdeps/unix/sysv/linux/i386/i486/sem_wait.S (__new_sem_wait):
Likewise.
--- libc/sysdeps/unix/sysv/linux/i386/sysdep.h.jj 2005-01-26 11:53:41.000000000 +0100
+++ libc/sysdeps/unix/sysv/linux/i386/sysdep.h 2005-01-26 19:04:55.326699068 +0100
@@ -159,7 +159,7 @@ __i686.get_pc_thunk.reg: \
jmp L(pseudo_end);
# ifndef NO_TLS_DIRECT_SEG_REFS
# define SYSCALL_ERROR_HANDLER_TLS_STORE(src, destoff) \
- movl src, %gs:0(destoff)
+ movl src, %gs:(destoff)
# else
# define SYSCALL_ERROR_HANDLER_TLS_STORE(src, destoff) \
addl %gs:0, destoff; \
--- libc/nptl/sysdeps/unix/sysv/linux/i386/i486/sem_trywait.S.jj 2003-05-10 22:38:06.000000000 +0200
+++ libc/nptl/sysdeps/unix/sysv/linux/i386/i486/sem_trywait.S 2005-01-26 19:21:57.837106985 +0100
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+/* Copyright (C) 2002, 2003, 2005 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
@@ -55,9 +55,14 @@ __new_sem_trywait:
#endif
addl $_GLOBAL_OFFSET_TABLE_, %ecx
#if USE___THREAD
- movl %gs:0, %edx
- subl errno@gottpoff(%ecx), %edx
+# ifdef NO_TLS_DIRECT_SEG_REFS
+ movl errno@gotntpoff(%ecx), %edx
+ addl %gs:0, %edx
movl $EAGAIN, (%edx)
+# else
+ movl errno@gotntpoff(%ecx), %edx
+ movl $EAGAIN, %gs:(%edx)
+# endif
#else
call __errno_location@plt
movl $EAGAIN, (%eax)
--- libc/nptl/sysdeps/unix/sysv/linux/i386/i486/sem_timedwait.S.jj 2004-05-18 10:52:25.000000000 +0200
+++ libc/nptl/sysdeps/unix/sysv/linux/i386/i486/sem_timedwait.S 2005-01-26 19:21:21.495604255 +0100
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+/* Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
@@ -158,9 +158,14 @@ sem_timedwait:
#endif
addl $_GLOBAL_OFFSET_TABLE_, %ebx
#if USE___THREAD
- movl %gs:0, %edx
- subl errno@gottpoff(%ebx), %edx
+# ifdef NO_TLS_DIRECT_SEG_REFS
+ movl errno@gotntpoff(%ebx), %edx
+ addl %gs:0, %edx
movl %esi, (%edx)
+# else
+ movl errno@gotntpoff(%ebx), %edx
+ movl %esi, %gs:(%edx)
+# endif
#else
call __errno_location@plt
movl %esi, (%eax)
--- libc/nptl/sysdeps/unix/sysv/linux/i386/i486/sem_post.S.jj 2003-03-13 02:06:30.000000000 +0100
+++ libc/nptl/sysdeps/unix/sysv/linux/i386/i486/sem_post.S 2005-01-26 19:15:07.198438482 +0100
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+/* Copyright (C) 2002, 2003, 2005 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
@@ -65,9 +65,14 @@ __new_sem_post:
#endif
addl $_GLOBAL_OFFSET_TABLE_, %ebx
#if USE___THREAD
- movl %gs:0, %edx
- subl errno@gottpoff(%ebx), %edx
+# ifdef NO_TLS_DIRECT_SEG_REFS
+ movl errno@gotntpoff(%ebx), %edx
+ addl %gs:0, %edx
movl $EINVAL, (%edx)
+# else
+ movl errno@gotntpoff(%ebx), %edx
+ movl $EINVAL, %gs:(%edx)
+# endif
#else
call __errno_location@plt
movl $EINVAL, (%eax)
--- libc/nptl/sysdeps/unix/sysv/linux/i386/i486/sem_wait.S.jj 2003-07-08 23:06:32.000000000 +0200
+++ libc/nptl/sysdeps/unix/sysv/linux/i386/i486/sem_wait.S 2005-01-26 19:20:31.927468385 +0100
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+/* Copyright (C) 2002, 2003, 2005 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
@@ -102,9 +102,14 @@ __new_sem_wait:
#endif
addl $_GLOBAL_OFFSET_TABLE_, %ebx
#if USE___THREAD
- movl %gs:0, %edx
- subl errno@gottpoff(%ebx), %edx
+# ifdef NO_TLS_DIRECT_SEG_REFS
+ movl errno@gotntpoff(%ebx), %edx
+ addl %gs:0, %edx
movl %esi, (%edx)
+# else
+ movl errno@gotntpoff(%ebx), %edx
+ movl %esi, %gs:(%edx)
+# endif
#else
call __errno_location@plt
movl %esi, (%eax)
Jakub
reply other threads:[~2005-01-26 18:35 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20050126183509.GP4777@sunsite.mff.cuni.cz \
--to=jakub@redhat.com \
--cc=drepper@redhat.com \
--cc=libc-hacker@sources.redhat.com \
--cc=roland@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).