emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Emacs-diffs] /srv/bzr/emacs/trunk r107377: * src/lisp.h: Improve co


From: YAMAMOTO Mitsuharu
Subject: Re: [Emacs-diffs] /srv/bzr/emacs/trunk r107377: * src/lisp.h: Improve comment about USE_LSB_TAG.
Date: Thu, 23 Feb 2012 12:57:36 +0900
User-agent: Wanderlust/2.14.0 (Africa) SEMI/1.14.6 (Maruoka) FLIM/1.14.8 (Shijō) APEL/10.6 Emacs/22.3 (sparc-sun-solaris2.8) MULE/5.0 (SAKAKI)

>>>>> On Wed, 22 Feb 2012 17:20:21 -0800, Paul Eggert <address@hidden> said:

> I'm pretty sure I'll get similar results with other benchmarks.  I
> don't see how USE_LSB_TAG could outperform !USE_LSB_TAG on my
> platform.


>> What kind of extra masking are you referring to?  The XFASTINT?
>> Note that the LSB masking can be cheaper than the MSB masking

> No, it's XPNTR that's faster, because its masking comes for free --
> zero runtime overhead on my platform.

Does "untagging by subtraction instead of masking" improve the
performance of USE_LSB_TAG in your platform?  The intention is to hide
the masking of XPNTR into the dereference and struct member access
that typically follow.

http://lists.gnu.org/archive/html/emacs-devel/2008-01/msg01876.html

The patch below is against Emacs 24.0.93.

                                     YAMAMOTO Mitsuharu
                                address@hidden

=== modified file 'src/font.h'
*** src/font.h  2012-01-19 07:21:25 +0000
--- src/font.h  2012-02-15 04:22:59 +0000
*************** struct font_bitmap
*** 469,479 ****
    } while (0)
  
  #define XFONT_SPEC(p) \
!   (eassert (FONT_SPEC_P(p)), (struct font_spec *) XPNTR (p))
  #define XFONT_ENTITY(p)       \
!   (eassert (FONT_ENTITY_P(p)), (struct font_entity *) XPNTR (p))
  #define XFONT_OBJECT(p)       \
!   (eassert (FONT_OBJECT_P(p)), (struct font *) XPNTR (p))
  #define XSETFONT(a, b) (XSETPSEUDOVECTOR (a, b, PVEC_FONT))
  
  /* Number of pt per inch (from the TeXbook).  */
--- 469,480 ----
    } while (0)
  
  #define XFONT_SPEC(p) \
!   (eassert (FONT_SPEC_P(p)), (struct font_spec *) XUNTAG (p, Lisp_Vectorlike))
  #define XFONT_ENTITY(p)       \
!   (eassert (FONT_ENTITY_P(p)), \
!    (struct font_entity *) XUNTAG (p, Lisp_Vectorlike))
  #define XFONT_OBJECT(p)       \
!   (eassert (FONT_OBJECT_P(p)), (struct font *) XUNTAG (p, Lisp_Vectorlike))
  #define XSETFONT(a, b) (XSETPSEUDOVECTOR (a, b, PVEC_FONT))
  
  /* Number of pt per inch (from the TeXbook).  */

=== modified file 'src/frame.h'
*** src/frame.h 2012-01-19 07:21:25 +0000
--- src/frame.h 2012-02-01 12:37:39 +0000
*************** struct frame
*** 501,507 ****
  
  typedef struct frame *FRAME_PTR;
  
! #define XFRAME(p) (eassert (FRAMEP(p)),(struct frame *) XPNTR (p))
  #define XSETFRAME(a, b) (XSETPSEUDOVECTOR (a, b, PVEC_FRAME))
  
  /* Given a window, return its frame as a Lisp_Object.  */
--- 505,512 ----
  
  typedef struct frame *FRAME_PTR;
  
! #define XFRAME(p) (eassert (FRAMEP(p)), \
!                  (struct frame *) XUNTAG (p, Lisp_Vectorlike))
  #define XSETFRAME(a, b) (XSETPSEUDOVECTOR (a, b, PVEC_FRAME))
  
  /* Given a window, return its frame as a Lisp_Object.  */

=== modified file 'src/lisp.h'
*** src/lisp.h  2012-01-19 07:21:25 +0000
--- src/lisp.h  2012-02-23 03:46:12 +0000
*************** enum pvec_type
*** 469,474 ****
--- 469,475 ----
       (var) = (type) | (intptr_t) (ptr))
  
  #define XPNTR(a) ((intptr_t) ((a) & ~TYPEMASK))
+ #define XUNTAG(a, type) ((uintptr_t) (a) - (type))
  
  #else  /* not USE_LSB_TAG */
  
*************** enum pvec_type
*** 511,516 ****
--- 512,518 ----
  #else
  #define XPNTR(a) ((uintptr_t) ((a) & VALMASK))
  #endif
+ #define XUNTAG(a, type) XPNTR (a)
  
  #endif /* not USE_LSB_TAG */
  
*************** extern Lisp_Object make_number (EMACS_IN
*** 601,615 ****
  
  /* Extract a value or address from a Lisp_Object.  */
  
! #define XCONS(a) (eassert (CONSP (a)), (struct Lisp_Cons *) XPNTR (a))
! #define XVECTOR(a) (eassert (VECTORLIKEP (a)), (struct Lisp_Vector *) XPNTR 
(a))
! #define XSTRING(a) (eassert (STRINGP (a)), (struct Lisp_String *) XPNTR (a))
! #define XSYMBOL(a) (eassert (SYMBOLP (a)), (struct Lisp_Symbol *) XPNTR (a))
! #define XFLOAT(a) (eassert (FLOATP (a)), (struct Lisp_Float *) XPNTR (a))
  
  /* Misc types.  */
  
! #define XMISC(a)   ((union Lisp_Misc *) XPNTR (a))
  #define XMISCANY(a)   (eassert (MISCP (a)), &(XMISC (a)->u_any))
  #define XMISCTYPE(a)   (XMISCANY (a)->type)
  #define XMARKER(a)    (eassert (MARKERP (a)), &(XMISC (a)->u_marker))
--- 603,622 ----
  
  /* Extract a value or address from a Lisp_Object.  */
  
! #define XCONS(a) (eassert (CONSP(a)), \
!                 (struct Lisp_Cons *) XUNTAG (a, Lisp_Cons))
! #define XVECTOR(a) (eassert (VECTORLIKEP(a)), \
!                   (struct Lisp_Vector *) XUNTAG (a, Lisp_Vectorlike))
! #define XSTRING(a) (eassert (STRINGP(a)), \
!                   (struct Lisp_String *) XUNTAG (a, Lisp_String))
! #define XSYMBOL(a) (eassert (SYMBOLP(a)), \
!                   (struct Lisp_Symbol *) XUNTAG (a, Lisp_Symbol))
! #define XFLOAT(a) (eassert (FLOATP(a)), \
!                  (struct Lisp_Float *) XUNTAG (a, Lisp_Float))
  
  /* Misc types.  */
  
! #define XMISC(a)   ((union Lisp_Misc *) XUNTAG (a, Lisp_Misc))
  #define XMISCANY(a)   (eassert (MISCP (a)), &(XMISC (a)->u_any))
  #define XMISCTYPE(a)   (XMISCANY (a)->type)
  #define XMARKER(a)    (eassert (MARKERP (a)), &(XMISC (a)->u_marker))
*************** extern Lisp_Object make_number (EMACS_IN
*** 629,642 ****
  
  /* Pseudovector types.  */
  
! #define XPROCESS(a) (eassert (PROCESSP (a)), (struct Lisp_Process *) XPNTR 
(a))
! #define XWINDOW(a) (eassert (WINDOWP (a)), (struct window *) XPNTR (a))
! #define XTERMINAL(a) (eassert (TERMINALP (a)), (struct terminal *) XPNTR (a))
! #define XSUBR(a) (eassert (SUBRP (a)), (struct Lisp_Subr *) XPNTR (a))
! #define XBUFFER(a) (eassert (BUFFERP (a)), (struct buffer *) XPNTR (a))
! #define XCHAR_TABLE(a) (eassert (CHAR_TABLE_P (a)), (struct Lisp_Char_Table 
*) XPNTR (a))
! #define XSUB_CHAR_TABLE(a) (eassert (SUB_CHAR_TABLE_P (a)), (struct 
Lisp_Sub_Char_Table *) XPNTR (a))
! #define XBOOL_VECTOR(a) (eassert (BOOL_VECTOR_P (a)), (struct 
Lisp_Bool_Vector *) XPNTR (a))
  
  /* Construct a Lisp_Object from a value or address.  */
  
--- 636,657 ----
  
  /* Pseudovector types.  */
  
! #define XPROCESS(a) (eassert (PROCESSP(a)), \
!                    (struct Lisp_Process *) XUNTAG (a, Lisp_Vectorlike))
! #define XWINDOW(a) (eassert (WINDOWP(a)), \
!                   (struct window *) XUNTAG (a, Lisp_Vectorlike))
! #define XTERMINAL(a) (eassert (TERMINALP(a)), \
!                     (struct terminal *) XUNTAG (a, Lisp_Vectorlike))
! #define XSUBR(a) (eassert (SUBRP(a)), \
!                 (struct Lisp_Subr *) XUNTAG (a, Lisp_Vectorlike))
! #define XBUFFER(a) (eassert (BUFFERP(a)), \
!                   (struct buffer *) XUNTAG (a, Lisp_Vectorlike))
! #define XCHAR_TABLE(a) (eassert (CHAR_TABLE_P (a)), \
!                       (struct Lisp_Char_Table *) XUNTAG (a, Lisp_Vectorlike))
! #define XSUB_CHAR_TABLE(a) (eassert (SUB_CHAR_TABLE_P (a)), \
!                           (struct Lisp_Sub_Char_Table *) XUNTAG (a, 
Lisp_Vectorlike))
! #define XBOOL_VECTOR(a) (eassert (BOOL_VECTOR_P (a)), \
!                        (struct Lisp_Bool_Vector *) XUNTAG (a, 
Lisp_Vectorlike))
  
  /* Construct a Lisp_Object from a value or address.  */
  
*************** extern Lisp_Object make_number (EMACS_IN
*** 663,669 ****
  /* The cast to struct vectorlike_header * avoids aliasing issues.  */
  #define XSETPSEUDOVECTOR(a, b, code) \
    XSETTYPED_PSEUDOVECTOR(a, b,       \
!                        ((struct vectorlike_header *) XPNTR (a))->size, \
                         code)
  #define XSETTYPED_PSEUDOVECTOR(a, b, size, code)                      \
    (XSETVECTOR (a, b),                                                 \
--- 678,684 ----
  /* The cast to struct vectorlike_header * avoids aliasing issues.  */
  #define XSETPSEUDOVECTOR(a, b, code) \
    XSETTYPED_PSEUDOVECTOR(a, b,       \
!                        ((struct vectorlike_header *) XUNTAG (a, 
Lisp_Vectorlike))->size, \
                         code)
  #define XSETTYPED_PSEUDOVECTOR(a, b, size, code)                      \
    (XSETVECTOR (a, b),                                                 \
*************** struct Lisp_Hash_Table
*** 1271,1277 ****
  
  
  #define XHASH_TABLE(OBJ) \
!      ((struct Lisp_Hash_Table *) XPNTR (OBJ))
  
  #define XSET_HASH_TABLE(VAR, PTR) \
       (XSETPSEUDOVECTOR (VAR, PTR, PVEC_HASH_TABLE))
--- 1286,1292 ----
  
  
  #define XHASH_TABLE(OBJ) \
!      ((struct Lisp_Hash_Table *) XUNTAG (OBJ, Lisp_Vectorlike))
  
  #define XSET_HASH_TABLE(VAR, PTR) \
       (XSETPSEUDOVECTOR (VAR, PTR, PVEC_HASH_TABLE))
*************** typedef struct {
*** 1738,1744 ****
     code is CODE.  */
  #define TYPED_PSEUDOVECTORP(x, t, code)                               \
    (VECTORLIKEP (x)                                            \
!    && (((((struct t *) XPNTR (x))->size                               \
         & (PSEUDOVECTOR_FLAG | (code))))                       \
         == (PSEUDOVECTOR_FLAG | (code))))
  
--- 1763,1769 ----
     code is CODE.  */
  #define TYPED_PSEUDOVECTORP(x, t, code)                               \
    (VECTORLIKEP (x)                                            \
!    && (((((struct t *) XUNTAG (x, Lisp_Vectorlike))->size     \
         & (PSEUDOVECTOR_FLAG | (code))))                       \
         == (PSEUDOVECTOR_FLAG | (code))))
  




reply via email to

[Prev in Thread] Current Thread [Next in Thread]