diff options
Diffstat (limited to 'src/alloc.c')
| -rw-r--r-- | src/alloc.c | 41 |
1 files changed, 36 insertions, 5 deletions
diff --git a/src/alloc.c b/src/alloc.c index ab383f34f04..d728c356109 100644 --- a/src/alloc.c +++ b/src/alloc.c | |||
| @@ -4547,7 +4547,16 @@ mark_maybe_object (Lisp_Object obj) | |||
| 4547 | } | 4547 | } |
| 4548 | } | 4548 | } |
| 4549 | 4549 | ||
| 4550 | /* Return true if P can point to Lisp data, and false otherwise. | ||
| 4551 | USE_LSB_TAG needs Lisp data to be aligned on multiples of GCALIGNMENT. | ||
| 4552 | Otherwise, assume that Lisp data is aligned on even addresses. */ | ||
| 4550 | 4553 | ||
| 4554 | static bool | ||
| 4555 | maybe_lisp_pointer (void *p) | ||
| 4556 | { | ||
| 4557 | return !((intptr_t) p % (USE_LSB_TAG ? GCALIGNMENT : 2)); | ||
| 4558 | } | ||
| 4559 | |||
| 4551 | /* If P points to Lisp data, mark that as live if it isn't already | 4560 | /* If P points to Lisp data, mark that as live if it isn't already |
| 4552 | marked. */ | 4561 | marked. */ |
| 4553 | 4562 | ||
| @@ -4561,10 +4570,7 @@ mark_maybe_pointer (void *p) | |||
| 4561 | VALGRIND_MAKE_MEM_DEFINED (&p, sizeof (p)); | 4570 | VALGRIND_MAKE_MEM_DEFINED (&p, sizeof (p)); |
| 4562 | #endif | 4571 | #endif |
| 4563 | 4572 | ||
| 4564 | /* Quickly rule out some values which can't point to Lisp data. | 4573 | if (!maybe_lisp_pointer (p)) |
| 4565 | USE_LSB_TAG needs Lisp data to be aligned on multiples of GCALIGNMENT. | ||
| 4566 | Otherwise, assume that Lisp data is aligned on even addresses. */ | ||
| 4567 | if ((intptr_t) p % (USE_LSB_TAG ? GCALIGNMENT : 2)) | ||
| 4568 | return; | 4574 | return; |
| 4569 | 4575 | ||
| 4570 | m = mem_find (p); | 4576 | m = mem_find (p); |
| @@ -5007,9 +5013,34 @@ valid_lisp_object_p (Lisp_Object obj) | |||
| 5007 | #endif | 5013 | #endif |
| 5008 | } | 5014 | } |
| 5009 | 5015 | ||
| 5016 | /* If GC_MARK_STACK, return 1 if STR is a relocatable data of Lisp_String | ||
| 5017 | (i.e. there is a non-pure Lisp_Object X so that SDATA (X) == STR) and 0 | ||
| 5018 | if not. Otherwise we can't rely on valid_lisp_object_p and return -1. | ||
| 5019 | This function is slow and should be used for debugging purposes. */ | ||
| 5010 | 5020 | ||
| 5021 | int | ||
| 5022 | relocatable_string_data_p (const char *str) | ||
| 5023 | { | ||
| 5024 | if (PURE_POINTER_P (str)) | ||
| 5025 | return 0; | ||
| 5026 | #if GC_MARK_STACK | ||
| 5027 | if (str) | ||
| 5028 | { | ||
| 5029 | struct sdata *sdata | ||
| 5030 | = (struct sdata *) (str - offsetof (struct sdata, data)); | ||
| 5031 | |||
| 5032 | if (valid_pointer_p (sdata) | ||
| 5033 | && valid_pointer_p (sdata->string) | ||
| 5034 | && maybe_lisp_pointer (sdata->string)) | ||
| 5035 | return (valid_lisp_object_p | ||
| 5036 | (make_lisp_ptr (sdata->string, Lisp_String)) | ||
| 5037 | && (const char *) sdata->string->data == str); | ||
| 5038 | } | ||
| 5039 | return 0; | ||
| 5040 | #endif /* GC_MARK_STACK */ | ||
| 5041 | return -1; | ||
| 5042 | } | ||
| 5011 | 5043 | ||
| 5012 | |||
| 5013 | /*********************************************************************** | 5044 | /*********************************************************************** |
| 5014 | Pure Storage Management | 5045 | Pure Storage Management |
| 5015 | ***********************************************************************/ | 5046 | ***********************************************************************/ |