aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert2012-05-09 10:51:30 -0700
committerPaul Eggert2012-05-09 10:51:30 -0700
commitb263a6b03bd58b811ac4f99aae7f37a0279528a9 (patch)
tree12faf8194bee0393c21dad562075e68911af873f /src
parent3478ec4554757213e8d2344826110cc0f4ae4f3c (diff)
downloademacs-b263a6b03bd58b811ac4f99aae7f37a0279528a9.tar.gz
emacs-b263a6b03bd58b811ac4f99aae7f37a0279528a9.zip
Untag more efficiently if USE_LSB_TAG.
This is based on a proposal by YAMAMOTO Mitsuharu in <http://lists.gnu.org/archive/html/emacs-devel/2008-01/msg01876.html>. For an admittedly artificial (nth 8000 longlist) benchmark on Fedora 15 x86-64, this yields a 25% CPU speedup. Also, it shrinks Emacs's overall text size by 1%. * lisp.h (XUNTAG): New macro. (XCONS, XVECTOR, XSTRING, XSYMBOL, XFLOAT, XMISC, XPROCESS, XWINDOW) (XTERMINAL, XSUBR, XBUFFER, XCHAR_TABLE, XSUB_CHAR_TABLE, XBOOL_VECTOR) (XSETTYPED_PSEUDOVECTOR, XHASH_TABLE, TYPED_PSEUDOVECTORP): Use it. * eval.c (Fautoload): * font.h (XFONT_SPEC, XFONT_ENTITY, XFONT_OBJECT): * frame.h (XFRAME): Use XUNTAG.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog14
-rw-r--r--src/eval.c2
-rw-r--r--src/font.h7
-rw-r--r--src/frame.h3
-rw-r--r--src/lisp.h59
5 files changed, 63 insertions, 22 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index b6415724b5e..e51d23435d1 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,19 @@
12012-05-09 Paul Eggert <eggert@cs.ucla.edu> 12012-05-09 Paul Eggert <eggert@cs.ucla.edu>
2 2
3 Untag more efficiently if USE_LSB_TAG.
4 This is based on a proposal by YAMAMOTO Mitsuharu in
5 <http://lists.gnu.org/archive/html/emacs-devel/2008-01/msg01876.html>.
6 For an admittedly artificial (nth 8000 longlist) benchmark on
7 Fedora 15 x86-64, this yields a 25% CPU speedup. Also, it shrinks
8 Emacs's overall text size by 1%.
9 * lisp.h (XUNTAG): New macro.
10 (XCONS, XVECTOR, XSTRING, XSYMBOL, XFLOAT, XMISC, XPROCESS, XWINDOW)
11 (XTERMINAL, XSUBR, XBUFFER, XCHAR_TABLE, XSUB_CHAR_TABLE, XBOOL_VECTOR)
12 (XSETTYPED_PSEUDOVECTOR, XHASH_TABLE, TYPED_PSEUDOVECTORP): Use it.
13 * eval.c (Fautoload):
14 * font.h (XFONT_SPEC, XFONT_ENTITY, XFONT_OBJECT):
15 * frame.h (XFRAME): Use XUNTAG.
16
3 Port recent dbusbind.c changes to 32-bit --with-wide-int. 17 Port recent dbusbind.c changes to 32-bit --with-wide-int.
4 * dbusbind.c (xd_append_arg, xd_retrieve_arg, Fdbus_message_internal): 18 * dbusbind.c (xd_append_arg, xd_retrieve_arg, Fdbus_message_internal):
5 Remove unportable assumptions about print widths of types like 19 Remove unportable assumptions about print widths of types like
diff --git a/src/eval.c b/src/eval.c
index cb0518f34ec..3d0e82c2d9f 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -2048,7 +2048,7 @@ this does nothing and returns nil. */)
2048 We used to use 0 here, but that leads to accidental sharing in 2048 We used to use 0 here, but that leads to accidental sharing in
2049 purecopy's hash-consing, so we use a (hopefully) unique integer 2049 purecopy's hash-consing, so we use a (hopefully) unique integer
2050 instead. */ 2050 instead. */
2051 docstring = make_number (XPNTR (function)); 2051 docstring = make_number (XUNTAG (function, Lisp_Symbol));
2052 return Ffset (function, 2052 return Ffset (function,
2053 Fpurecopy (list5 (Qautoload, file, docstring, 2053 Fpurecopy (list5 (Qautoload, file, docstring,
2054 interactive, type))); 2054 interactive, type)));
diff --git a/src/font.h b/src/font.h
index 663cc675c05..ea392d2e3fa 100644
--- a/src/font.h
+++ b/src/font.h
@@ -469,11 +469,12 @@ struct font_bitmap
469 } while (0) 469 } while (0)
470 470
471#define XFONT_SPEC(p) \ 471#define XFONT_SPEC(p) \
472 (eassert (FONT_SPEC_P(p)), (struct font_spec *) XPNTR (p)) 472 (eassert (FONT_SPEC_P (p)), (struct font_spec *) XUNTAG (p, Lisp_Vectorlike))
473#define XFONT_ENTITY(p) \ 473#define XFONT_ENTITY(p) \
474 (eassert (FONT_ENTITY_P(p)), (struct font_entity *) XPNTR (p)) 474 (eassert (FONT_ENTITY_P (p)), \
475 (struct font_entity *) XUNTAG (p, Lisp_Vectorlike))
475#define XFONT_OBJECT(p) \ 476#define XFONT_OBJECT(p) \
476 (eassert (FONT_OBJECT_P(p)), (struct font *) XPNTR (p)) 477 (eassert (FONT_OBJECT_P (p)), (struct font *) XUNTAG (p, Lisp_Vectorlike))
477#define XSETFONT(a, b) (XSETPSEUDOVECTOR (a, b, PVEC_FONT)) 478#define XSETFONT(a, b) (XSETPSEUDOVECTOR (a, b, PVEC_FONT))
478 479
479/* Number of pt per inch (from the TeXbook). */ 480/* Number of pt per inch (from the TeXbook). */
diff --git a/src/frame.h b/src/frame.h
index 5c89fc69628..9779f4a0926 100644
--- a/src/frame.h
+++ b/src/frame.h
@@ -501,7 +501,8 @@ struct frame
501 501
502typedef struct frame *FRAME_PTR; 502typedef struct frame *FRAME_PTR;
503 503
504#define XFRAME(p) (eassert (FRAMEP(p)),(struct frame *) XPNTR (p)) 504#define XFRAME(p) \
505 (eassert (FRAMEP (p)), (struct frame *) XUNTAG (p, Lisp_Vectorlike))
505#define XSETFRAME(a, b) (XSETPSEUDOVECTOR (a, b, PVEC_FRAME)) 506#define XSETFRAME(a, b) (XSETPSEUDOVECTOR (a, b, PVEC_FRAME))
506 507
507/* Given a window, return its frame as a Lisp_Object. */ 508/* Given a window, return its frame as a Lisp_Object. */
diff --git a/src/lisp.h b/src/lisp.h
index 1f839750609..6376862949a 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -475,6 +475,7 @@ enum pvec_type
475 (var) = (type) | (intptr_t) (ptr)) 475 (var) = (type) | (intptr_t) (ptr))
476 476
477#define XPNTR(a) ((intptr_t) ((a) & ~TYPEMASK)) 477#define XPNTR(a) ((intptr_t) ((a) & ~TYPEMASK))
478#define XUNTAG(a, type) ((intptr_t) ((a) - (type)))
478 479
479#else /* not USE_LSB_TAG */ 480#else /* not USE_LSB_TAG */
480 481
@@ -581,6 +582,13 @@ extern Lisp_Object make_number (EMACS_INT);
581# define XSETFASTINT(a, b) (XSETINT (a, b)) 582# define XSETFASTINT(a, b) (XSETINT (a, b))
582#endif 583#endif
583 584
585/* Extract the pointer value of the Lisp object A, under the
586 assumption that A's type is TYPE. This is a fallback
587 implementation if nothing faster is available. */
588#ifndef XUNTAG
589# define XUNTAG(a, type) XPNTR (a)
590#endif
591
584#define EQ(x, y) (XHASH (x) == XHASH (y)) 592#define EQ(x, y) (XHASH (x) == XHASH (y))
585 593
586/* Number of bits in a fixnum, including the sign bit. */ 594/* Number of bits in a fixnum, including the sign bit. */
@@ -607,15 +615,20 @@ extern Lisp_Object make_number (EMACS_INT);
607 615
608/* Extract a value or address from a Lisp_Object. */ 616/* Extract a value or address from a Lisp_Object. */
609 617
610#define XCONS(a) (eassert (CONSP (a)), (struct Lisp_Cons *) XPNTR (a)) 618#define XCONS(a) (eassert (CONSP (a)), \
611#define XVECTOR(a) (eassert (VECTORLIKEP (a)), (struct Lisp_Vector *) XPNTR (a)) 619 (struct Lisp_Cons *) XUNTAG (a, Lisp_Cons))
612#define XSTRING(a) (eassert (STRINGP (a)), (struct Lisp_String *) XPNTR (a)) 620#define XVECTOR(a) (eassert (VECTORLIKEP (a)), \
613#define XSYMBOL(a) (eassert (SYMBOLP (a)), (struct Lisp_Symbol *) XPNTR (a)) 621 (struct Lisp_Vector *) XUNTAG (a, Lisp_Vectorlike))
614#define XFLOAT(a) (eassert (FLOATP (a)), (struct Lisp_Float *) XPNTR (a)) 622#define XSTRING(a) (eassert (STRINGP (a)), \
623 (struct Lisp_String *) XUNTAG (a, Lisp_String))
624#define XSYMBOL(a) (eassert (SYMBOLP (a)), \
625 (struct Lisp_Symbol *) XUNTAG (a, Lisp_Symbol))
626#define XFLOAT(a) (eassert (FLOATP (a)), \
627 (struct Lisp_Float *) XUNTAG (a, Lisp_Float))
615 628
616/* Misc types. */ 629/* Misc types. */
617 630
618#define XMISC(a) ((union Lisp_Misc *) XPNTR (a)) 631#define XMISC(a) ((union Lisp_Misc *) XUNTAG (a, Lisp_Misc))
619#define XMISCANY(a) (eassert (MISCP (a)), &(XMISC (a)->u_any)) 632#define XMISCANY(a) (eassert (MISCP (a)), &(XMISC (a)->u_any))
620#define XMISCTYPE(a) (XMISCANY (a)->type) 633#define XMISCTYPE(a) (XMISCANY (a)->type)
621#define XMARKER(a) (eassert (MARKERP (a)), &(XMISC (a)->u_marker)) 634#define XMARKER(a) (eassert (MARKERP (a)), &(XMISC (a)->u_marker))
@@ -635,14 +648,24 @@ extern Lisp_Object make_number (EMACS_INT);
635 648
636/* Pseudovector types. */ 649/* Pseudovector types. */
637 650
638#define XPROCESS(a) (eassert (PROCESSP (a)), (struct Lisp_Process *) XPNTR (a)) 651#define XPROCESS(a) (eassert (PROCESSP (a)), \
639#define XWINDOW(a) (eassert (WINDOWP (a)), (struct window *) XPNTR (a)) 652 (struct Lisp_Process *) XUNTAG (a, Lisp_Vectorlike))
640#define XTERMINAL(a) (eassert (TERMINALP (a)), (struct terminal *) XPNTR (a)) 653#define XWINDOW(a) (eassert (WINDOWP (a)), \
641#define XSUBR(a) (eassert (SUBRP (a)), (struct Lisp_Subr *) XPNTR (a)) 654 (struct window *) XUNTAG (a, Lisp_Vectorlike))
642#define XBUFFER(a) (eassert (BUFFERP (a)), (struct buffer *) XPNTR (a)) 655#define XTERMINAL(a) (eassert (TERMINALP (a)), \
643#define XCHAR_TABLE(a) (eassert (CHAR_TABLE_P (a)), (struct Lisp_Char_Table *) XPNTR (a)) 656 (struct terminal *) XUNTAG (a, Lisp_Vectorlike))
644#define XSUB_CHAR_TABLE(a) (eassert (SUB_CHAR_TABLE_P (a)), (struct Lisp_Sub_Char_Table *) XPNTR (a)) 657#define XSUBR(a) (eassert (SUBRP (a)), \
645#define XBOOL_VECTOR(a) (eassert (BOOL_VECTOR_P (a)), (struct Lisp_Bool_Vector *) XPNTR (a)) 658 (struct Lisp_Subr *) XUNTAG (a, Lisp_Vectorlike))
659#define XBUFFER(a) (eassert (BUFFERP (a)), \
660 (struct buffer *) XUNTAG (a, Lisp_Vectorlike))
661#define XCHAR_TABLE(a) (eassert (CHAR_TABLE_P (a)), \
662 (struct Lisp_Char_Table *) XUNTAG (a, Lisp_Vectorlike))
663#define XSUB_CHAR_TABLE(a) (eassert (SUB_CHAR_TABLE_P (a)), \
664 ((struct Lisp_Sub_Char_Table *) \
665 XUNTAG (a, Lisp_Vectorlike)))
666#define XBOOL_VECTOR(a) (eassert (BOOL_VECTOR_P (a)), \
667 ((struct Lisp_Bool_Vector *) \
668 XUNTAG (a, Lisp_Vectorlike)))
646 669
647/* Construct a Lisp_Object from a value or address. */ 670/* Construct a Lisp_Object from a value or address. */
648 671
@@ -669,7 +692,9 @@ extern Lisp_Object make_number (EMACS_INT);
669/* The cast to struct vectorlike_header * avoids aliasing issues. */ 692/* The cast to struct vectorlike_header * avoids aliasing issues. */
670#define XSETPSEUDOVECTOR(a, b, code) \ 693#define XSETPSEUDOVECTOR(a, b, code) \
671 XSETTYPED_PSEUDOVECTOR(a, b, \ 694 XSETTYPED_PSEUDOVECTOR(a, b, \
672 ((struct vectorlike_header *) XPNTR (a))->size, \ 695 (((struct vectorlike_header *) \
696 XUNTAG (a, Lisp_Vectorlike)) \
697 ->size), \
673 code) 698 code)
674#define XSETTYPED_PSEUDOVECTOR(a, b, size, code) \ 699#define XSETTYPED_PSEUDOVECTOR(a, b, size, code) \
675 (XSETVECTOR (a, b), \ 700 (XSETVECTOR (a, b), \
@@ -1277,7 +1302,7 @@ struct Lisp_Hash_Table
1277 1302
1278 1303
1279#define XHASH_TABLE(OBJ) \ 1304#define XHASH_TABLE(OBJ) \
1280 ((struct Lisp_Hash_Table *) XPNTR (OBJ)) 1305 ((struct Lisp_Hash_Table *) XUNTAG (OBJ, Lisp_Vectorlike))
1281 1306
1282#define XSET_HASH_TABLE(VAR, PTR) \ 1307#define XSET_HASH_TABLE(VAR, PTR) \
1283 (XSETPSEUDOVECTOR (VAR, PTR, PVEC_HASH_TABLE)) 1308 (XSETPSEUDOVECTOR (VAR, PTR, PVEC_HASH_TABLE))
@@ -1735,7 +1760,7 @@ typedef struct {
1735 code is CODE. */ 1760 code is CODE. */
1736#define TYPED_PSEUDOVECTORP(x, t, code) \ 1761#define TYPED_PSEUDOVECTORP(x, t, code) \
1737 (VECTORLIKEP (x) \ 1762 (VECTORLIKEP (x) \
1738 && (((((struct t *) XPNTR (x))->size \ 1763 && (((((struct t *) XUNTAG (x, Lisp_Vectorlike))->size \
1739 & (PSEUDOVECTOR_FLAG | (code)))) \ 1764 & (PSEUDOVECTOR_FLAG | (code)))) \
1740 == (PSEUDOVECTOR_FLAG | (code)))) 1765 == (PSEUDOVECTOR_FLAG | (code))))
1741 1766