diff options
Diffstat (limited to 'src/alloc.c')
| -rw-r--r-- | src/alloc.c | 43 |
1 files changed, 10 insertions, 33 deletions
diff --git a/src/alloc.c b/src/alloc.c index e241b9933a4..124b50d0d3f 100644 --- a/src/alloc.c +++ b/src/alloc.c | |||
| @@ -4687,35 +4687,6 @@ mark_maybe_objects (Lisp_Object const *array, ptrdiff_t nelts) | |||
| 4687 | mark_maybe_object (*array); | 4687 | mark_maybe_object (*array); |
| 4688 | } | 4688 | } |
| 4689 | 4689 | ||
| 4690 | /* A lower bound on the alignment of Lisp objects that need marking. | ||
| 4691 | Although 1 is safe, higher values speed up mark_maybe_pointer. | ||
| 4692 | If USE_LSB_TAG, this value is typically GCALIGNMENT; otherwise, | ||
| 4693 | it's determined by the natural alignment of Lisp structs. | ||
| 4694 | All vectorlike objects have alignment at least that of union | ||
| 4695 | vectorlike_header and it's unlikely they all have alignment greater, | ||
| 4696 | so use the union as a safe and likely-accurate standin for | ||
| 4697 | vectorlike objects. */ | ||
| 4698 | |||
| 4699 | enum { GC_OBJECT_ALIGNMENT_MINIMUM | ||
| 4700 | = max (GCALIGNMENT, | ||
| 4701 | min (alignof (union vectorlike_header), | ||
| 4702 | min (min (alignof (struct Lisp_Cons), | ||
| 4703 | alignof (struct Lisp_Float)), | ||
| 4704 | min (alignof (struct Lisp_String), | ||
| 4705 | alignof (struct Lisp_Symbol))))) }; | ||
| 4706 | |||
| 4707 | /* Return true if P might point to Lisp data that can be garbage | ||
| 4708 | collected, and false otherwise (i.e., false if it is easy to see | ||
| 4709 | that P cannot point to Lisp data that can be garbage collected). | ||
| 4710 | Symbols are implemented via offsets not pointers, but the offsets | ||
| 4711 | are also multiples of GC_OBJECT_ALIGNMENT_MINIMUM. */ | ||
| 4712 | |||
| 4713 | static bool | ||
| 4714 | maybe_lisp_pointer (void *p) | ||
| 4715 | { | ||
| 4716 | return (uintptr_t) p % GC_OBJECT_ALIGNMENT_MINIMUM == 0; | ||
| 4717 | } | ||
| 4718 | |||
| 4719 | /* If P points to Lisp data, mark that as live if it isn't already | 4690 | /* If P points to Lisp data, mark that as live if it isn't already |
| 4720 | marked. */ | 4691 | marked. */ |
| 4721 | 4692 | ||
| @@ -4728,9 +4699,6 @@ mark_maybe_pointer (void *p) | |||
| 4728 | VALGRIND_MAKE_MEM_DEFINED (&p, sizeof (p)); | 4699 | VALGRIND_MAKE_MEM_DEFINED (&p, sizeof (p)); |
| 4729 | #endif | 4700 | #endif |
| 4730 | 4701 | ||
| 4731 | if (!maybe_lisp_pointer (p)) | ||
| 4732 | return; | ||
| 4733 | |||
| 4734 | if (pdumper_object_p (p)) | 4702 | if (pdumper_object_p (p)) |
| 4735 | { | 4703 | { |
| 4736 | int type = pdumper_find_object_type (p); | 4704 | int type = pdumper_find_object_type (p); |
| @@ -4830,7 +4798,16 @@ mark_memory (void const *start, void const *end) | |||
| 4830 | 4798 | ||
| 4831 | for (pp = start; (void const *) pp < end; pp += GC_POINTER_ALIGNMENT) | 4799 | for (pp = start; (void const *) pp < end; pp += GC_POINTER_ALIGNMENT) |
| 4832 | { | 4800 | { |
| 4833 | mark_maybe_pointer (*(void *const *) pp); | 4801 | char *p = *(char *const *) pp; |
| 4802 | mark_maybe_pointer (p); | ||
| 4803 | |||
| 4804 | /* Unmask any struct Lisp_Symbol pointer that make_lisp_symbol | ||
| 4805 | previously disguised by adding the address of 'lispsym'. | ||
| 4806 | On a host with 32-bit pointers and 64-bit Lisp_Objects, | ||
| 4807 | a Lisp_Object might be split into registers saved into | ||
| 4808 | non-adjacent words and P might be the low-order word's value. */ | ||
| 4809 | p += (intptr_t) lispsym; | ||
| 4810 | mark_maybe_pointer (p); | ||
| 4834 | 4811 | ||
| 4835 | verify (alignof (Lisp_Object) % GC_POINTER_ALIGNMENT == 0); | 4812 | verify (alignof (Lisp_Object) % GC_POINTER_ALIGNMENT == 0); |
| 4836 | if (alignof (Lisp_Object) == GC_POINTER_ALIGNMENT | 4813 | if (alignof (Lisp_Object) == GC_POINTER_ALIGNMENT |