Next: , Up: Dumping phase   [Contents][Index]


12.4.1 Object inventory

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 pdump_entry_list structures and can be enumerated thru either:

  1. the pdump_object_table, an array of pdump_entry_list, one per lrecord type, indexed by type number.
  2. the pdump_opaque_data_list, used for the opaque data which does not include pointers, and hence does not need descriptions.
  3. the pdump_struct_table, which is a vector of struct_description/pdump_entry_list pairs, used for non-opaque C structures.

This uses a marking strategy similar to the garbage collector. Some differences though:

  1. We do not use the mark bit (which does not exist for C structures anyway); we use a big hash table instead.
  2. We do not use the mark function of lrecords but instead rely on the external descriptions. This happens essentially because we need to follow pointers to C structures and opaque data in addition to Lisp_Object members.

This is done by pdump_register_object(), which handles Lisp_Object variables, and pdump_register_struct() which handles C structures, which both delegate the description management to pdump_register_sub().

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 pdump_make_hash().

The roots for the marking are:

  1. the staticpro’ed variables (there is a special staticpro_nodump() call for protected variables we do not want to dump).
  2. the variables registered via dump_add_root_object (staticpro() is equivalent to staticpro_nodump() + dump_add_root_object()).
  3. the variables registered via 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.


Next: , Up: Dumping phase   [Contents][Index]