The first task is to build the list of the objects to dump. This includes:
We end up with one
pdump_entry_list_elmt per object group (arrays
of C structs are kept together) which includes a pointer to the first
object of the group, the per-object size and the count of objects in the
group, along with some other information which is initialized later.
These entries are linked together in
and can be enumerated thru either:
pdump_object_table, an array of
pdump_entry_list, one per lrecord type, indexed by type number.
pdump_opaque_data_list, used for the opaque data which does not include pointers, and hence does not need descriptions.
pdump_struct_table, which is a vector of
pdump_entry_listpairs, used for non-opaque C structures.
This uses a marking strategy similar to the garbage collector. Some differences though:
This is done by
pdump_register_object(), which handles Lisp_Object
pdump_register_struct() which handles C structures,
which both delegate the description management to
The hash table doubles as a map object to pdump_entry_list_elmt (i.e.
allows us to look up a pdump_entry_list_elmt with the object it points
to). Entries are added with
pdump_add_entry() and looked up with
pdump_get_entry(). There is no need for entry removal. The hash
value is computed quite simply from the object pointer by
The roots for the marking are:
staticpro’ed variables (there is a special
staticpro_nodump()call for protected variables we do not want to dump).
staticpro()is equivalent to
dump_add_root_struct_ptr, each of which points to a C structure.
This does not include the GCPRO’ed variables, the specbinds, the catchtags, the backlist, the redisplay or the profiling info, since we do not want to rebuild the actual chain of lisp calls which end up to the dump-emacs call, only the global variables.
Weak lists and weak hash tables are dumped as if they were their non-weak equivalent (without changing their type, of course). This has not yet been a problem.