Next: gc_sweep, Previous: garbage_collect_1, Up: Garbage Collection - Step by Step [Contents][Index]
mark_object
The first thing that is checked while marking an object is whether the
object is a real Lisp object Lisp_Type_Record
or just an integer
or a character. Integers and characters are the only two types that are
stored directly - without another level of indirection, and therefore they
don’t have to be marked and collected.
See How Lisp Objects Are Represented in C.
The second case is the one we have to handle. It is the one when we are
dealing with a pointer to a Lisp object. But, there exist also three
possibilities, that prevent us from doing anything while marking: The
object is read only which prevents it from being garbage collected,
i.e. marked (C_READONLY_RECORD_HEADER
). The object in question is
already marked, and need not be marked for the second time (checked by
MARKED_RECORD_HEADER_P
). If it is a special, unmarkable object
(UNMARKABLE_RECORD_HEADER_P
, apparently, these are objects that
sit in some const space, and can therefore not be marked, see
this_one_is_unmarkable
in alloc.c
).
Now, the actual marking is feasible. We do so by once using the macro
MARK_RECORD_HEADER
to mark the object itself (actually the
special flag in the lrecord header), and calling its special marker
"method" marker
if available. The marker method marks every
other object that is in reach from our current object. Note, that these
marker methods should not call mark_object
recursively, but
instead should return the next object from where further marking has to
be performed.
In case another object was returned, as mentioned before, we reiterate
the whole mark_object
process beginning with this next object.
Next: gc_sweep, Previous: garbage_collect_1, Up: Garbage Collection - Step by Step [Contents][Index]