diff options
| author | Joakim Verona | 2011-10-10 13:00:51 +0200 |
|---|---|---|
| committer | Joakim Verona | 2011-10-10 13:00:51 +0200 |
| commit | 0b19c7867f5e647fa0269833fe74e0064b415c08 (patch) | |
| tree | 08a0a4112e94675ffde647160706480e78435818 /src/alloc.c | |
| parent | d4077561a90a24d61e295745d70c0effa655a37c (diff) | |
| parent | 0563dae9a9e3a8c2b6de454693c0cc207e67f05d (diff) | |
| download | emacs-0b19c7867f5e647fa0269833fe74e0064b415c08.tar.gz emacs-0b19c7867f5e647fa0269833fe74e0064b415c08.zip | |
upstream
Diffstat (limited to 'src/alloc.c')
| -rw-r--r-- | src/alloc.c | 42 |
1 files changed, 22 insertions, 20 deletions
diff --git a/src/alloc.c b/src/alloc.c index ead5c8a8ca4..09ef4b085df 100644 --- a/src/alloc.c +++ b/src/alloc.c | |||
| @@ -393,7 +393,7 @@ static int live_symbol_p (struct mem_node *, void *); | |||
| 393 | static int live_float_p (struct mem_node *, void *); | 393 | static int live_float_p (struct mem_node *, void *); |
| 394 | static int live_misc_p (struct mem_node *, void *); | 394 | static int live_misc_p (struct mem_node *, void *); |
| 395 | static void mark_maybe_object (Lisp_Object); | 395 | static void mark_maybe_object (Lisp_Object); |
| 396 | static void mark_memory (void *, void *, int); | 396 | static void mark_memory (void *, void *); |
| 397 | static void mem_init (void); | 397 | static void mem_init (void); |
| 398 | static struct mem_node *mem_insert (void *, void *, enum mem_type); | 398 | static struct mem_node *mem_insert (void *, void *, enum mem_type); |
| 399 | static void mem_insert_fixup (struct mem_node *); | 399 | static void mem_insert_fixup (struct mem_node *); |
| @@ -4235,14 +4235,25 @@ mark_maybe_pointer (void *p) | |||
| 4235 | } | 4235 | } |
| 4236 | 4236 | ||
| 4237 | 4237 | ||
| 4238 | /* Alignment of Lisp_Object and pointer values. Use offsetof, as it | ||
| 4239 | sometimes returns a smaller alignment than GCC's __alignof__ and | ||
| 4240 | mark_memory might miss objects if __alignof__ were used. For | ||
| 4241 | example, on x86 with WIDE_EMACS_INT, __alignof__ (Lisp_Object) is 8 | ||
| 4242 | but GC_LISP_OBJECT_ALIGNMENT should be 4. */ | ||
| 4243 | #ifndef GC_LISP_OBJECT_ALIGNMENT | ||
| 4244 | # define GC_LISP_OBJECT_ALIGNMENT offsetof (struct {char a; Lisp_Object b;}, b) | ||
| 4245 | #endif | ||
| 4246 | #define GC_POINTER_ALIGNMENT offsetof (struct {char a; void *b;}, b) | ||
| 4247 | |||
| 4238 | /* Mark Lisp objects referenced from the address range START+OFFSET..END | 4248 | /* Mark Lisp objects referenced from the address range START+OFFSET..END |
| 4239 | or END+OFFSET..START. */ | 4249 | or END+OFFSET..START. */ |
| 4240 | 4250 | ||
| 4241 | static void | 4251 | static void |
| 4242 | mark_memory (void *start, void *end, int offset) | 4252 | mark_memory (void *start, void *end) |
| 4243 | { | 4253 | { |
| 4244 | Lisp_Object *p; | 4254 | Lisp_Object *p; |
| 4245 | void **pp; | 4255 | void **pp; |
| 4256 | int i; | ||
| 4246 | 4257 | ||
| 4247 | #if GC_MARK_STACK == GC_USE_GCPROS_CHECK_ZOMBIES | 4258 | #if GC_MARK_STACK == GC_USE_GCPROS_CHECK_ZOMBIES |
| 4248 | nzombies = 0; | 4259 | nzombies = 0; |
| @@ -4258,8 +4269,9 @@ mark_memory (void *start, void *end, int offset) | |||
| 4258 | } | 4269 | } |
| 4259 | 4270 | ||
| 4260 | /* Mark Lisp_Objects. */ | 4271 | /* Mark Lisp_Objects. */ |
| 4261 | for (p = (Lisp_Object *) ((char *) start + offset); (void *) p < end; ++p) | 4272 | for (p = start; (void *) p < end; p++) |
| 4262 | mark_maybe_object (*p); | 4273 | for (i = 0; i < sizeof *p; i += GC_LISP_OBJECT_ALIGNMENT) |
| 4274 | mark_maybe_object (*(Lisp_Object *) ((char *) p + i)); | ||
| 4263 | 4275 | ||
| 4264 | /* Mark Lisp data pointed to. This is necessary because, in some | 4276 | /* Mark Lisp data pointed to. This is necessary because, in some |
| 4265 | situations, the C compiler optimizes Lisp objects away, so that | 4277 | situations, the C compiler optimizes Lisp objects away, so that |
| @@ -4279,8 +4291,9 @@ mark_memory (void *start, void *end, int offset) | |||
| 4279 | away. The only reference to the life string is through the | 4291 | away. The only reference to the life string is through the |
| 4280 | pointer `s'. */ | 4292 | pointer `s'. */ |
| 4281 | 4293 | ||
| 4282 | for (pp = (void **) ((char *) start + offset); (void *) pp < end; ++pp) | 4294 | for (pp = start; (void *) pp < end; pp++) |
| 4283 | mark_maybe_pointer (*pp); | 4295 | for (i = 0; i < sizeof *pp; i += GC_POINTER_ALIGNMENT) |
| 4296 | mark_maybe_pointer (*(void **) ((char *) pp + i)); | ||
| 4284 | } | 4297 | } |
| 4285 | 4298 | ||
| 4286 | /* setjmp will work with GCC unless NON_SAVING_SETJMP is defined in | 4299 | /* setjmp will work with GCC unless NON_SAVING_SETJMP is defined in |
| @@ -4454,15 +4467,11 @@ dump_zombies (void) | |||
| 4454 | pass starting at the start of the stack + 2. Likewise, if the | 4467 | pass starting at the start of the stack + 2. Likewise, if the |
| 4455 | minimal alignment of Lisp_Objects on the stack is 1, four passes | 4468 | minimal alignment of Lisp_Objects on the stack is 1, four passes |
| 4456 | would be necessary, each one starting with one byte more offset | 4469 | would be necessary, each one starting with one byte more offset |
| 4457 | from the stack start. | 4470 | from the stack start. */ |
| 4458 | |||
| 4459 | The current code assumes by default that Lisp_Objects are aligned | ||
| 4460 | equally on the stack. */ | ||
| 4461 | 4471 | ||
| 4462 | static void | 4472 | static void |
| 4463 | mark_stack (void) | 4473 | mark_stack (void) |
| 4464 | { | 4474 | { |
| 4465 | int i; | ||
| 4466 | void *end; | 4475 | void *end; |
| 4467 | 4476 | ||
| 4468 | #ifdef HAVE___BUILTIN_UNWIND_INIT | 4477 | #ifdef HAVE___BUILTIN_UNWIND_INIT |
| @@ -4520,15 +4529,8 @@ mark_stack (void) | |||
| 4520 | /* This assumes that the stack is a contiguous region in memory. If | 4529 | /* This assumes that the stack is a contiguous region in memory. If |
| 4521 | that's not the case, something has to be done here to iterate | 4530 | that's not the case, something has to be done here to iterate |
| 4522 | over the stack segments. */ | 4531 | over the stack segments. */ |
| 4523 | #ifndef GC_LISP_OBJECT_ALIGNMENT | 4532 | mark_memory (stack_base, end); |
| 4524 | #ifdef __GNUC__ | 4533 | |
| 4525 | #define GC_LISP_OBJECT_ALIGNMENT __alignof__ (Lisp_Object) | ||
| 4526 | #else | ||
| 4527 | #define GC_LISP_OBJECT_ALIGNMENT sizeof (Lisp_Object) | ||
| 4528 | #endif | ||
| 4529 | #endif | ||
| 4530 | for (i = 0; i < sizeof (Lisp_Object); i += GC_LISP_OBJECT_ALIGNMENT) | ||
| 4531 | mark_memory (stack_base, end, i); | ||
| 4532 | /* Allow for marking a secondary stack, like the register stack on the | 4534 | /* Allow for marking a secondary stack, like the register stack on the |
| 4533 | ia64. */ | 4535 | ia64. */ |
| 4534 | #ifdef GC_MARK_SECONDARY_STACK | 4536 | #ifdef GC_MARK_SECONDARY_STACK |