summaryrefslogtreecommitdiff
path: root/src/alloc.c
diff options
context:
space:
mode:
authorAndrea Corallo <akrl@sdf.org>2020-06-04 10:33:07 +0100
committerAndrea Corallo <akrl@sdf.org>2020-06-04 10:33:07 +0100
commitf5ea65b43678621cb450d7afbcd46032258d4b20 (patch)
treedcc643ae66589a1690c50895a46e8004c981ead0 /src/alloc.c
parente4e6bb7fddaa3a4e82748c106366fe9113dc16d9 (diff)
parent4fff6502368e87b3c031589a1a96267243f868b0 (diff)
downloademacs-f5ea65b43678621cb450d7afbcd46032258d4b20.tar.gz
Merge remote-tracking branch 'savannah/master' into HEAD
Diffstat (limited to 'src/alloc.c')
-rw-r--r--src/alloc.c57
1 files changed, 17 insertions, 40 deletions
diff --git a/src/alloc.c b/src/alloc.c
index dc92d67f163..281525b20e5 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -67,7 +67,8 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
# include <malloc.h>
#endif
-#if defined HAVE_VALGRIND_VALGRIND_H && !defined USE_VALGRIND
+#if (defined ENABLE_CHECKING \
+ && defined HAVE_VALGRIND_VALGRIND_H && !defined USE_VALGRIND)
# define USE_VALGRIND 1
#endif
@@ -4463,7 +4464,7 @@ live_string_holding (struct mem_node *m, void *p)
/* P must point into a Lisp_String structure, and it
must not be on the free-list. */
- if (0 <= offset && offset < STRING_BLOCK_SIZE * sizeof b->strings[0])
+ if (0 <= offset && offset < sizeof b->strings)
{
cp = ptr_bounds_copy (cp, b);
struct Lisp_String *s = p = cp -= offset % sizeof b->strings[0];
@@ -4496,7 +4497,7 @@ live_cons_holding (struct mem_node *m, void *p)
/* P must point into a Lisp_Cons, not be
one of the unused cells in the current cons block,
and not be on the free-list. */
- if (0 <= offset && offset < CONS_BLOCK_SIZE * sizeof b->conses[0]
+ if (0 <= offset && offset < sizeof b->conses
&& (b != cons_block
|| offset / sizeof b->conses[0] < cons_block_index))
{
@@ -4532,7 +4533,7 @@ live_symbol_holding (struct mem_node *m, void *p)
/* P must point into the Lisp_Symbol, not be
one of the unused cells in the current symbol block,
and not be on the free-list. */
- if (0 <= offset && offset < SYMBOL_BLOCK_SIZE * sizeof b->symbols[0]
+ if (0 <= offset && offset < sizeof b->symbols
&& (b != symbol_block
|| offset / sizeof b->symbols[0] < symbol_block_index))
{
@@ -4566,9 +4567,8 @@ live_float_p (struct mem_node *m, void *p)
/* P must point to the start of a Lisp_Float and not be
one of the unused cells in the current float block. */
- return (offset >= 0
+ return (0 <= offset && offset < sizeof b->floats
&& offset % sizeof b->floats[0] == 0
- && offset < (FLOAT_BLOCK_SIZE * sizeof b->floats[0])
&& (b != float_block
|| offset / sizeof b->floats[0] < float_block_index));
}
@@ -4694,35 +4694,6 @@ mark_maybe_objects (Lisp_Object const *array, ptrdiff_t nelts)
mark_maybe_object (*array);
}
-/* A lower bound on the alignment of Lisp objects that need marking.
- Although 1 is safe, higher values speed up mark_maybe_pointer.
- If USE_LSB_TAG, this value is typically GCALIGNMENT; otherwise,
- it's determined by the natural alignment of Lisp structs.
- All vectorlike objects have alignment at least that of union
- vectorlike_header and it's unlikely they all have alignment greater,
- so use the union as a safe and likely-accurate standin for
- vectorlike objects. */
-
-enum { GC_OBJECT_ALIGNMENT_MINIMUM
- = max (GCALIGNMENT,
- min (alignof (union vectorlike_header),
- min (min (alignof (struct Lisp_Cons),
- alignof (struct Lisp_Float)),
- min (alignof (struct Lisp_String),
- alignof (struct Lisp_Symbol))))) };
-
-/* Return true if P might point to Lisp data that can be garbage
- collected, and false otherwise (i.e., false if it is easy to see
- that P cannot point to Lisp data that can be garbage collected).
- Symbols are implemented via offsets not pointers, but the offsets
- are also multiples of GC_OBJECT_ALIGNMENT_MINIMUM. */
-
-static bool
-maybe_lisp_pointer (void *p)
-{
- return (uintptr_t) p % GC_OBJECT_ALIGNMENT_MINIMUM == 0;
-}
-
/* If P points to Lisp data, mark that as live if it isn't already
marked. */
@@ -4731,13 +4702,10 @@ mark_maybe_pointer (void *p)
{
struct mem_node *m;
-#ifdef USE_VALGRIND
+#if USE_VALGRIND
VALGRIND_MAKE_MEM_DEFINED (&p, sizeof (p));
#endif
- if (!maybe_lisp_pointer (p))
- return;
-
if (pdumper_object_p (p))
{
int type = pdumper_find_object_type (p);
@@ -4837,7 +4805,16 @@ mark_memory (void const *start, void const *end)
for (pp = start; (void const *) pp < end; pp += GC_POINTER_ALIGNMENT)
{
- mark_maybe_pointer (*(void *const *) pp);
+ char *p = *(char *const *) pp;
+ mark_maybe_pointer (p);
+
+ /* Unmask any struct Lisp_Symbol pointer that make_lisp_symbol
+ previously disguised by adding the address of 'lispsym'.
+ On a host with 32-bit pointers and 64-bit Lisp_Objects,
+ a Lisp_Object might be split into registers saved into
+ non-adjacent words and P might be the low-order word's value. */
+ p += (intptr_t) lispsym;
+ mark_maybe_pointer (p);
verify (alignof (Lisp_Object) % GC_POINTER_ALIGNMENT == 0);
if (alignof (Lisp_Object) == GC_POINTER_ALIGNMENT