aboutsummaryrefslogtreecommitdiffstats
path: root/src/alloc.c
diff options
context:
space:
mode:
authorPaul Eggert2011-10-06 23:35:43 -0700
committerPaul Eggert2011-10-06 23:35:43 -0700
commit3164aeac1589cc7898634d8f9ea155a005576942 (patch)
tree8e95d742c24ce141b087e2d7f5e875776caedf01 /src/alloc.c
parentc9af454e51a926245a3ee19c04ae5ed058fcd215 (diff)
downloademacs-3164aeac1589cc7898634d8f9ea155a005576942.tar.gz
emacs-3164aeac1589cc7898634d8f9ea155a005576942.zip
* alloc.c (mark_memory): Omit 3rd (offset) arg; caller changed.
Don't assume EMACS_INT alignment is the same as pointer alignment. (GC_POINTER_ALIGNMENT): New macro.
Diffstat (limited to 'src/alloc.c')
-rw-r--r--src/alloc.c29
1 files changed, 16 insertions, 13 deletions
diff --git a/src/alloc.c b/src/alloc.c
index 100a5e593fa..18a248567a1 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -393,7 +393,7 @@ static int live_symbol_p (struct mem_node *, void *);
393static int live_float_p (struct mem_node *, void *); 393static int live_float_p (struct mem_node *, void *);
394static int live_misc_p (struct mem_node *, void *); 394static int live_misc_p (struct mem_node *, void *);
395static void mark_maybe_object (Lisp_Object); 395static void mark_maybe_object (Lisp_Object);
396static void mark_memory (void *, void *, int); 396static void mark_memory (void *, void *);
397static void mem_init (void); 397static void mem_init (void);
398static struct mem_node *mem_insert (void *, void *, enum mem_type); 398static struct mem_node *mem_insert (void *, void *, enum mem_type);
399static void mem_insert_fixup (struct mem_node *); 399static void mem_insert_fixup (struct mem_node *);
@@ -4236,14 +4236,20 @@ mark_maybe_pointer (void *p)
4236} 4236}
4237 4237
4238 4238
4239#ifndef GC_LISP_OBJECT_ALIGNMENT
4240# define GC_LISP_OBJECT_ALIGNMENT offsetof (struct {char a; Lisp_Object b;}, b)
4241#endif
4242#define GC_POINTER_ALIGNMENT offsetof (struct {char a; void *b;}, b)
4243
4239/* Mark Lisp objects referenced from the address range START+OFFSET..END 4244/* Mark Lisp objects referenced from the address range START+OFFSET..END
4240 or END+OFFSET..START. */ 4245 or END+OFFSET..START. */
4241 4246
4242static void 4247static void
4243mark_memory (void *start, void *end, int offset) 4248mark_memory (void *start, void *end)
4244{ 4249{
4245 Lisp_Object *p; 4250 Lisp_Object *p;
4246 void **pp; 4251 void **pp;
4252 int i;
4247 4253
4248#if GC_MARK_STACK == GC_USE_GCPROS_CHECK_ZOMBIES 4254#if GC_MARK_STACK == GC_USE_GCPROS_CHECK_ZOMBIES
4249 nzombies = 0; 4255 nzombies = 0;
@@ -4259,8 +4265,9 @@ mark_memory (void *start, void *end, int offset)
4259 } 4265 }
4260 4266
4261 /* Mark Lisp_Objects. */ 4267 /* Mark Lisp_Objects. */
4262 for (p = (Lisp_Object *) ((char *) start + offset); (void *) p < end; ++p) 4268 for (p = start; (void *) p < end; p++)
4263 mark_maybe_object (*p); 4269 for (i = 0; i < sizeof *p; i += GC_LISP_OBJECT_ALIGNMENT)
4270 mark_maybe_object (*(Lisp_Object *) ((char *) p + i));
4264 4271
4265 /* Mark Lisp data pointed to. This is necessary because, in some 4272 /* Mark Lisp data pointed to. This is necessary because, in some
4266 situations, the C compiler optimizes Lisp objects away, so that 4273 situations, the C compiler optimizes Lisp objects away, so that
@@ -4280,8 +4287,9 @@ mark_memory (void *start, void *end, int offset)
4280 away. The only reference to the life string is through the 4287 away. The only reference to the life string is through the
4281 pointer `s'. */ 4288 pointer `s'. */
4282 4289
4283 for (pp = (void **) ((char *) start + offset); (void *) pp < end; ++pp) 4290 for (pp = start; (void *) pp < end; pp++)
4284 mark_maybe_pointer (*pp); 4291 for (i = 0; i < sizeof *pp; i += GC_POINTER_ALIGNMENT)
4292 mark_maybe_pointer (*(void **) ((char *) pp + i));
4285} 4293}
4286 4294
4287/* setjmp will work with GCC unless NON_SAVING_SETJMP is defined in 4295/* setjmp will work with GCC unless NON_SAVING_SETJMP is defined in
@@ -4460,7 +4468,6 @@ dump_zombies (void)
4460static void 4468static void
4461mark_stack (void) 4469mark_stack (void)
4462{ 4470{
4463 int i;
4464 void *end; 4471 void *end;
4465 4472
4466#ifdef HAVE___BUILTIN_UNWIND_INIT 4473#ifdef HAVE___BUILTIN_UNWIND_INIT
@@ -4518,12 +4525,8 @@ mark_stack (void)
4518 /* This assumes that the stack is a contiguous region in memory. If 4525 /* This assumes that the stack is a contiguous region in memory. If
4519 that's not the case, something has to be done here to iterate 4526 that's not the case, something has to be done here to iterate
4520 over the stack segments. */ 4527 over the stack segments. */
4521#ifndef GC_LISP_OBJECT_ALIGNMENT 4528 mark_memory (stack_base, end);
4522# define GC_LISP_OBJECT_ALIGNMENT \ 4529
4523 offsetof (struct {char a; Lisp_Object b;}, b)
4524#endif
4525 for (i = 0; i < sizeof (Lisp_Object); i += GC_LISP_OBJECT_ALIGNMENT)
4526 mark_memory (stack_base, end, i);
4527 /* Allow for marking a secondary stack, like the register stack on the 4530 /* Allow for marking a secondary stack, like the register stack on the
4528 ia64. */ 4531 ia64. */
4529#ifdef GC_MARK_SECONDARY_STACK 4532#ifdef GC_MARK_SECONDARY_STACK