diff options
Diffstat (limited to 'src/alloc.c')
| -rw-r--r-- | src/alloc.c | 51 |
1 files changed, 35 insertions, 16 deletions
diff --git a/src/alloc.c b/src/alloc.c index 9ec44b8a2c3..03dacc77c6e 100644 --- a/src/alloc.c +++ b/src/alloc.c | |||
| @@ -3732,7 +3732,7 @@ make_event_array (ptrdiff_t nargs, Lisp_Object *args) | |||
| 3732 | #ifdef HAVE_MODULES | 3732 | #ifdef HAVE_MODULES |
| 3733 | /* Create a new module user ptr object. */ | 3733 | /* Create a new module user ptr object. */ |
| 3734 | Lisp_Object | 3734 | Lisp_Object |
| 3735 | make_user_ptr (void (*finalizer) (void*), void *p) | 3735 | make_user_ptr (void (*finalizer) (void *), void *p) |
| 3736 | { | 3736 | { |
| 3737 | Lisp_Object obj; | 3737 | Lisp_Object obj; |
| 3738 | struct Lisp_User_Ptr *uptr; | 3738 | struct Lisp_User_Ptr *uptr; |
| @@ -4594,6 +4594,10 @@ maybe_lisp_pointer (void *p) | |||
| 4594 | return (uintptr_t) p % GCALIGNMENT == 0; | 4594 | return (uintptr_t) p % GCALIGNMENT == 0; |
| 4595 | } | 4595 | } |
| 4596 | 4596 | ||
| 4597 | #ifndef HAVE_MODULES | ||
| 4598 | enum { HAVE_MODULES = false }; | ||
| 4599 | #endif | ||
| 4600 | |||
| 4597 | /* If P points to Lisp data, mark that as live if it isn't already | 4601 | /* If P points to Lisp data, mark that as live if it isn't already |
| 4598 | marked. */ | 4602 | marked. */ |
| 4599 | 4603 | ||
| @@ -4607,8 +4611,17 @@ mark_maybe_pointer (void *p) | |||
| 4607 | VALGRIND_MAKE_MEM_DEFINED (&p, sizeof (p)); | 4611 | VALGRIND_MAKE_MEM_DEFINED (&p, sizeof (p)); |
| 4608 | #endif | 4612 | #endif |
| 4609 | 4613 | ||
| 4610 | if (!maybe_lisp_pointer (p)) | 4614 | if (sizeof (Lisp_Object) == sizeof (void *) || !HAVE_MODULES) |
| 4611 | return; | 4615 | { |
| 4616 | if (!maybe_lisp_pointer (p)) | ||
| 4617 | return; | ||
| 4618 | } | ||
| 4619 | else | ||
| 4620 | { | ||
| 4621 | /* For the wide-int case, also mark emacs_value tagged pointers, | ||
| 4622 | which can be generated by emacs-module.c's value_to_lisp. */ | ||
| 4623 | p = (void *) ((uintptr_t) p & ~(GCALIGNMENT - 1)); | ||
| 4624 | } | ||
| 4612 | 4625 | ||
| 4613 | m = mem_find (p); | 4626 | m = mem_find (p); |
| 4614 | if (m != MEM_NIL) | 4627 | if (m != MEM_NIL) |
| @@ -4685,8 +4698,7 @@ mark_maybe_pointer (void *p) | |||
| 4685 | static void ATTRIBUTE_NO_SANITIZE_ADDRESS | 4698 | static void ATTRIBUTE_NO_SANITIZE_ADDRESS |
| 4686 | mark_memory (void *start, void *end) | 4699 | mark_memory (void *start, void *end) |
| 4687 | { | 4700 | { |
| 4688 | void **pp; | 4701 | char *pp; |
| 4689 | int i; | ||
| 4690 | 4702 | ||
| 4691 | /* Make START the pointer to the start of the memory region, | 4703 | /* Make START the pointer to the start of the memory region, |
| 4692 | if it isn't already. */ | 4704 | if it isn't already. */ |
| @@ -4697,6 +4709,8 @@ mark_memory (void *start, void *end) | |||
| 4697 | end = tem; | 4709 | end = tem; |
| 4698 | } | 4710 | } |
| 4699 | 4711 | ||
| 4712 | eassert (((uintptr_t) start) % GC_POINTER_ALIGNMENT == 0); | ||
| 4713 | |||
| 4700 | /* Mark Lisp data pointed to. This is necessary because, in some | 4714 | /* Mark Lisp data pointed to. This is necessary because, in some |
| 4701 | situations, the C compiler optimizes Lisp objects away, so that | 4715 | situations, the C compiler optimizes Lisp objects away, so that |
| 4702 | only a pointer to them remains. Example: | 4716 | only a pointer to them remains. Example: |
| @@ -4715,13 +4729,11 @@ mark_memory (void *start, void *end) | |||
| 4715 | away. The only reference to the life string is through the | 4729 | away. The only reference to the life string is through the |
| 4716 | pointer `s'. */ | 4730 | pointer `s'. */ |
| 4717 | 4731 | ||
| 4718 | for (pp = start; (void *) pp < end; pp++) | 4732 | for (pp = start; (void *) pp < end; pp += GC_POINTER_ALIGNMENT) |
| 4719 | for (i = 0; i < sizeof *pp; i += GC_POINTER_ALIGNMENT) | 4733 | { |
| 4720 | { | 4734 | mark_maybe_pointer (*(void **) pp); |
| 4721 | void *p = *(void **) ((char *) pp + i); | 4735 | mark_maybe_object (*(Lisp_Object *) pp); |
| 4722 | mark_maybe_pointer (p); | 4736 | } |
| 4723 | mark_maybe_object (XIL ((intptr_t) p)); | ||
| 4724 | } | ||
| 4725 | } | 4737 | } |
| 4726 | 4738 | ||
| 4727 | #if !defined GC_SAVE_REGISTERS_ON_STACK && !defined GC_SETJMP_WORKS | 4739 | #if !defined GC_SAVE_REGISTERS_ON_STACK && !defined GC_SETJMP_WORKS |
| @@ -5513,9 +5525,16 @@ garbage_collect_1 (void *end) | |||
| 5513 | don't let that cause a recursive GC. */ | 5525 | don't let that cause a recursive GC. */ |
| 5514 | consing_since_gc = 0; | 5526 | consing_since_gc = 0; |
| 5515 | 5527 | ||
| 5516 | /* Save what's currently displayed in the echo area. */ | 5528 | /* Save what's currently displayed in the echo area. Don't do that |
| 5517 | message_p = push_message (); | 5529 | if we are GC'ing because we've run out of memory, since |
| 5518 | record_unwind_protect_void (pop_message_unwind); | 5530 | push_message will cons, and we might have no memory for that. */ |
| 5531 | if (NILP (Vmemory_full)) | ||
| 5532 | { | ||
| 5533 | message_p = push_message (); | ||
| 5534 | record_unwind_protect_void (pop_message_unwind); | ||
| 5535 | } | ||
| 5536 | else | ||
| 5537 | message_p = false; | ||
| 5519 | 5538 | ||
| 5520 | /* Save a copy of the contents of the stack, for debugging. */ | 5539 | /* Save a copy of the contents of the stack, for debugging. */ |
| 5521 | #if MAX_SAVE_STACK > 0 | 5540 | #if MAX_SAVE_STACK > 0 |
| @@ -5646,7 +5665,7 @@ garbage_collect_1 (void *end) | |||
| 5646 | } | 5665 | } |
| 5647 | } | 5666 | } |
| 5648 | 5667 | ||
| 5649 | if (garbage_collection_messages) | 5668 | if (garbage_collection_messages && NILP (Vmemory_full)) |
| 5650 | { | 5669 | { |
| 5651 | if (message_p || minibuf_level > 0) | 5670 | if (message_p || minibuf_level > 0) |
| 5652 | restore_message (); | 5671 | restore_message (); |