[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master 3021851: Use __builtin_assume_aligned on untagged L
From: |
Paul Eggert |
Subject: |
[Emacs-diffs] master 3021851: Use __builtin_assume_aligned on untagged Lisp vals |
Date: |
Tue, 7 Jun 2016 22:44:18 +0000 (UTC) |
branch: master
commit 302185156b6c20df5400a9956c09d6c24d29f652
Author: Paul Eggert <address@hidden>
Commit: Paul Eggert <address@hidden>
Use __builtin_assume_aligned on untagged Lisp vals
* src/conf_post.h (__has_builtin, __builtin_assume_aligned):
New macros, for compilers not already defining them.
(__has_builtin___builtin_assume_aligned): New macro.
* src/lisp.h (lisp_h_XUNTAG): Use __builtin_assume_aligned.
This shrinks text space by 0.2% on x86-64 with GCC 6.1.
---
src/conf_post.h | 14 ++++++++++++++
src/lisp.h | 4 +++-
2 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/src/conf_post.h b/src/conf_post.h
index bea2a8a..762aa77 100644
--- a/src/conf_post.h
+++ b/src/conf_post.h
@@ -64,6 +64,15 @@ typedef bool bool_bf;
(4 < __GNUC__ + (8 <= __GNUC_MINOR__))
#endif
+/* Simulate __has_builtin on compilers that lack it. It is used only
+ on arguments like __builtin_assume_aligned that are handled in this
+ simulation. */
+#ifndef __has_builtin
+# define __has_builtin(a) __has_builtin_##a
+# define __has_builtin___builtin_assume_aligned \
+ (4 < __GNUC__ + (7 <= __GNUC_MINOR__))
+#endif
+
/* Simulate __has_feature on compilers that lack it. It is used only
to define ADDRESS_SANITIZER below. */
#ifndef __has_feature
@@ -77,6 +86,11 @@ typedef bool bool_bf;
# define ADDRESS_SANITIZER false
#endif
+/* Yield PTR, which must be aligned to ALIGNMENT. */
+#if ! __has_builtin (__builtin_assume_aligned)
+# define __builtin_assume_aligned(ptr, alignment, ...) ((void *) (ptr))
+#endif
+
#ifdef DARWIN_OS
#ifdef emacs
#define malloc unexec_malloc
diff --git a/src/lisp.h b/src/lisp.h
index 1fc6130..4042f4d 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -341,7 +341,9 @@ error !;
(struct Lisp_Symbol *) ((intptr_t) XLI (a) - Lisp_Symbol \
+ (char *) lispsym))
# define lisp_h_XTYPE(a) ((enum Lisp_Type) (XLI (a) & ~VALMASK))
-# define lisp_h_XUNTAG(a, type) ((void *) (intptr_t) (XLI (a) - (type)))
+# define lisp_h_XUNTAG(a, type) \
+ __builtin_assume_aligned ((void *) (intptr_t) (XLI (a) - (type)), \
+ GCALIGNMENT)
#endif
/* When compiling via gcc -O0, define the key operations as macros, as
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] master 3021851: Use __builtin_assume_aligned on untagged Lisp vals,
Paul Eggert <=