comparison src/alloc.c @ 73964:b684c6771753

(mark_memory): New argument OFFSET. All uses changed. Fix address calculations for case END < START. (mark_stack): Impose Lisp_Object alignment on jmp_buf.
author YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
date Mon, 13 Nov 2006 08:20:28 +0000
parents 07b45e10e844
children a62f8b0494a2 c71725faff1a dbe3f29e61d6
comparison
equal deleted inserted replaced
73963:4ccb00e24c09 73964:b684c6771753
476 static int live_cons_p P_ ((struct mem_node *, void *)); 476 static int live_cons_p P_ ((struct mem_node *, void *));
477 static int live_symbol_p P_ ((struct mem_node *, void *)); 477 static int live_symbol_p P_ ((struct mem_node *, void *));
478 static int live_float_p P_ ((struct mem_node *, void *)); 478 static int live_float_p P_ ((struct mem_node *, void *));
479 static int live_misc_p P_ ((struct mem_node *, void *)); 479 static int live_misc_p P_ ((struct mem_node *, void *));
480 static void mark_maybe_object P_ ((Lisp_Object)); 480 static void mark_maybe_object P_ ((Lisp_Object));
481 static void mark_memory P_ ((void *, void *)); 481 static void mark_memory P_ ((void *, void *, int));
482 static void mem_init P_ ((void)); 482 static void mem_init P_ ((void));
483 static struct mem_node *mem_insert P_ ((void *, void *, enum mem_type)); 483 static struct mem_node *mem_insert P_ ((void *, void *, enum mem_type));
484 static void mem_insert_fixup P_ ((struct mem_node *)); 484 static void mem_insert_fixup P_ ((struct mem_node *));
485 static void mem_rotate_left P_ ((struct mem_node *)); 485 static void mem_rotate_left P_ ((struct mem_node *));
486 static void mem_rotate_right P_ ((struct mem_node *)); 486 static void mem_rotate_right P_ ((struct mem_node *));
4325 mark_object (obj); 4325 mark_object (obj);
4326 } 4326 }
4327 } 4327 }
4328 4328
4329 4329
4330 /* Mark Lisp objects referenced from the address range START..END. */ 4330 /* Mark Lisp objects referenced from the address range START+OFFSET..END
4331 or END+OFFSET..START. */
4331 4332
4332 static void 4333 static void
4333 mark_memory (start, end) 4334 mark_memory (start, end, offset)
4334 void *start, *end; 4335 void *start, *end;
4336 int offset;
4335 { 4337 {
4336 Lisp_Object *p; 4338 Lisp_Object *p;
4337 void **pp; 4339 void **pp;
4338 4340
4339 #if GC_MARK_STACK == GC_USE_GCPROS_CHECK_ZOMBIES 4341 #if GC_MARK_STACK == GC_USE_GCPROS_CHECK_ZOMBIES
4348 start = end; 4350 start = end;
4349 end = tem; 4351 end = tem;
4350 } 4352 }
4351 4353
4352 /* Mark Lisp_Objects. */ 4354 /* Mark Lisp_Objects. */
4353 for (p = (Lisp_Object *) start; (void *) p < end; ++p) 4355 for (p = (Lisp_Object *) ((char *) start + offset); (void *) p < end; ++p)
4354 mark_maybe_object (*p); 4356 mark_maybe_object (*p);
4355 4357
4356 /* Mark Lisp data pointed to. This is necessary because, in some 4358 /* Mark Lisp data pointed to. This is necessary because, in some
4357 situations, the C compiler optimizes Lisp objects away, so that 4359 situations, the C compiler optimizes Lisp objects away, so that
4358 only a pointer to them remains. Example: 4360 only a pointer to them remains. Example:
4369 4371
4370 Here, `obj' isn't really used, and the compiler optimizes it 4372 Here, `obj' isn't really used, and the compiler optimizes it
4371 away. The only reference to the life string is through the 4373 away. The only reference to the life string is through the
4372 pointer `s'. */ 4374 pointer `s'. */
4373 4375
4374 for (pp = (void **) start; (void *) pp < end; ++pp) 4376 for (pp = (void **) ((char *) start + offset); (void *) pp < end; ++pp)
4375 mark_maybe_pointer (*pp); 4377 mark_maybe_pointer (*pp);
4376 } 4378 }
4377 4379
4378 /* setjmp will work with GCC unless NON_SAVING_SETJMP is defined in 4380 /* setjmp will work with GCC unless NON_SAVING_SETJMP is defined in
4379 the GCC system configuration. In gcc 3.2, the only systems for 4381 the GCC system configuration. In gcc 3.2, the only systems for
4548 4550
4549 static void 4551 static void
4550 mark_stack () 4552 mark_stack ()
4551 { 4553 {
4552 int i; 4554 int i;
4553 jmp_buf j; 4555 /* jmp_buf may not be aligned enough on darwin-ppc64 */
4556 union aligned_jmpbuf {
4557 Lisp_Object o;
4558 jmp_buf j;
4559 } j;
4554 volatile int stack_grows_down_p = (char *) &j > (char *) stack_base; 4560 volatile int stack_grows_down_p = (char *) &j > (char *) stack_base;
4555 void *end; 4561 void *end;
4556 4562
4557 /* This trick flushes the register windows so that all the state of 4563 /* This trick flushes the register windows so that all the state of
4558 the process is contained in the stack. */ 4564 the process is contained in the stack. */
4579 setjmp_tested_p = 1; 4585 setjmp_tested_p = 1;
4580 test_setjmp (); 4586 test_setjmp ();
4581 } 4587 }
4582 #endif /* GC_SETJMP_WORKS */ 4588 #endif /* GC_SETJMP_WORKS */
4583 4589
4584 setjmp (j); 4590 setjmp (j.j);
4585 end = stack_grows_down_p ? (char *) &j + sizeof j : (char *) &j; 4591 end = stack_grows_down_p ? (char *) &j + sizeof j : (char *) &j;
4586 #endif /* not GC_SAVE_REGISTERS_ON_STACK */ 4592 #endif /* not GC_SAVE_REGISTERS_ON_STACK */
4587 4593
4588 /* This assumes that the stack is a contiguous region in memory. If 4594 /* This assumes that the stack is a contiguous region in memory. If
4589 that's not the case, something has to be done here to iterate 4595 that's not the case, something has to be done here to iterate
4594 #else 4600 #else
4595 #define GC_LISP_OBJECT_ALIGNMENT sizeof (Lisp_Object) 4601 #define GC_LISP_OBJECT_ALIGNMENT sizeof (Lisp_Object)
4596 #endif 4602 #endif
4597 #endif 4603 #endif
4598 for (i = 0; i < sizeof (Lisp_Object); i += GC_LISP_OBJECT_ALIGNMENT) 4604 for (i = 0; i < sizeof (Lisp_Object); i += GC_LISP_OBJECT_ALIGNMENT)
4599 mark_memory ((char *) stack_base + i, end); 4605 mark_memory (stack_base, end, i);
4600 /* Allow for marking a secondary stack, like the register stack on the 4606 /* Allow for marking a secondary stack, like the register stack on the
4601 ia64. */ 4607 ia64. */
4602 #ifdef GC_MARK_SECONDARY_STACK 4608 #ifdef GC_MARK_SECONDARY_STACK
4603 GC_MARK_SECONDARY_STACK (); 4609 GC_MARK_SECONDARY_STACK ();
4604 #endif 4610 #endif