aboutsummaryrefslogtreecommitdiffstats
path: root/src/alloc.c
diff options
context:
space:
mode:
authorPaul Eggert2015-12-12 19:27:51 -0800
committerPaul Eggert2015-12-12 19:28:53 -0800
commit09663d9b91803882508bd805581b95f8990eb441 (patch)
treea42fd5bacc97e94c2f60ee801cdc908b15b2df9a /src/alloc.c
parent95a5c23f741f42c6f68e283570cdce10b1946296 (diff)
downloademacs-09663d9b91803882508bd805581b95f8990eb441.tar.gz
emacs-09663d9b91803882508bd805581b95f8990eb441.zip
Fix performance regression with gcc -O0
This fixes the smaller performance hit that I noted in: https://lists.gnu.org/archive/html/emacs-devel/2015-12/msg00357.html * src/alloc.c (macro_XPNTR_OR_SYMBOL_OFFSET, macro_XPNTR): * src/puresize.h (puresize_h_PURE_P) (puresize_h_CHECK_IMPURE): New macros, with the old contents of the functions. * src/alloc.c (XPNTR_OR_SYMBOL_OFFSET, XPNTR): * src/puresize.h (PURE_P, CHECK_IMPURE): Use the new macros. Also macros, if DEFINE_KEY_OPS_AS_MACROS. * src/conf_post.h (ATTRIBUTE_UNUSED): * src/lisp.h (DEFINE_KEY_OPS_AS_MACROS): New macros.
Diffstat (limited to 'src/alloc.c')
-rw-r--r--src/alloc.c35
1 files changed, 24 insertions, 11 deletions
diff --git a/src/alloc.c b/src/alloc.c
index ea44c51d162..23ddd83d7d6 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -406,24 +406,37 @@ ALIGN (void *ptr, int alignment)
406 If A is a symbol, extract the hidden pointer's offset from lispsym, 406 If A is a symbol, extract the hidden pointer's offset from lispsym,
407 converted to void *. */ 407 converted to void *. */
408 408
409static void * 409#define macro_XPNTR_OR_SYMBOL_OFFSET(a) \
410XPNTR_OR_SYMBOL_OFFSET (Lisp_Object a) 410 ((void *) (intptr_t) (USE_LSB_TAG ? XLI (a) - XTYPE (a) : XLI (a) & VALMASK))
411{
412 intptr_t i = USE_LSB_TAG ? XLI (a) - XTYPE (a) : XLI (a) & VALMASK;
413 return (void *) i;
414}
415 411
416/* Extract the pointer hidden within A. */ 412/* Extract the pointer hidden within A. */
417 413
418static void * 414#define macro_XPNTR(a) \
415 ((void *) ((intptr_t) XPNTR_OR_SYMBOL_OFFSET (a) \
416 + (SYMBOLP (a) ? (char *) lispsym : NULL)))
417
418/* For pointer access, define XPNTR and XPNTR_OR_SYMBOL_OFFSET as
419 functions, as functions are cleaner and can be used in debuggers.
420 Also, define them as macros if being compiled with GCC without
421 optimization, for performance in that case. The macro_* names are
422 private to this section of code. */
423
424static ATTRIBUTE_UNUSED void *
425XPNTR_OR_SYMBOL_OFFSET (Lisp_Object a)
426{
427 return macro_XPNTR_OR_SYMBOL_OFFSET (a);
428}
429static ATTRIBUTE_UNUSED void *
419XPNTR (Lisp_Object a) 430XPNTR (Lisp_Object a)
420{ 431{
421 void *p = XPNTR_OR_SYMBOL_OFFSET (a); 432 return macro_XPNTR (a);
422 if (SYMBOLP (a))
423 p = (intptr_t) p + (char *) lispsym;
424 return p;
425} 433}
426 434
435#if DEFINE_KEY_OPS_AS_MACROS
436# define XPNTR_OR_SYMBOL_OFFSET(a) macro_XPNTR_OR_SYMBOL_OFFSET (a)
437# define XPNTR(a) macro_XPNTR (a)
438#endif
439
427static void 440static void
428XFLOAT_INIT (Lisp_Object f, double n) 441XFLOAT_INIT (Lisp_Object f, double n)
429{ 442{