diff options
| author | Paul Eggert | 2016-06-07 15:41:51 -0700 |
|---|---|---|
| committer | Paul Eggert | 2016-06-07 15:44:15 -0700 |
| commit | 302185156b6c20df5400a9956c09d6c24d29f652 (patch) | |
| tree | 7d8e87dd55aaec9df6775bb0cc903cfba72cfed9 /src | |
| parent | 8ea5d990f6315917bbd9c7b94856c52137405dad (diff) | |
| download | emacs-302185156b6c20df5400a9956c09d6c24d29f652.tar.gz emacs-302185156b6c20df5400a9956c09d6c24d29f652.zip | |
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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/conf_post.h | 14 | ||||
| -rw-r--r-- | src/lisp.h | 4 |
2 files changed, 17 insertions, 1 deletions
diff --git a/src/conf_post.h b/src/conf_post.h index bea2a8a587f..762aa7727fd 100644 --- a/src/conf_post.h +++ b/src/conf_post.h | |||
| @@ -64,6 +64,15 @@ typedef bool bool_bf; | |||
| 64 | (4 < __GNUC__ + (8 <= __GNUC_MINOR__)) | 64 | (4 < __GNUC__ + (8 <= __GNUC_MINOR__)) |
| 65 | #endif | 65 | #endif |
| 66 | 66 | ||
| 67 | /* Simulate __has_builtin on compilers that lack it. It is used only | ||
| 68 | on arguments like __builtin_assume_aligned that are handled in this | ||
| 69 | simulation. */ | ||
| 70 | #ifndef __has_builtin | ||
| 71 | # define __has_builtin(a) __has_builtin_##a | ||
| 72 | # define __has_builtin___builtin_assume_aligned \ | ||
| 73 | (4 < __GNUC__ + (7 <= __GNUC_MINOR__)) | ||
| 74 | #endif | ||
| 75 | |||
| 67 | /* Simulate __has_feature on compilers that lack it. It is used only | 76 | /* Simulate __has_feature on compilers that lack it. It is used only |
| 68 | to define ADDRESS_SANITIZER below. */ | 77 | to define ADDRESS_SANITIZER below. */ |
| 69 | #ifndef __has_feature | 78 | #ifndef __has_feature |
| @@ -77,6 +86,11 @@ typedef bool bool_bf; | |||
| 77 | # define ADDRESS_SANITIZER false | 86 | # define ADDRESS_SANITIZER false |
| 78 | #endif | 87 | #endif |
| 79 | 88 | ||
| 89 | /* Yield PTR, which must be aligned to ALIGNMENT. */ | ||
| 90 | #if ! __has_builtin (__builtin_assume_aligned) | ||
| 91 | # define __builtin_assume_aligned(ptr, alignment, ...) ((void *) (ptr)) | ||
| 92 | #endif | ||
| 93 | |||
| 80 | #ifdef DARWIN_OS | 94 | #ifdef DARWIN_OS |
| 81 | #ifdef emacs | 95 | #ifdef emacs |
| 82 | #define malloc unexec_malloc | 96 | #define malloc unexec_malloc |
diff --git a/src/lisp.h b/src/lisp.h index 1fc6130be0b..4042f4decb1 100644 --- a/src/lisp.h +++ b/src/lisp.h | |||
| @@ -341,7 +341,9 @@ error !; | |||
| 341 | (struct Lisp_Symbol *) ((intptr_t) XLI (a) - Lisp_Symbol \ | 341 | (struct Lisp_Symbol *) ((intptr_t) XLI (a) - Lisp_Symbol \ |
| 342 | + (char *) lispsym)) | 342 | + (char *) lispsym)) |
| 343 | # define lisp_h_XTYPE(a) ((enum Lisp_Type) (XLI (a) & ~VALMASK)) | 343 | # define lisp_h_XTYPE(a) ((enum Lisp_Type) (XLI (a) & ~VALMASK)) |
| 344 | # define lisp_h_XUNTAG(a, type) ((void *) (intptr_t) (XLI (a) - (type))) | 344 | # define lisp_h_XUNTAG(a, type) \ |
| 345 | __builtin_assume_aligned ((void *) (intptr_t) (XLI (a) - (type)), \ | ||
| 346 | GCALIGNMENT) | ||
| 345 | #endif | 347 | #endif |
| 346 | 348 | ||
| 347 | /* When compiling via gcc -O0, define the key operations as macros, as | 349 | /* When compiling via gcc -O0, define the key operations as macros, as |