aboutsummaryrefslogtreecommitdiffstats
path: root/src/alloc.c
diff options
context:
space:
mode:
authorStefan Monnier2016-01-09 21:15:12 -0500
committerStefan Monnier2016-01-09 21:15:12 -0500
commit09b2b8a5ce5b542856f93b645db51eb11cf9855a (patch)
tree30b58f9c9fdad59bc3c6780412a45436c549d4e0 /src/alloc.c
parentcca0f933594a22a834ffae5475488a6066c584c1 (diff)
downloademacs-09b2b8a5ce5b542856f93b645db51eb11cf9855a.tar.gz
emacs-09b2b8a5ce5b542856f93b645db51eb11cf9855a.zip
* 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.
Diffstat (limited to 'src/alloc.c')
-rw-r--r--src/alloc.c28
1 files changed, 17 insertions, 11 deletions
diff --git a/src/alloc.c b/src/alloc.c
index 9ec44b8a2c3..e1b0d2e4a60 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -4607,8 +4607,15 @@ mark_maybe_pointer (void *p)
4607 VALGRIND_MAKE_MEM_DEFINED (&p, sizeof (p)); 4607 VALGRIND_MAKE_MEM_DEFINED (&p, sizeof (p));
4608#endif 4608#endif
4609 4609
4610 if (!maybe_lisp_pointer (p)) 4610 if (sizeof (Lisp_Object) == sizeof (void *) || !HAVE_MODULES)
4611 return; 4611 {
4612 if (!maybe_lisp_pointer (p))
4613 return;
4614 }
4615 else
4616 /* For the wide-int case, we also have to accept emacs_value "tagged
4617 pointers", which can be generated by emacs-module.c's value_to_lisp. */
4618 p = (void*)((uintptr_t) p & ~(GCALIGNMENT - 1));
4612 4619
4613 m = mem_find (p); 4620 m = mem_find (p);
4614 if (m != MEM_NIL) 4621 if (m != MEM_NIL)
@@ -4685,8 +4692,7 @@ mark_maybe_pointer (void *p)
4685static void ATTRIBUTE_NO_SANITIZE_ADDRESS 4692static void ATTRIBUTE_NO_SANITIZE_ADDRESS
4686mark_memory (void *start, void *end) 4693mark_memory (void *start, void *end)
4687{ 4694{
4688 void **pp; 4695 char *pp;
4689 int i;
4690 4696
4691 /* Make START the pointer to the start of the memory region, 4697 /* Make START the pointer to the start of the memory region,
4692 if it isn't already. */ 4698 if it isn't already. */
@@ -4697,6 +4703,8 @@ mark_memory (void *start, void *end)
4697 end = tem; 4703 end = tem;
4698 } 4704 }
4699 4705
4706 eassert (((uintptr_t) start) % GC_POINTER_ALIGNMENT == 0);
4707
4700 /* Mark Lisp data pointed to. This is necessary because, in some 4708 /* Mark Lisp data pointed to. This is necessary because, in some
4701 situations, the C compiler optimizes Lisp objects away, so that 4709 situations, the C compiler optimizes Lisp objects away, so that
4702 only a pointer to them remains. Example: 4710 only a pointer to them remains. Example:
@@ -4715,13 +4723,11 @@ mark_memory (void *start, void *end)
4715 away. The only reference to the life string is through the 4723 away. The only reference to the life string is through the
4716 pointer `s'. */ 4724 pointer `s'. */
4717 4725
4718 for (pp = start; (void *) pp < end; pp++) 4726 for (pp = start; (void*)pp < end; pp = pp + GC_POINTER_ALIGNMENT)
4719 for (i = 0; i < sizeof *pp; i += GC_POINTER_ALIGNMENT) 4727 {
4720 { 4728 mark_maybe_pointer (*(void **) pp);
4721 void *p = *(void **) ((char *) pp + i); 4729 mark_maybe_object (*(Lisp_Object *) pp);
4722 mark_maybe_pointer (p); 4730 }
4723 mark_maybe_object (XIL ((intptr_t) p));
4724 }
4725} 4731}
4726 4732
4727#if !defined GC_SAVE_REGISTERS_ON_STACK && !defined GC_SETJMP_WORKS 4733#if !defined GC_SAVE_REGISTERS_ON_STACK && !defined GC_SETJMP_WORKS