return live_small_vector_holding (m, p) == p;
}
-/* Mark OBJ if we can prove it's a Lisp_Object. */
+/* If P points to Lisp data, mark that as live if it isn't already
+ marked. */
static void
-mark_maybe_object (Lisp_Object obj)
+mark_maybe_pointer (void *p)
{
+ struct mem_node *m;
+
#if USE_VALGRIND
- VALGRIND_MAKE_MEM_DEFINED (&obj, sizeof (obj));
+ VALGRIND_MAKE_MEM_DEFINED (&p, sizeof (p));
#endif
- int type_tag = XTYPE (obj);
- intptr_t pointer_word_tag = LISP_WORD_TAG (type_tag), offset, ipo;
-
- switch (type_tag)
- {
- case_Lisp_Int: case Lisp_Type_Unused0:
- return;
-
- case Lisp_Symbol:
- offset = (intptr_t) lispsym;
- break;
-
- default:
- offset = 0;
- break;
- }
-
- INT_ADD_WRAPV ((intptr_t) XLP (obj), offset - pointer_word_tag, &ipo);
- void *po = (void *) ipo;
-
/* If the pointer is in the dump image and the dump has a record
of the object starting at the place where the pointer points, we
definitely have an object. If the pointer is in the dump image
and the dump has no idea what the pointer is pointing at, we
definitely _don't_ have an object. */
- if (pdumper_object_p (po))
+ if (pdumper_object_p (p))
{
/* Don't use pdumper_object_p_precise here! It doesn't check the
tag bits. OBJ here might be complete garbage, so we need to
verify both the pointer and the tag. */
- if (pdumper_find_object_type (po) == type_tag)
- mark_object (obj);
- return;
- }
-
- struct mem_node *m = mem_find (po);
-
- if (m != MEM_NIL)
- {
- bool mark_p = false;
-
- switch (type_tag)
- {
- case Lisp_String:
- mark_p = m->type == MEM_TYPE_STRING && live_string_p (m, po);
- break;
-
- case Lisp_Cons:
- mark_p = m->type == MEM_TYPE_CONS && live_cons_p (m, po);
- break;
-
- case Lisp_Symbol:
- mark_p = m->type == MEM_TYPE_SYMBOL && live_symbol_p (m, po);
- break;
-
- case Lisp_Float:
- mark_p = m->type == MEM_TYPE_FLOAT && live_float_p (m, po);
- break;
-
- case Lisp_Vectorlike:
- mark_p = (m->type == MEM_TYPE_VECTOR_BLOCK
- ? live_small_vector_p (m, po)
- : (m->type == MEM_TYPE_VECTORLIKE
- && live_large_vector_p (m, po)));
- break;
-
- default:
- eassume (false);
- }
-
- if (mark_p)
- mark_object (obj);
- }
-}
-
-void
-mark_maybe_objects (Lisp_Object const *array, ptrdiff_t nelts)
-{
- for (Lisp_Object const *lim = array + nelts; array < lim; array++)
- mark_maybe_object (*array);
-}
-
-/* If P points to Lisp data, mark that as live if it isn't already
- marked. */
-
-static void
-mark_maybe_pointer (void *p)
-{
- struct mem_node *m;
-
-#if USE_VALGRIND
- VALGRIND_MAKE_MEM_DEFINED (&p, sizeof (p));
-#endif
-
- if (pdumper_object_p (p))
- {
int type = pdumper_find_object_type (p);
if (pdumper_valid_object_type_p (type))
mark_object (type == Lisp_Symbol
? make_lisp_symbol (p)
: make_lisp_ptr (p, type));
- /* See mark_maybe_object for why we can confidently return. */
return;
}
}
}
+void
+mark_objects (Lisp_Object *obj, ptrdiff_t n)
+{
+ for (ptrdiff_t i = 0; i < n; i++)
+ mark_object (obj[i]);
+}
+
/* Determine type of generic Lisp_Object and mark it accordingly.
This function implements a straightforward depth-first marking
extern AVOID buffer_memory_full (ptrdiff_t);
extern bool survives_gc_p (Lisp_Object);
extern void mark_object (Lisp_Object);
+extern void mark_objects (Lisp_Object *, ptrdiff_t);
#if defined REL_ALLOC && !defined SYSTEM_MALLOC && !defined HYBRID_MALLOC
extern void refill_memory_reserve (void);
#endif
extern void alloc_unexec_pre (void);
extern void alloc_unexec_post (void);
-extern void mark_maybe_objects (Lisp_Object const *, ptrdiff_t);
extern void mark_stack (char const *, char const *);
extern void flush_stack_call_func1 (void (*func) (void *arg), void *arg);
(buf) = AVAIL_ALLOCA (alloca_nbytes); \
else \
{ \
- (buf) = xmalloc (alloca_nbytes); \
+ /* Although only the first nelt words need clearing, \
+ typically EXTRA is 0 or small so just use xzalloc; \
+ this is simpler and often faster. */ \
+ (buf) = xzalloc (alloca_nbytes); \
record_unwind_protect_array (buf, nelt); \
} \
} while (false)