This speeds up ‘make compile-always’ by 0.1% on my platform.
Suggested by Pip Cet in:
https://lists.gnu.org/r/emacs-devel/2019-07/msg00257.html
* src/.gdbinit (pwinx, pgx, xbuffer, xprintstr):
Output dead_object () as "DEAD".
* src/alloc.c (Vdead, DEADP): Remove.
All uses replaced by dead_object () / deadp.
(deadp): New function.
(init_alloc_once_for_pdumper): Remove no-longer-needed
initialization.
* src/lisp.h (dead_object): New function.
xgetptr $w->contents
set $tem = (struct buffer *) $ptr
xgetptr $tem->name_
- printf "%s", ((struct Lisp_String *) $ptr)->u.s.data
+ printf "%s", $ptr ? (char *) ((struct Lisp_String *) $ptr)->u.s.data : "DEAD"
printf "\n"
xgetptr $w->start
set $tem = (struct Lisp_Marker *) $ptr
xgettype ($g.object)
if ($type == Lisp_String)
xgetptr $g.object
- printf " str=0x%x[%d]", ((struct Lisp_String *)$ptr)->u.s.data, $g.charpos
+ if ($ptr)
+ printf " str=0x%x", ((struct Lisp_String *)$ptr)->u.s.data
+ else
+ printf " str=DEAD"
+ end
+ printf "[%d]", $g.charpos
else
printf " pos=%d", $g.charpos
end
xgetptr $
print (struct buffer *) $ptr
xgetptr $->name_
- output ((struct Lisp_String *) $ptr)->u.s.data
+ output $ptr ? (char *) ((struct Lisp_String *) $ptr)->u.s.data : "DEAD"
echo \n
end
document xbuffer
end
define xprintstr
- set $data = (char *) $arg0->u.s.data
- set $strsize = ($arg0->u.s.size_byte < 0) ? ($arg0->u.s.size & ~ARRAY_MARK_FLAG) : $arg0->u.s.size_byte
- # GDB doesn't like zero repetition counts
- if $strsize == 0
- output ""
+ if (! $arg0)
+ output "DEAD"
else
- output ($arg0->u.s.size > 1000) ? 0 : ($data[0])@($strsize)
+ set $data = (char *) $arg0->u.s.data
+ set $strsize = ($arg0->u.s.size_byte < 0) ? ($arg0->u.s.size & ~ARRAY_MARK_FLAG) : $arg0->u.s.size_byte
+ # GDB doesn't like zero repetition counts
+ if $strsize == 0
+ output ""
+ else
+ output ($arg0->u.s.size > 1000) ? 0 : ($data[0])@($strsize)
+ end
end
end
MEM_TYPE_SPARE
};
-/* A unique object in pure space used to make some Lisp objects
- on free lists recognizable in O(1). */
-
-#ifndef ENABLE_CHECKING
-static
-#endif
-Lisp_Object Vdead;
-#define DEADP(x) EQ (x, Vdead)
+static bool
+deadp (Lisp_Object x)
+{
+ return EQ (x, dead_object ());
+}
#ifdef GC_MALLOC_CHECK
static void mem_delete_fixup (struct mem_node *);
static struct mem_node *mem_find (void *);
-#ifndef DEADP
-# define DEADP(x) 0
-#endif
-
/* Addresses of staticpro'd variables. Initialize it to a nonzero
value if we might unexec; otherwise some compilers put it into
BSS. */
free_cons (struct Lisp_Cons *ptr)
{
ptr->u.s.u.chain = cons_free_list;
- ptr->u.s.car = Vdead;
+ ptr->u.s.car = dead_object ();
cons_free_list = ptr;
consing_since_gc -= sizeof *ptr;
gcstat.total_free_conses++;
{
cp = ptr_bounds_copy (cp, b);
struct Lisp_Cons *s = p = cp -= offset % sizeof b->conses[0];
- if (!EQ (s->u.s.car, Vdead))
+ if (!deadp (s->u.s.car))
return make_lisp_ptr (s, Lisp_Cons);
}
}
{
cp = ptr_bounds_copy (cp, b);
struct Lisp_Symbol *s = p = cp -= offset % sizeof b->symbols[0];
- if (!EQ (s->u.s.function, Vdead))
+ if (!deadp (s->u.s.function))
return make_lisp_symbol (s);
}
}
this_free++;
cblk->conses[pos].u.s.u.chain = cons_free_list;
cons_free_list = &cblk->conses[pos];
- cons_free_list->u.s.car = Vdead;
+ cons_free_list->u.s.car = dead_object ();
}
else
{
}
sym->u.s.next = symbol_free_list;
symbol_free_list = sym;
- symbol_free_list->u.s.function = Vdead;
+ symbol_free_list->u.s.function = dead_object ();
++this_free;
}
else
ptrdiff_t gc_count = inhibit_garbage_collection ();
Lisp_Object found = Qnil;
- if (! DEADP (obj))
+ if (! deadp (obj))
{
for (int i = 0; i < ARRAYELTS (lispsym); i++)
{
purebeg = PUREBEG;
pure_size = PURESIZE;
mem_init ();
- Vdead = make_pure_string ("DEAD", 4, 4, 0);
#ifdef DOUG_LEA_MALLOC
mallopt (M_TRIM_THRESHOLD, 128 * 1024); /* Trim threshold. */
#define XSETSYMBOL(a, b) ((a) = make_lisp_symbol (b))
#define XSETFLOAT(a, b) ((a) = make_lisp_ptr (b, Lisp_Float))
+/* Return a Lisp_Object value that does not correspond to any object.
+ This can make some Lisp objects on free lists recognizable in O(1). */
+
+INLINE Lisp_Object
+dead_object (void)
+{
+ return make_lisp_ptr (NULL, Lisp_String);
+}
+
/* Pseudovector types. */
#define XSETPVECTYPE(v, code) \
#ifdef HAVE_PDUMPER
extern int number_finalizers_run;
#endif
-#ifdef ENABLE_CHECKING
-extern Lisp_Object Vdead;
-#endif
extern Lisp_Object list1 (Lisp_Object);
extern Lisp_Object list2 (Lisp_Object, Lisp_Object);
extern Lisp_Object list3 (Lisp_Object, Lisp_Object, Lisp_Object);
#if CHECK_STRUCTS && !defined (HASH_Lisp_Type_E2AD97D3F7)
# error "Lisp_Type changed. See CHECK_STRUCTS comment in config.h."
#endif
-#ifdef ENABLE_CHECKING
- /* Vdead is extern only when ENABLE_CHECKING. */
- eassert (!EQ (object, Vdead));
-#endif
+ eassert (!EQ (object, dead_object ()));
dump_off offset = dump_recall_object (ctx, object);
if (offset > 0)