emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] trunk r117030: Use bits_word for gcmarkbits.


From: Paul Eggert
Subject: [Emacs-diffs] trunk r117030: Use bits_word for gcmarkbits.
Date: Mon, 28 Apr 2014 16:59:45 +0000
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 117030
revision-id: address@hidden
parent: address@hidden
author: Paul Eggert  <address@hidden>
committer: Paul Eggert <address@hidden>
branch nick: trunk
timestamp: Mon 2014-04-28 09:59:41 -0700
message:
  Use bits_word for gcmarkbits.
  
  * alloc.c (struct cons_block, struct float_block): On 64-bit hosts,
  bits_word is typically a tad more efficient for mark bits than
  unsigned is, so use bits_word.  All uses changed.
  * lisp.h (BITS_PER_INT): Remove; no longer used.
modified:
  src/ChangeLog                  changelog-20091113204419-o5vbwnq5f7feedwu-1438
  src/alloc.c                    alloc.c-20091113204419-o5vbwnq5f7feedwu-252
  src/lisp.h                     lisp.h-20091113204419-o5vbwnq5f7feedwu-253
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2014-04-28 01:29:44 +0000
+++ b/src/ChangeLog     2014-04-28 16:59:41 +0000
@@ -1,5 +1,11 @@
 2014-04-28  Paul Eggert  <address@hidden>
 
+       Use bits_word for gcmarkbits.
+       * alloc.c (struct cons_block, struct float_block): On 64-bit hosts,
+       bits_word is typically a tad more efficient for mark bits than
+       unsigned is, so use bits_word.  All uses changed.
+       * lisp.h (BITS_PER_INT): Remove; no longer used.
+
        Avoid undefined behavior in signed left shift.
        This ports to GCC 4.9.0 with -fsanitize=undefined.
        * alloc.c (bool_vector_fill, SETMARKBIT, UNSETMARKBIT):

=== modified file 'src/alloc.c'
--- a/src/alloc.c       2014-04-28 01:29:44 +0000
+++ b/src/alloc.c       2014-04-28 16:59:41 +0000
@@ -2332,21 +2332,21 @@
 #define FLOAT_BLOCK_SIZE                                       \
   (((BLOCK_BYTES - sizeof (struct float_block *)               \
      /* The compiler might add padding at the end.  */         \
-     - (sizeof (struct Lisp_Float) - sizeof (int))) * CHAR_BIT) \
+     - (sizeof (struct Lisp_Float) - sizeof (bits_word))) * CHAR_BIT) \
    / (sizeof (struct Lisp_Float) * CHAR_BIT + 1))
 
 #define GETMARKBIT(block,n)                            \
-  (((block)->gcmarkbits[(n) / (sizeof (unsigned) * CHAR_BIT)]  \
-    >> ((n) % (sizeof (unsigned) * CHAR_BIT)))         \
+  (((block)->gcmarkbits[(n) / BITS_PER_BITS_WORD]      \
+    >> ((n) % BITS_PER_BITS_WORD))                     \
    & 1)
 
 #define SETMARKBIT(block,n)                            \
-  ((block)->gcmarkbits[(n) / (sizeof (unsigned) * CHAR_BIT)]   \
-   |= 1u << ((n) % (sizeof (unsigned) * CHAR_BIT)))
+  ((block)->gcmarkbits[(n) / BITS_PER_BITS_WORD]       \
+   |= (bits_word) 1 << ((n) % BITS_PER_BITS_WORD))
 
 #define UNSETMARKBIT(block,n)                          \
-  ((block)->gcmarkbits[(n) / (sizeof (unsigned) * CHAR_BIT)]   \
-   &= ~(1u << ((n) % (sizeof (unsigned) * CHAR_BIT))))
+  ((block)->gcmarkbits[(n) / BITS_PER_BITS_WORD]       \
+   &= ~((bits_word) 1 << ((n) % BITS_PER_BITS_WORD)))
 
 #define FLOAT_BLOCK(fptr) \
   ((struct float_block *) (((uintptr_t) (fptr)) & ~(BLOCK_ALIGN - 1)))
@@ -2358,7 +2358,7 @@
 {
   /* Place `floats' at the beginning, to ease up FLOAT_INDEX's job.  */
   struct Lisp_Float floats[FLOAT_BLOCK_SIZE];
-  unsigned gcmarkbits[1 + FLOAT_BLOCK_SIZE / (sizeof (unsigned) * CHAR_BIT)];
+  bits_word gcmarkbits[1 + FLOAT_BLOCK_SIZE / BITS_PER_BITS_WORD];
   struct float_block *next;
 };
 
@@ -2439,7 +2439,7 @@
 #define CONS_BLOCK_SIZE                                                \
   (((BLOCK_BYTES - sizeof (struct cons_block *)                        \
      /* The compiler might add padding at the end.  */         \
-     - (sizeof (struct Lisp_Cons) - sizeof (int))) * CHAR_BIT) \
+     - (sizeof (struct Lisp_Cons) - sizeof (bits_word))) * CHAR_BIT)   \
    / (sizeof (struct Lisp_Cons) * CHAR_BIT + 1))
 
 #define CONS_BLOCK(fptr) \
@@ -2452,7 +2452,7 @@
 {
   /* Place `conses' at the beginning, to ease up CONS_INDEX's job.  */
   struct Lisp_Cons conses[CONS_BLOCK_SIZE];
-  unsigned gcmarkbits[1 + CONS_BLOCK_SIZE / (sizeof (unsigned) * CHAR_BIT)];
+  bits_word gcmarkbits[1 + CONS_BLOCK_SIZE / BITS_PER_BITS_WORD];
   struct cons_block *next;
 };
 
@@ -6436,27 +6436,27 @@
 static void
 sweep_conses (void)
 {
-  register struct cons_block *cblk;
+  struct cons_block *cblk;
   struct cons_block **cprev = &cons_block;
-  register int lim = cons_block_index;
+  int lim = cons_block_index;
   EMACS_INT num_free = 0, num_used = 0;
 
   cons_free_list = 0;
 
   for (cblk = cons_block; cblk; cblk = *cprev)
     {
-      register int i = 0;
+      int i = 0;
       int this_free = 0;
-      int ilim = (lim + BITS_PER_INT - 1) / BITS_PER_INT;
+      int ilim = (lim + BITS_PER_BITS_WORD - 1) / BITS_PER_BITS_WORD;
 
       /* Scan the mark bits an int at a time.  */
       for (i = 0; i < ilim; i++)
         {
-          if (cblk->gcmarkbits[i] == -1)
+          if (cblk->gcmarkbits[i] == BITS_WORD_MAX)
             {
               /* Fast path - all cons cells for this int are marked.  */
               cblk->gcmarkbits[i] = 0;
-              num_used += BITS_PER_INT;
+              num_used += BITS_PER_BITS_WORD;
             }
           else
             {
@@ -6464,10 +6464,10 @@
                  Find which ones, and free them.  */
               int start, pos, stop;
 
-              start = i * BITS_PER_INT;
+              start = i * BITS_PER_BITS_WORD;
               stop = lim - start;
-              if (stop > BITS_PER_INT)
-                stop = BITS_PER_INT;
+              if (stop > BITS_PER_BITS_WORD)
+                stop = BITS_PER_BITS_WORD;
               stop += start;
 
               for (pos = start; pos < stop; pos++)

=== modified file 'src/lisp.h'
--- a/src/lisp.h        2014-04-28 01:29:44 +0000
+++ b/src/lisp.h        2014-04-28 16:59:41 +0000
@@ -115,7 +115,7 @@
 };
 
 /* An unsigned integer type representing a fixed-length bit sequence,
-   suitable for words in a Lisp bool vector.  Normally it is size_t
+   suitable for bool vector words, GC mark bits, etc.  Normally it is size_t
    for speed, but it is unsigned char on weird platforms.  */
 #if BOOL_VECTOR_BITS_PER_CHAR == CHAR_BIT
 typedef size_t bits_word;
@@ -133,7 +133,6 @@
   {
     BITS_PER_CHAR      = CHAR_BIT,
     BITS_PER_SHORT     = CHAR_BIT * sizeof (short),
-    BITS_PER_INT       = CHAR_BIT * sizeof (int),
     BITS_PER_LONG      = CHAR_BIT * sizeof (long int),
     BITS_PER_EMACS_INT = CHAR_BIT * sizeof (EMACS_INT)
   };


reply via email to

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