diff options
| author | Yuuki Harano | 2021-07-18 18:44:54 +0900 |
|---|---|---|
| committer | Yuuki Harano | 2021-07-18 18:44:54 +0900 |
| commit | b242394f24b154f8e20f5abf4b2f826629e99ea6 (patch) | |
| tree | 9d20e7baa90bd4039ff08c098a09a8c729ce2f12 /src/alloc.c | |
| parent | 492a0ae5927eda83b65dd08d3e1655a62fc2c43d (diff) | |
| parent | 6b802a08cabfb23bdf1f65faa2ee163d3efa820d (diff) | |
| download | emacs-b242394f24b154f8e20f5abf4b2f826629e99ea6.tar.gz emacs-b242394f24b154f8e20f5abf4b2f826629e99ea6.zip | |
Merge branch 'master' of git.sv.gnu.org:/srv/git/emacs into feature/pgtk
Diffstat (limited to 'src/alloc.c')
| -rw-r--r-- | src/alloc.c | 44 |
1 files changed, 36 insertions, 8 deletions
diff --git a/src/alloc.c b/src/alloc.c index e57bec111e3..a17488ee1d0 100644 --- a/src/alloc.c +++ b/src/alloc.c | |||
| @@ -4740,7 +4740,7 @@ live_small_vector_p (struct mem_node *m, void *p) | |||
| 4740 | marked. */ | 4740 | marked. */ |
| 4741 | 4741 | ||
| 4742 | static void | 4742 | static void |
| 4743 | mark_maybe_pointer (void *p) | 4743 | mark_maybe_pointer (void *p, bool symbol_only) |
| 4744 | { | 4744 | { |
| 4745 | struct mem_node *m; | 4745 | struct mem_node *m; |
| 4746 | 4746 | ||
| @@ -4755,14 +4755,32 @@ mark_maybe_pointer (void *p) | |||
| 4755 | definitely _don't_ have an object. */ | 4755 | definitely _don't_ have an object. */ |
| 4756 | if (pdumper_object_p (p)) | 4756 | if (pdumper_object_p (p)) |
| 4757 | { | 4757 | { |
| 4758 | /* FIXME: This code assumes that every reachable pdumper object | ||
| 4759 | is addressed either by a pointer to the object start, or by | ||
| 4760 | the same pointer with an LSB-style tag. This assumption | ||
| 4761 | fails if a pdumper object is reachable only via machine | ||
| 4762 | addresses of non-initial object components. Although such | ||
| 4763 | addressing is rare in machine code generated by C compilers | ||
| 4764 | from Emacs source code, it can occur in some cases. To fix | ||
| 4765 | this problem, the pdumper code should grok non-initial | ||
| 4766 | addresses, as the non-pdumper code does. */ | ||
| 4767 | uintptr_t mask = VALMASK & UINTPTR_MAX; | ||
| 4768 | uintptr_t masked_p = (uintptr_t) p & mask; | ||
| 4769 | void *po = (void *) masked_p; | ||
| 4770 | char *cp = p; | ||
| 4771 | char *cpo = po; | ||
| 4758 | /* Don't use pdumper_object_p_precise here! It doesn't check the | 4772 | /* Don't use pdumper_object_p_precise here! It doesn't check the |
| 4759 | tag bits. OBJ here might be complete garbage, so we need to | 4773 | tag bits. OBJ here might be complete garbage, so we need to |
| 4760 | verify both the pointer and the tag. */ | 4774 | verify both the pointer and the tag. */ |
| 4761 | int type = pdumper_find_object_type (p); | 4775 | int type = pdumper_find_object_type (po); |
| 4762 | if (pdumper_valid_object_type_p (type)) | 4776 | if (pdumper_valid_object_type_p (type) |
| 4763 | mark_object (type == Lisp_Symbol | 4777 | && (!USE_LSB_TAG || p == po || cp - cpo == type)) |
| 4764 | ? make_lisp_symbol (p) | 4778 | { |
| 4765 | : make_lisp_ptr (p, type)); | 4779 | if (type == Lisp_Symbol) |
| 4780 | mark_object (make_lisp_symbol (po)); | ||
| 4781 | else if (!symbol_only) | ||
| 4782 | mark_object (make_lisp_ptr (po, type)); | ||
| 4783 | } | ||
| 4766 | return; | 4784 | return; |
| 4767 | } | 4785 | } |
| 4768 | 4786 | ||
| @@ -4780,6 +4798,8 @@ mark_maybe_pointer (void *p) | |||
| 4780 | 4798 | ||
| 4781 | case MEM_TYPE_CONS: | 4799 | case MEM_TYPE_CONS: |
| 4782 | { | 4800 | { |
| 4801 | if (symbol_only) | ||
| 4802 | return; | ||
| 4783 | struct Lisp_Cons *h = live_cons_holding (m, p); | 4803 | struct Lisp_Cons *h = live_cons_holding (m, p); |
| 4784 | if (!h) | 4804 | if (!h) |
| 4785 | return; | 4805 | return; |
| @@ -4789,6 +4809,8 @@ mark_maybe_pointer (void *p) | |||
| 4789 | 4809 | ||
| 4790 | case MEM_TYPE_STRING: | 4810 | case MEM_TYPE_STRING: |
| 4791 | { | 4811 | { |
| 4812 | if (symbol_only) | ||
| 4813 | return; | ||
| 4792 | struct Lisp_String *h = live_string_holding (m, p); | 4814 | struct Lisp_String *h = live_string_holding (m, p); |
| 4793 | if (!h) | 4815 | if (!h) |
| 4794 | return; | 4816 | return; |
| @@ -4807,6 +4829,8 @@ mark_maybe_pointer (void *p) | |||
| 4807 | 4829 | ||
| 4808 | case MEM_TYPE_FLOAT: | 4830 | case MEM_TYPE_FLOAT: |
| 4809 | { | 4831 | { |
| 4832 | if (symbol_only) | ||
| 4833 | return; | ||
| 4810 | struct Lisp_Float *h = live_float_holding (m, p); | 4834 | struct Lisp_Float *h = live_float_holding (m, p); |
| 4811 | if (!h) | 4835 | if (!h) |
| 4812 | return; | 4836 | return; |
| @@ -4816,6 +4840,8 @@ mark_maybe_pointer (void *p) | |||
| 4816 | 4840 | ||
| 4817 | case MEM_TYPE_VECTORLIKE: | 4841 | case MEM_TYPE_VECTORLIKE: |
| 4818 | { | 4842 | { |
| 4843 | if (symbol_only) | ||
| 4844 | return; | ||
| 4819 | struct Lisp_Vector *h = live_large_vector_holding (m, p); | 4845 | struct Lisp_Vector *h = live_large_vector_holding (m, p); |
| 4820 | if (!h) | 4846 | if (!h) |
| 4821 | return; | 4847 | return; |
| @@ -4825,6 +4851,8 @@ mark_maybe_pointer (void *p) | |||
| 4825 | 4851 | ||
| 4826 | case MEM_TYPE_VECTOR_BLOCK: | 4852 | case MEM_TYPE_VECTOR_BLOCK: |
| 4827 | { | 4853 | { |
| 4854 | if (symbol_only) | ||
| 4855 | return; | ||
| 4828 | struct Lisp_Vector *h = live_small_vector_holding (m, p); | 4856 | struct Lisp_Vector *h = live_small_vector_holding (m, p); |
| 4829 | if (!h) | 4857 | if (!h) |
| 4830 | return; | 4858 | return; |
| @@ -4886,7 +4914,7 @@ mark_memory (void const *start, void const *end) | |||
| 4886 | for (pp = start; (void const *) pp < end; pp += GC_POINTER_ALIGNMENT) | 4914 | for (pp = start; (void const *) pp < end; pp += GC_POINTER_ALIGNMENT) |
| 4887 | { | 4915 | { |
| 4888 | void *p = *(void *const *) pp; | 4916 | void *p = *(void *const *) pp; |
| 4889 | mark_maybe_pointer (p); | 4917 | mark_maybe_pointer (p, false); |
| 4890 | 4918 | ||
| 4891 | /* Unmask any struct Lisp_Symbol pointer that make_lisp_symbol | 4919 | /* Unmask any struct Lisp_Symbol pointer that make_lisp_symbol |
| 4892 | previously disguised by adding the address of 'lispsym'. | 4920 | previously disguised by adding the address of 'lispsym'. |
| @@ -4895,7 +4923,7 @@ mark_memory (void const *start, void const *end) | |||
| 4895 | non-adjacent words and P might be the low-order word's value. */ | 4923 | non-adjacent words and P might be the low-order word's value. */ |
| 4896 | intptr_t ip; | 4924 | intptr_t ip; |
| 4897 | INT_ADD_WRAPV ((intptr_t) p, (intptr_t) lispsym, &ip); | 4925 | INT_ADD_WRAPV ((intptr_t) p, (intptr_t) lispsym, &ip); |
| 4898 | mark_maybe_pointer ((void *) ip); | 4926 | mark_maybe_pointer ((void *) ip, true); |
| 4899 | } | 4927 | } |
| 4900 | } | 4928 | } |
| 4901 | 4929 | ||