summaryrefslogtreecommitdiff
path: root/src/puresize.h
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2015-12-12 19:27:51 -0800
committerPaul Eggert <eggert@cs.ucla.edu>2015-12-12 19:28:53 -0800
commit09663d9b91803882508bd805581b95f8990eb441 (patch)
treea42fd5bacc97e94c2f60ee801cdc908b15b2df9a /src/puresize.h
parent95a5c23f741f42c6f68e283570cdce10b1946296 (diff)
downloademacs-09663d9b91803882508bd805581b95f8990eb441.tar.gz
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/puresize.h')
-rw-r--r--src/puresize.h20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/puresize.h b/src/puresize.h
index f07562429d5..96ddcde24a6 100644
--- a/src/puresize.h
+++ b/src/puresize.h
@@ -81,21 +81,35 @@ extern _Noreturn void pure_write_error (Lisp_Object);
extern EMACS_INT pure[];
+/* The puresize_h_* macros are private to this include file. */
+
/* True if PTR is pure. */
+
+#define puresize_h_PURE_P(ptr) \
+ ((uintptr_t) (ptr) - (uintptr_t) pure <= PURESIZE)
+
INLINE bool
PURE_P (void *ptr)
{
- return (uintptr_t) (ptr) - (uintptr_t) pure <= PURESIZE;
+ return puresize_h_PURE_P (ptr);
}
/* Signal an error if OBJ is pure. PTR is OBJ untagged. */
+
+#define puresize_h_CHECK_IMPURE(obj, ptr) \
+ (PURE_P (ptr) ? pure_write_error (obj) : (void) 0)
+
INLINE void
CHECK_IMPURE (Lisp_Object obj, void *ptr)
{
- if (PURE_P (ptr))
- pure_write_error (obj);
+ puresize_h_CHECK_IMPURE (obj, ptr);
}
+#if DEFINE_KEY_OPS_AS_MACROS
+# define PURE_P(ptr) puresize_h_PURE_P (ptr)
+# define CHECK_IMPURE(obj, ptr) puresize_h_CHECK_IMPURE (obj, ptr)
+#endif
+
INLINE_HEADER_END
#endif /* EMACS_PURESIZE_H */