]> git.eshelyaron.com Git - emacs.git/commitdiff
Tweak mark_object to avoid a conditional branch
authorPaul Eggert <eggert@cs.ucla.edu>
Wed, 18 Apr 2018 20:08:36 +0000 (13:08 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Wed, 18 Apr 2018 20:15:26 +0000 (13:15 -0700)
* src/alloc.c (LAST_MARKED_SIZE): Now an enum.  Make it a power of 2.
(mark_object): Take advantage of the power of 2.

etc/DEBUG
src/alloc.c

index c4774b06d38f750362f8200b159630864ea18a54..a779295208904841f327c77b9b6e1efc2820e83c 100644 (file)
--- a/etc/DEBUG
+++ b/etc/DEBUG
@@ -814,7 +814,7 @@ the machine where you started GDB and use the debugger from there.
 ** Debugging problems which happen in GC
 
 The array 'last_marked' (defined on alloc.c) can be used to display up
-to 500 last objects marked by the garbage collection process.
+to the 512 most-recent objects marked by the garbage collection process.
 Whenever the garbage collector marks a Lisp object, it records the
 pointer to that object in the 'last_marked' array, which is maintained
 as a circular buffer.  The variable 'last_marked_index' holds the
index 9fdcc7306a844934bbdaf4886ce25db5fad2564c..8264e0623cf442ddafcad31a51df97bf0780a69c 100644 (file)
@@ -6188,11 +6188,7 @@ mark_glyph_matrix (struct glyph_matrix *matrix)
       }
 }
 
-/* Mark reference to a Lisp_Object.
-   If the object referred to has not been seen yet, recursively mark
-   all the references contained in it.  */
-
-#define LAST_MARKED_SIZE 500
+enum { LAST_MARKED_SIZE = 1 << 9 }; /* Must be a power of 2.  */
 Lisp_Object last_marked[LAST_MARKED_SIZE] EXTERNALLY_VISIBLE;
 static int last_marked_index;
 
@@ -6418,8 +6414,7 @@ mark_object (Lisp_Object arg)
     return;
 
   last_marked[last_marked_index++] = obj;
-  if (last_marked_index == LAST_MARKED_SIZE)
-    last_marked_index = 0;
+  last_marked_index &= LAST_MARKED_SIZE - 1;
 
   /* Perform some sanity checks on the objects marked here.  Abort if
      we encounter an object we know is bogus.  This increases GC time