* src/alloc.c (mark_maybe_pointer): Also check wide-int's emacs_value

(mark_memory): Simplify loop.  Don't assume a pointer-sized word can be
cast to Lisp_Object.
This commit is contained in:
Stefan Monnier 2016-01-09 21:15:12 -05:00
parent cca0f93359
commit 09b2b8a5ce

View file

@ -4607,8 +4607,15 @@ mark_maybe_pointer (void *p)
VALGRIND_MAKE_MEM_DEFINED (&p, sizeof (p)); VALGRIND_MAKE_MEM_DEFINED (&p, sizeof (p));
#endif #endif
if (!maybe_lisp_pointer (p)) if (sizeof (Lisp_Object) == sizeof (void *) || !HAVE_MODULES)
return; {
if (!maybe_lisp_pointer (p))
return;
}
else
/* For the wide-int case, we also have to accept emacs_value "tagged
pointers", which can be generated by emacs-module.c's value_to_lisp. */
p = (void*)((uintptr_t) p & ~(GCALIGNMENT - 1));
m = mem_find (p); m = mem_find (p);
if (m != MEM_NIL) if (m != MEM_NIL)
@ -4685,8 +4692,7 @@ mark_maybe_pointer (void *p)
static void ATTRIBUTE_NO_SANITIZE_ADDRESS static void ATTRIBUTE_NO_SANITIZE_ADDRESS
mark_memory (void *start, void *end) mark_memory (void *start, void *end)
{ {
void **pp; char *pp;
int i;
/* Make START the pointer to the start of the memory region, /* Make START the pointer to the start of the memory region,
if it isn't already. */ if it isn't already. */
@ -4697,6 +4703,8 @@ mark_memory (void *start, void *end)
end = tem; end = tem;
} }
eassert (((uintptr_t) start) % GC_POINTER_ALIGNMENT == 0);
/* Mark Lisp data pointed to. This is necessary because, in some /* Mark Lisp data pointed to. This is necessary because, in some
situations, the C compiler optimizes Lisp objects away, so that situations, the C compiler optimizes Lisp objects away, so that
only a pointer to them remains. Example: only a pointer to them remains. Example:
@ -4715,13 +4723,11 @@ mark_memory (void *start, void *end)
away. The only reference to the life string is through the away. The only reference to the life string is through the
pointer `s'. */ pointer `s'. */
for (pp = start; (void *) pp < end; pp++) for (pp = start; (void*)pp < end; pp = pp + GC_POINTER_ALIGNMENT)
for (i = 0; i < sizeof *pp; i += GC_POINTER_ALIGNMENT) {
{ mark_maybe_pointer (*(void **) pp);
void *p = *(void **) ((char *) pp + i); mark_maybe_object (*(Lisp_Object *) pp);
mark_maybe_pointer (p); }
mark_maybe_object (XIL ((intptr_t) p));
}
} }
#if !defined GC_SAVE_REGISTERS_ON_STACK && !defined GC_SETJMP_WORKS #if !defined GC_SAVE_REGISTERS_ON_STACK && !defined GC_SETJMP_WORKS