diff options
Diffstat (limited to 'src/alloc.c')
| -rw-r--r-- | src/alloc.c | 105 |
1 files changed, 14 insertions, 91 deletions
diff --git a/src/alloc.c b/src/alloc.c index 5453c54d931..2f66b5eef52 100644 --- a/src/alloc.c +++ b/src/alloc.c | |||
| @@ -4680,117 +4680,33 @@ live_small_vector_p (struct mem_node *m, void *p) | |||
| 4680 | return live_small_vector_holding (m, p) == p; | 4680 | return live_small_vector_holding (m, p) == p; |
| 4681 | } | 4681 | } |
| 4682 | 4682 | ||
| 4683 | /* Mark OBJ if we can prove it's a Lisp_Object. */ | 4683 | /* If P points to Lisp data, mark that as live if it isn't already |
| 4684 | marked. */ | ||
| 4684 | 4685 | ||
| 4685 | static void | 4686 | static void |
| 4686 | mark_maybe_object (Lisp_Object obj) | 4687 | mark_maybe_pointer (void *p) |
| 4687 | { | 4688 | { |
| 4689 | struct mem_node *m; | ||
| 4690 | |||
| 4688 | #if USE_VALGRIND | 4691 | #if USE_VALGRIND |
| 4689 | VALGRIND_MAKE_MEM_DEFINED (&obj, sizeof (obj)); | 4692 | VALGRIND_MAKE_MEM_DEFINED (&p, sizeof (p)); |
| 4690 | #endif | 4693 | #endif |
| 4691 | 4694 | ||
| 4692 | int type_tag = XTYPE (obj); | ||
| 4693 | intptr_t pointer_word_tag = LISP_WORD_TAG (type_tag), offset, ipo; | ||
| 4694 | |||
| 4695 | switch (type_tag) | ||
| 4696 | { | ||
| 4697 | case_Lisp_Int: case Lisp_Type_Unused0: | ||
| 4698 | return; | ||
| 4699 | |||
| 4700 | case Lisp_Symbol: | ||
| 4701 | offset = (intptr_t) lispsym; | ||
| 4702 | break; | ||
| 4703 | |||
| 4704 | default: | ||
| 4705 | offset = 0; | ||
| 4706 | break; | ||
| 4707 | } | ||
| 4708 | |||
| 4709 | INT_ADD_WRAPV ((intptr_t) XLP (obj), offset - pointer_word_tag, &ipo); | ||
| 4710 | void *po = (void *) ipo; | ||
| 4711 | |||
| 4712 | /* If the pointer is in the dump image and the dump has a record | 4695 | /* If the pointer is in the dump image and the dump has a record |
| 4713 | of the object starting at the place where the pointer points, we | 4696 | of the object starting at the place where the pointer points, we |
| 4714 | definitely have an object. If the pointer is in the dump image | 4697 | definitely have an object. If the pointer is in the dump image |
| 4715 | and the dump has no idea what the pointer is pointing at, we | 4698 | and the dump has no idea what the pointer is pointing at, we |
| 4716 | definitely _don't_ have an object. */ | 4699 | definitely _don't_ have an object. */ |
| 4717 | if (pdumper_object_p (po)) | 4700 | if (pdumper_object_p (p)) |
| 4718 | { | 4701 | { |
| 4719 | /* Don't use pdumper_object_p_precise here! It doesn't check the | 4702 | /* Don't use pdumper_object_p_precise here! It doesn't check the |
| 4720 | tag bits. OBJ here might be complete garbage, so we need to | 4703 | tag bits. OBJ here might be complete garbage, so we need to |
| 4721 | verify both the pointer and the tag. */ | 4704 | verify both the pointer and the tag. */ |
| 4722 | if (pdumper_find_object_type (po) == type_tag) | ||
| 4723 | mark_object (obj); | ||
| 4724 | return; | ||
| 4725 | } | ||
| 4726 | |||
| 4727 | struct mem_node *m = mem_find (po); | ||
| 4728 | |||
| 4729 | if (m != MEM_NIL) | ||
| 4730 | { | ||
| 4731 | bool mark_p = false; | ||
| 4732 | |||
| 4733 | switch (type_tag) | ||
| 4734 | { | ||
| 4735 | case Lisp_String: | ||
| 4736 | mark_p = m->type == MEM_TYPE_STRING && live_string_p (m, po); | ||
| 4737 | break; | ||
| 4738 | |||
| 4739 | case Lisp_Cons: | ||
| 4740 | mark_p = m->type == MEM_TYPE_CONS && live_cons_p (m, po); | ||
| 4741 | break; | ||
| 4742 | |||
| 4743 | case Lisp_Symbol: | ||
| 4744 | mark_p = m->type == MEM_TYPE_SYMBOL && live_symbol_p (m, po); | ||
| 4745 | break; | ||
| 4746 | |||
| 4747 | case Lisp_Float: | ||
| 4748 | mark_p = m->type == MEM_TYPE_FLOAT && live_float_p (m, po); | ||
| 4749 | break; | ||
| 4750 | |||
| 4751 | case Lisp_Vectorlike: | ||
| 4752 | mark_p = (m->type == MEM_TYPE_VECTOR_BLOCK | ||
| 4753 | ? live_small_vector_p (m, po) | ||
| 4754 | : (m->type == MEM_TYPE_VECTORLIKE | ||
| 4755 | && live_large_vector_p (m, po))); | ||
| 4756 | break; | ||
| 4757 | |||
| 4758 | default: | ||
| 4759 | eassume (false); | ||
| 4760 | } | ||
| 4761 | |||
| 4762 | if (mark_p) | ||
| 4763 | mark_object (obj); | ||
| 4764 | } | ||
| 4765 | } | ||
| 4766 | |||
| 4767 | void | ||
| 4768 | mark_maybe_objects (Lisp_Object const *array, ptrdiff_t nelts) | ||
| 4769 | { | ||
| 4770 | for (Lisp_Object const *lim = array + nelts; array < lim; array++) | ||
| 4771 | mark_maybe_object (*array); | ||
| 4772 | } | ||
| 4773 | |||
| 4774 | /* If P points to Lisp data, mark that as live if it isn't already | ||
| 4775 | marked. */ | ||
| 4776 | |||
| 4777 | static void | ||
| 4778 | mark_maybe_pointer (void *p) | ||
| 4779 | { | ||
| 4780 | struct mem_node *m; | ||
| 4781 | |||
| 4782 | #if USE_VALGRIND | ||
| 4783 | VALGRIND_MAKE_MEM_DEFINED (&p, sizeof (p)); | ||
| 4784 | #endif | ||
| 4785 | |||
| 4786 | if (pdumper_object_p (p)) | ||
| 4787 | { | ||
| 4788 | int type = pdumper_find_object_type (p); | 4705 | int type = pdumper_find_object_type (p); |
| 4789 | if (pdumper_valid_object_type_p (type)) | 4706 | if (pdumper_valid_object_type_p (type)) |
| 4790 | mark_object (type == Lisp_Symbol | 4707 | mark_object (type == Lisp_Symbol |
| 4791 | ? make_lisp_symbol (p) | 4708 | ? make_lisp_symbol (p) |
| 4792 | : make_lisp_ptr (p, type)); | 4709 | : make_lisp_ptr (p, type)); |
| 4793 | /* See mark_maybe_object for why we can confidently return. */ | ||
| 4794 | return; | 4710 | return; |
| 4795 | } | 4711 | } |
| 4796 | 4712 | ||
| @@ -6570,6 +6486,13 @@ mark_hash_table (struct Lisp_Vector *ptr) | |||
| 6570 | } | 6486 | } |
| 6571 | } | 6487 | } |
| 6572 | 6488 | ||
| 6489 | void | ||
| 6490 | mark_objects (Lisp_Object *obj, ptrdiff_t n) | ||
| 6491 | { | ||
| 6492 | for (ptrdiff_t i = 0; i < n; i++) | ||
| 6493 | mark_object (obj[i]); | ||
| 6494 | } | ||
| 6495 | |||
| 6573 | /* Determine type of generic Lisp_Object and mark it accordingly. | 6496 | /* Determine type of generic Lisp_Object and mark it accordingly. |
| 6574 | 6497 | ||
| 6575 | This function implements a straightforward depth-first marking | 6498 | This function implements a straightforward depth-first marking |