From 3d3923b79fe103ba66838db04aa9460cf990e565 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Wed, 18 Apr 2018 13:08:36 -0700 Subject: [PATCH] Tweak mark_object to avoid a conditional branch * 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 | 2 +- src/alloc.c | 9 ++------- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/etc/DEBUG b/etc/DEBUG index c4774b06d38..a7792952089 100644 --- 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 diff --git a/src/alloc.c b/src/alloc.c index 9fdcc7306a8..8264e0623cf 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -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 -- 2.39.2