comparison man/internals/internals.texi @ 452:3d3049ae1304 r21-2-41

Import from CVS: tag r21-2-41
author cvs
date Mon, 13 Aug 2007 11:40:21 +0200
parents 3078fd1074e8
children d7a9135ec789
comparison
equal deleted inserted replaced
451:8ad70c5cd5d7 452:3d3049ae1304
4865 there to mark all reachable objects. All roots that are traversed are 4865 there to mark all reachable objects. All roots that are traversed are
4866 shown in their processed order: 4866 shown in their processed order:
4867 @itemize @bullet 4867 @itemize @bullet
4868 @item 4868 @item
4869 all constant symbols and static variables that are registered via 4869 all constant symbols and static variables that are registered via
4870 @code{staticpro}@ in the array @code{staticvec}. 4870 @code{staticpro}@ in the dynarr @code{staticpros}.
4871 @xref{Adding Global Lisp Variables}. 4871 @xref{Adding Global Lisp Variables}.
4872 @item 4872 @item
4873 all Lisp objects that are created in C functions and that must be 4873 all Lisp objects that are created in C functions and that must be
4874 protected from freeing them. They are registered in the global 4874 protected from freeing them. They are registered in the global
4875 list @code{gcprolist}. 4875 list @code{gcprolist}.
5875 external descriptions. This happens essentially because we need to 5875 external descriptions. This happens essentially because we need to
5876 follow pointers to C structures and opaque data in addition to 5876 follow pointers to C structures and opaque data in addition to
5877 Lisp_Object members. 5877 Lisp_Object members.
5878 @end enumerate 5878 @end enumerate
5879 5879
5880 This is done by @code{pdump_register_object}, which handles Lisp_Object 5880 This is done by @code{pdump_register_object()}, which handles Lisp_Object
5881 variables, and pdump_register_struct which handles C structures, which 5881 variables, and @code{pdump_register_struct()} which handles C structures,
5882 both delegate the description management to pdump_register_sub. 5882 which both delegate the description management to @code{pdump_register_sub()}.
5883 5883
5884 The hash table doubles as a map object to pdump_entry_list_elmt (i.e. 5884 The hash table doubles as a map object to pdump_entry_list_elmt (i.e.
5885 allows us to look up a pdump_entry_list_elmt with the object it points 5885 allows us to look up a pdump_entry_list_elmt with the object it points
5886 to). Entries are added with @code{pdump_add_entry()} and looked up with 5886 to). Entries are added with @code{pdump_add_entry()} and looked up with
5887 @code{pdump_get_entry()}. There is no need for entry removal. The hash 5887 @code{pdump_get_entry()}. There is no need for entry removal. The hash
5894 @item 5894 @item
5895 the @code{staticpro}'ed variables (there is a special @code{staticpro_nodump()} 5895 the @code{staticpro}'ed variables (there is a special @code{staticpro_nodump()}
5896 call for protected variables we do not want to dump). 5896 call for protected variables we do not want to dump).
5897 5897
5898 @item 5898 @item
5899 the @code{pdump_wire}'d variables (@code{staticpro()} is equivalent to 5899 the variables registered via @code{dump_add_root_object}
5900 @code{staticpro_nodump()} + @code{pdump_wire()}). 5900 (@code{staticpro()} is equivalent to @code{staticpro_nodump()} +
5901 5901 @code{dump_add_root_object()}).
5902 @item 5902
5903 the @code{dumpstruct}'ed variables, which points to C structures. 5903 @item
5904 the variables registered via @code{dump_add_root_struct_ptr}, each of
5905 which points to a C structure.
5904 @end enumerate 5906 @end enumerate
5905 5907
5906 This does not include the GCPRO'ed variables, the specbinds, the 5908 This does not include the GCPRO'ed variables, the specbinds, the
5907 catchtags, the backlist, the redisplay or the profiling info, since we 5909 catchtags, the backlist, the redisplay or the profiling info, since we
5908 do not want to rebuild the actual chain of lisp calls which end up to 5910 do not want to rebuild the actual chain of lisp calls which end up to
5951 5953
5952 @node The header, Data dumping, Address allocation, Dumping phase 5954 @node The header, Data dumping, Address allocation, Dumping phase
5953 @subsection The header 5955 @subsection The header
5954 5956
5955 The next step creates the file and writes a header with a signature and 5957 The next step creates the file and writes a header with a signature and
5956 some random information in it (number of staticpro, number of assigned 5958 some random information in it. The @code{reloc_address} field, which
5957 lrecord types, etc...). The reloc_address field, which indicates at 5959 indicates at which address the file should be loaded if we want to avoid
5958 which address the file should be loaded if we want to avoid post-reload 5960 post-reload relocation, is set to 0. It then seeks to offset 256 (base
5959 relocation, is set to 0. It then seeks to offset 256 (base offset for 5961 offset for the objects).
5960 the objects).
5961 5962
5962 @node Data dumping, Pointers dumping, The header, Dumping phase 5963 @node Data dumping, Pointers dumping, The header, Dumping phase
5963 @subsection Data dumping 5964 @subsection Data dumping
5964 5965
5965 The data is dumped in the same order as the addresses were allocated by 5966 The data is dumped in the same order as the addresses were allocated by
5977 A bunch of tables needed to reassign properly the global pointers are 5978 A bunch of tables needed to reassign properly the global pointers are
5978 then written. They are: 5979 then written. They are:
5979 5980
5980 @enumerate 5981 @enumerate
5981 @item 5982 @item
5982 the staticpro array 5983 the pdump_root_struct_ptrs dynarr
5983 @item 5984 @item
5984 the dumpstruct array 5985 the pdump_opaques dynarr
5985 @item
5986 the lrecord_implementation_table array
5987 @item 5986 @item
5988 a vector of all the offsets to the objects in the file that include a 5987 a vector of all the offsets to the objects in the file that include a
5989 description (for faster relocation at reload time) 5988 description (for faster relocation at reload time)
5990 @item 5989 @item
5991 the pdump_wire and pdump_wire_list arrays 5990 the pdump_root_objects and pdump_weak_object_chains dynarrs.
5992 @end enumerate 5991 @end enumerate
5993 5992
5994 For each of the arrays we write both the pointer to the variables and 5993 For each of the dynarrs we write both the pointer to the variables and
5995 the relocated offset of the object they point to. Since these variables 5994 the relocated offset of the object they point to. Since these variables
5996 are global, the pointers are still valid when restarting the program and 5995 are global, the pointers are still valid when restarting the program and
5997 are used to regenerate the global pointers. 5996 are used to regenerate the global pointers.
5998 5997
5999 The @code{pdump_wire_list} array is a special case. The variables it 5998 The @code{pdump_weak_object_chains} dynarr is a special case. The
6000 points to are the head of weak linked lists of lisp objects of the same 5999 variables it points to are the head of weak linked lists of lisp objects
6001 type. Not all objects of this list are dumped so the relocated pointer 6000 of the same type. Not all objects of this list are dumped so the
6002 we associate with them points to the first dumped object of the list, or 6001 relocated pointer we associate with them points to the first dumped
6003 Qnil if none is available. This is also the reason why they are not 6002 object of the list, or Qnil if none is available. This is also the
6004 used as roots for the purpose of object enumeration. 6003 reason why they are not used as roots for the purpose of object
6004 enumeration.
6005
6006 Some very important information like the @code{staticpros} and
6007 @code{lrecord_implementations_table} are handled indirectly using
6008 @code{dump_add_opaque} or @code{dump_add_root_struct_ptr}.
6005 6009
6006 This is the end of the dumping part. 6010 This is the end of the dumping part.
6007 6011
6008 @node Reloading phase, Remaining issues, Dumping phase, Dumping 6012 @node Reloading phase, Remaining issues, Dumping phase, Dumping
6009 @section Reloading phase 6013 @section Reloading phase
6018 6022
6019 The difference between the actual loading address and the reloc_address 6023 The difference between the actual loading address and the reloc_address
6020 is computed and will be used for all the relocations. 6024 is computed and will be used for all the relocations.
6021 6025
6022 6026
6023 @subsection Putting back the staticvec 6027 @subsection Putting back the pdump_opaques
6024 6028
6025 The staticvec array is memcpy'd from the file and the variables it 6029 The memory contents are restored in the obvious and trivial way.
6026 points to are reset to the relocated objects addresses. 6030
6027 6031
6028 6032 @subsection Putting back the pdump_root_struct_ptrs
6029 @subsection Putting back the dumpstructed variables 6033
6030 6034 The variables pointed to by pdump_root_struct_ptrs in the dump phase are
6031 The variables pointed to by dumpstruct in the dump phase are reset to 6035 reset to the right relocated object addresses.
6032 the right relocated object addresses.
6033
6034
6035 @subsection lrecord_implementations_table
6036
6037 The lrecord_implementations_table is reset to its dump time state and
6038 the right lrecord_type_index values are put in.
6039 6036
6040 6037
6041 @subsection Object relocation 6038 @subsection Object relocation
6042 6039
6043 All the objects are relocated using their description and their offset 6040 All the objects are relocated using their description and their offset
6044 by @code{pdump_reloc_one}. This step is unnecessary if the 6041 by @code{pdump_reloc_one}. This step is unnecessary if the
6045 reloc_address is equal to the file loading address. 6042 reloc_address is equal to the file loading address.
6046 6043
6047 6044
6048 @subsection Putting back the pdump_wire and pdump_wire_list variables 6045 @subsection Putting back the pdump_root_objects and pdump_weak_object_chains
6049 6046
6050 Same as Putting back the dumpstructed variables. 6047 Same as Putting back the pdump_root_struct_ptrs.
6051 6048
6052 6049
6053 @subsection Reorganize the hash tables 6050 @subsection Reorganize the hash tables
6054 6051
6055 Since some of the hash values in the lisp hash tables are 6052 Since some of the hash values in the lisp hash tables are