emacs-devel
[Top][All Lists]
Advanced

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

Re: immediate strings #2


From: Stefan Monnier
Subject: Re: immediate strings #2
Date: Mon, 28 Nov 2011 12:33:26 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.91 (gnu/linux)

>  struct Lisp_String
>    {
> +    /* Text properties in this string.  */
> +    INTERVAL intervals;
> +
> +    /* Mark bit used for GC.  */
> +    unsigned gcmarkbit : 1;
> +
> +    /* String subtype.  */
> +    unsigned immbit : 1;
> +
> +    union {
> +
> +      /* When IMMBIT is 1. */
> +      struct {
> +     EMACS_INT size : 7;
> +     EMACS_INT size_byte : 7;
> +     unsigned char data[STRING_IMM_MAX];
> +      } imm;
> +      
> +      /* When IMMBIT is 0.  */
> +      struct {
> +     EMACS_INT size : BITS_PER_EMACS_INT - 1;
> +     EMACS_INT size_byte : BITS_PER_EMACS_INT - 1;
> +     unsigned char *data;
> +      } dat;
> +    } u;
>    };

I don't know any C compiler able to allocate unions at the bit level, so
the above struct will have the following layout:

   INTERVAL:  32
   gcmarkbit: 1
   immbit:    1
   <padding>: 30
   union:     96

I'm not sure about the layout of dat.size_byte, but I could even imagine
it straddling two words.  You need to move the immbit and gcmarkbit
into the union :-(

It's great to see that it can speed up compilation, tho (although
the 1.3% difference could just as well be due to noise).  You might want
to check what proportion of those strings have a NULL `intervals' field.
   

        Stefan



reply via email to

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