comparison src/dumper.c @ 2720:6fa9919a9a0b

[xemacs-hg @ 2005-04-08 23:10:01 by crestani] ChangeLog addition: 2005-04-01  Marcus Crestani  <crestani@xemacs.org>         The new allocator.         New configure flag: `MC_ALLOC':         * configure.ac (XE_COMPLEX_ARG_ENABLE): Add `--enable-mc-alloc' as         a new configure flag.         * configure.in (AC_INIT_PARSE_ARGS): Add `--mc-alloc' as a new         configure flag.         * configure.usage: Add description for `mc-alloc'.         DUMP_IN_EXEC:         * Makefile.in.in: Condition the installation of a separate dump         file on !DUMP_ON_EXEC.         * configure.ac (XE_COMPLEX_ARG_ENABLE): Add         `--enable-dump-in-exec' as a new configure flag.         * configure.ac: DUMP_IN_EXEC is define as default for PDUMP but         not default for MC_ALLOC.         * configure.in (AC_INIT_PARSE_ARGS): Add `--dump-in-exec' as a         new configure flag.         * configure.in: DUMP_IN_EXEC is define as default for PDUMP but         not default for MC_ALLOC.         * configure.usage: Add description for `dump-in-exec'. lib-src/ChangeLog addition: 2005-04-01  Marcus Crestani  <crestani@xemacs.org>         The new allocator.         DUMP_IN_EXEC:                  * Makefile.in.in: Only compile insert-data-in-exec if         DUMP_IN_EXEC is defined. lisp/ChangeLog addition: 2005-04-01  Marcus Crestani  <crestani@xemacs.org>         The new allocator.         MEMORY_USAGE_STATS         * diagnose.el: Add new lisp function to pretty print statistics         about the new allocator.         * diagnose.el (show-mc-alloc-memory-usage): New. modules/ChangeLog addition: 2005-04-01  Marcus Crestani  <crestani@xemacs.org>         The new allocator.         Remove Lcrecords:                  * postgresql/postgresql.c (allocate_pgconn): Allocate with new         allocator.         * postgresql/postgresql.c (allocate_pgresult): Allocate PGresult         with new allocator.           * postgresql/postgresql.h (struct Lisp_PGconn): Add         lrecord_header.         * postgresql/postgresql.h (struct Lisp_PGresult): Add         lrecord_header.         * ldap/eldap.c (allocate_ldap): Allocate with new allocator.         * ldap/eldap.h (struct Lisp_LDAP): Add lrecord_header. nt/ChangeLog addition: 2005-04-01  Marcus Crestani  <crestani@xemacs.org>         The new allocator.         New configure flag: `MC_ALLOC':         * config.inc.samp: Add new flag `MC_ALLOC'.         * xemacs.mak: Add flag and configuration output for `MC_ALLOC'.         New files:         * xemacs.dsp: Add source files mc-alloc.c and mc-alloc.h.         * xemacs.mak: Add new object file mc-alloc.obj to dependencies. src/ChangeLog addition: 2005-04-01  Marcus Crestani  <crestani@xemacs.org>         The new allocator.         New configure flag: `MC_ALLOC':         * config.h.in: Add new flag `MC_ALLOC'.         New files:         * Makefile.in.in: Add new object file mc-alloc.o.         * depend: Add new files to dependencies.         * mc-alloc.c: New.         * mc-alloc.h: New.         Running the new allocator from XEmacs:         * alloc.c (deadbeef_memory): Moved to mc-alloc.c.         * emacs.c (main_1): Initialize the new allocator and add         syms_of_mc_alloc.         * symsinit.h: Add syms_of_mc_alloc.         New lrecord allocation and free functions:         * alloc.c (alloc_lrecord): New. Allocates an lrecord, includes         type checking and initializing of the lrecord_header.         * alloc.c (noseeum_alloc_lrecord): Same as above, but increments         the NOSEEUM cons counter.         * alloc.c (free_lrecord): New. Calls the finalizer and frees the         lrecord.         * lrecord.h: Add lrecord allocation prototypes and comments.         Remove old lrecord FROB block allocation:                  * alloc.c (allocate_lisp_storage): Former function to expand         heap. Not needed anymore, remove.         * alloc.c: Completely remove `Fixed-size type macros'         * alloc.c (release_breathing_space): Remove.         * alloc.c (memory_full): Remove release_breathing_space.         * alloc.c (refill_memory_reserve): Remove.         * alloc.c (TYPE_ALLOC_SIZE): Remove.         * alloc.c (DECLARE_FIXED_TYPE_ALLOC): Remove.         * alloc.c (ALLOCATE_FIXED_TYPE_FROM_BLOCK): Remove.         * alloc.c (ALLOCATE_FIXED_TYPE_1): Remove.         * alloc.c (ALLOCATE_FIXED_TYPE): Remove.         * alloc.c (NOSEEUM_ALLOCATE_FIXED_TYPE): Remove.         * alloc.c (struct Lisp_Free): Remove.         * alloc.c (LRECORD_FREE_P): Remove.         * alloc.c (MARK_LRECORD_AS_FREE): Remove.         * alloc.c (MARK_LRECORD_AS_NOT_FREE): Remove.         * alloc.c (PUT_FIXED_TYPE_ON_FREE_LIST): Remove.         * alloc.c (FREE_FIXED_TYPE): Remove.         * alloc.c (FREE_FIXED_TYPE_WHEN_NOT_IN_GC): Remove.         Allocate old lrecords with new allocator:                  * alloc.c: DECLARE_FIXED_TYPE_ALLOC removed for all lrecords         defined in alloc.c.         * alloc.c (Fcons): Allocate with new allocator.         * alloc.c (noseeum_cons): Allocate with new allocator.         * alloc.c (make_float): Allocate with new allocator.         * alloc.c (make_bignum): Allocate with new allocator.         * alloc.c (make_bignum_bg): Allocate with new allocator.         * alloc.c (make_ratio): Allocate with new allocator.         * alloc.c (make_ratio_bg): Allocate with new allocator.         * alloc.c (make_ratio_rt): Allocate with new allocator.         * alloc.c (make_bigfloat): Allocate with new allocator.         * alloc.c (make_bigfloat_bf): Allocate with new allocator.         * alloc.c (make_compiled_function): Allocate with new allocator.         * alloc.c (Fmake_symbol): Allocate with new allocator.         * alloc.c (allocate_extent): Allocate with new allocator.         * alloc.c (allocate_event): Allocate with new allocator.         * alloc.c (make_key_data): Allocate with new allocator.         * alloc.c (make_button_data): Allocate with new allocator.         * alloc.c (make_motion_data): Allocate with new allocator.         * alloc.c (make_process_data): Allocate with new allocator.         * alloc.c (make_timeout_data): Allocate with new allocator.         * alloc.c (make_magic_data): Allocate with new allocator.         * alloc.c (make_magic_eval_data): Allocate with new allocator.         * alloc.c (make_eval_data): Allocate with new allocator.         * alloc.c (make_misc_user_data): Allocate with new allocator.         * alloc.c (Fmake_marker): Allocate with new allocator.         * alloc.c (noseeum_make_marker): Allocate with new allocator.         * alloc.c (make_uninit_string): Allocate with new allocator.         * alloc.c (resize_string): Allocate with new allocator.         * alloc.c (make_string_nocopy): Allocate with new allocator.         Garbage Collection:         * alloc.c (GC_CHECK_NOT_FREE): Remove obsolete assertions.         * alloc.c (SWEEP_FIXED_TYPE_BLOCK): Remove.         * alloc.c (SWEEP_FIXED_TYPE_BLOCK_1): Remove.         * alloc.c (sweep_conses): Remove.         * alloc.c (free_cons): Use new allocator to free.         * alloc.c (sweep_compiled_functions): Remove.         * alloc.c (sweep_floats): Remove.         * alloc.c (sweep_bignums): Remove.         * alloc.c (sweep_ratios): Remove.         * alloc.c (sweep_bigfloats): Remove.         * alloc.c (sweep_symbols): Remove.         * alloc.c (sweep_extents): Remove.         * alloc.c (sweep_events): Remove.         * alloc.c (sweep_key_data): Remove.         * alloc.c (free_key_data): Use new allocator to free.         * alloc.c (sweep_button_data): Remove.         * alloc.c (free_button_data): Use new allocator to free.         * alloc.c (sweep_motion_data): Remove.         * alloc.c (free_motion_data): Use new allocator to free.         * alloc.c (sweep_process_data): Remove.         * alloc.c (free_process_data): Use new allocator to free.         * alloc.c (sweep_timeout_data): Remove.         * alloc.c (free_timeout_data): Use new allocator to free.         * alloc.c (sweep_magic_data): Remove.         * alloc.c (free_magic_data): Use new allocator to free.         * alloc.c (sweep_magic_eval_data): Remove.         * alloc.c (free_magic_eval_data): Use new allocator to free.         * alloc.c (sweep_eval_data): Remove.         * alloc.c (free_eval_data): Use new allocator to free.         * alloc.c (sweep_misc_user_data): Remove.         * alloc.c (free_misc_user_data): Use new allocator to free.         * alloc.c (sweep_markers): Remove.         * alloc.c (free_marker): Use new allocator to free.         * alloc.c (garbage_collect_1): Remove release_breathing_space.         * alloc.c (gc_sweep): Remove all the old lcrecord and lrecord         related stuff. Sweeping now works like this: compact string         chars, finalize, sweep.         * alloc.c (common_init_alloc_early): Remove old lrecord         initializations, remove breathing_space.         * emacs.c (Fdump_emacs): Remove release_breathing_space.         * lisp.h: Remove prototype for release_breathing_space.         * lisp.h: Adjust the special cons mark makros.         Lrecord Finalizer:         * alloc.c: Add finalizer to lrecord definition.         * alloc.c (finalize_string): Add finalizer for string.         * bytecode.c: Add finalizer to lrecord definition.         * bytecode.c (finalize_compiled_function): Add finalizer for         compiled function.         * marker.c: Add finalizer to lrecord definition.         * marker.c (finalize_marker): Add finalizer for marker.         These changes build the interface to mc-alloc:         * lrecord.h (MC_ALLOC_CALL_FINALIZER): Tell mc-alloc how to         finalize lrecords.         * lrecord.h (MC_ALLOC_CALL_FINALIZER_FOR_DISKSAVE): Tell         mc-alloc how to finalize for disksave.         Unify lrecords and lcrecords:         * lisp.h (struct Lisp_String): Adjust string union hack to         new lrecord header.         * lrecord.h: Adjust comments.         * lrecord.h (struct lrecord_header): The new lrecord header         includes type, lisp-readonly, free, and uid.         * lrecord.h (set_lheader_implementation): Adjust to new         lrecord_header.         * lrecord.h (struct lrecord_implementation): The field basic_p         for indication of an old lrecord is not needed anymore, remove.         * lrecord.h (MAKE_LRECORD_IMPLEMENTATION): Remove basic_p.         * lrecord.h (MAKE_EXTERNAL_LRECORD_IMPLEMENTATION): Remove         basic_p.         * lrecord.h (copy_sized_lrecord): Remove distinction between         old lrecords and lcrecords.         * lrecord.h (copy_lrecord): Remove distinction between old         lrecords and lcrecords.         * lrecord.h (zero_sized_lrecord): Remove distinction between         old lrecords and lcrecords.         * lrecord.h (zero_lrecord): Remove distinction between old         lrecords and lcrecords.         Remove lcrecords and lcrecord lists:         * alloc.c (basic_alloc_lcrecord): Not needed anymore, remove.         * alloc.c (very_old_free_lcrecord): Not needed anymore, remove.         * alloc.c (copy_lisp_object): No more distinction between         lrecords and lcrecords.         * alloc.c (all_lcrecords): Not needed anymore, remove.         * alloc.c (make_vector_internal): Allocate as lrecord.         * alloc.c (make_bit_vector_internal): Allocate as lrecord.         * alloc.c: Completely remove `lcrecord lists'.         * alloc.c (free_description): Remove.         * alloc.c (lcrecord_list_description): Remove.         * alloc.c (mark_lcrecord_list): Remove.         * alloc.c (make_lcrecord_list): Remove.         * alloc.c (alloc_managed_lcrecord): Remove.         * alloc.c (free_managed_lcrecord): Remove.         * alloc.c (alloc_automanaged_lcrecord): Remove.         * alloc.c (free_lcrecord): Remove.         * alloc.c (lcrecord_stats): Remove.         * alloc.c (tick_lcrecord_stats): Remove.         * alloc.c (disksave_object_finalization_1): Add call to         mc_finalize_for_disksave. Remove the lcrecord way to visit all         objects.         * alloc.c (kkcc_marking): Remove XD_FLAG_FREE_LISP_OBJECT         * alloc.c (sweep_lcrecords_1): Remove.         * alloc.c (common_init_alloc_early): Remove everything related         to lcrecords, remove old lrecord initializations,         * alloc.c (init_lcrecord_lists): Not needed anymore, remove.         * alloc.c (reinit_alloc_early): Remove everything related to         lcrecords.         * alloc.c (init_alloc_once_early): Remove everything related to         lcrecords.         * buffer.c (allocate_buffer): Allocate as lrecord.         * buffer.c (nuke_all_buffer_slots): Use lrecord functions.         * buffer.c (common_init_complex_vars_of_buffer): Allocate as         lrecord.         * buffer.h (struct buffer): Add lrecord_header.         * casetab.c (allocate_case_table): Allocate as lrecord.         * casetab.h (struct Lisp_Case_Table): Add lrecord_header.         * charset.h (struct Lisp_Charset): Add lrecord_header.         * chartab.c (fill_char_table): Use lrecord functions.         * chartab.c (Fmake_char_table): Allocate as lrecord.         * chartab.c (make_char_table_entry): Allocate as lrecord.         * chartab.c (copy_char_table_entry): Allocate as lrecord.         * chartab.c (Fcopy_char_table): Allocate as lrecord.         * chartab.c (put_char_table): Use lrecord functions.         * chartab.h (struct Lisp_Char_Table_Entry): Add lrecord_header.         * chartab.h (struct Lisp_Char_Table): Add lrecord_header.         * console-impl.h (struct console): Add lrecord_header.         * console-msw-impl.h (struct Lisp_Devmode): Add lrecord_header.         * console-msw-impl.h (struct mswindows_dialog_id): Add         lrecord_header.         * console.c (allocate_console): Allocate as lrecord.         * console.c (nuke_all_console_slots): Use lrecord functions.         * console.c (common_init_complex_vars_of_console): Allocate as         lrecord.         * data.c (make_weak_list): Allocate as lrecord.         * data.c (make_weak_box): Allocate as lrecord.         * data.c (make_ephemeron): Allocate as lrecord.         * database.c (struct Lisp_Database): Add lrecord_header.         * database.c (allocate_database): Allocate as lrecord.         * device-impl.h (struct device): Add lrecord_header.         * device-msw.c (allocate_devmode): Allocate as lrecord.         * device.c (nuke_all_device_slots): Use lrecord functions.         * device.c (allocate_device): Allocate as lrecord.         * dialog-msw.c (handle_question_dialog_box): Allocate as lrecord.         * elhash.c (struct Lisp_Hash_Table): Add lrecord_header.         * elhash.c (make_general_lisp_hash_table): Allocate as lrecord.         * elhash.c (Fcopy_hash_table): Allocate as lrecord.         * event-stream.c: Lcrecord lists Vcommand_builder_free_list and         Vtimeout_free_list are no longer needed. Remove.         * event-stream.c (allocate_command_builder): Allocate as lrecord.         * event-stream.c (free_command_builder): Use lrecord functions.         * event-stream.c (event_stream_generate_wakeup): Allocate as         lrecord.         * event-stream.c (event_stream_resignal_wakeup): Use lrecord         functions.         * event-stream.c (event_stream_disable_wakeup): Use lrecord         functions.         * event-stream.c (reinit_vars_of_event_stream): Lcrecord lists         remove.         * events.h (struct Lisp_Timeout): Add lrecord_header.         * events.h (struct command_builder): Add lrecord_header.         * extents-impl.h (struct extent_auxiliary): Add lrecord_header.         * extents-impl.h (struct extent_info): Add lrecord_header.         * extents.c (allocate_extent_auxiliary): Allocate as lrecord.         * extents.c (allocate_extent_info): Allocate as lrecord.         * extents.c (copy_extent): Allocate as lrecord.         * faces.c (allocate_face): Allocate as lrecord.         * faces.h (struct Lisp_Face): Add lrecord_header.         * file-coding.c (allocate_coding_system): Allocate as lrecord.         * file-coding.c (Fcopy_coding_system): Allocate as lrecord.         * file-coding.h (struct Lisp_Coding_System): Add lrecord_header.         * fns.c (Ffillarray): Allocate as lrecord.         * frame-impl.h (struct frame): Add lrecord_header.         * frame.c (nuke_all_frame_slots): Use lrecord functions.         * frame.c (allocate_frame_core): Allocate as lrecord.         * glyphs.c (allocate_image_instance): Allocate as lrecord.         * glyphs.c (Fcolorize_image_instance): Allocate as lrecord.         * glyphs.c (allocate_glyph): Allocate as lrecord.         * glyphs.h (struct Lisp_Image_Instance): Add lrecord_header.         * glyphs.h (struct Lisp_Glyph): Add lrecord_header.         * gui.c (allocate_gui_item): Allocate as lrecord.         * gui.h (struct Lisp_Gui_Item): Add lrecord_header.         * keymap.c (struct Lisp_Keymap): Add lrecord_header.         * keymap.c (make_keymap): Allocate as lrecord.         * lisp.h (struct Lisp_Vector): Add lrecord_header.         * lisp.h (struct Lisp_Bit_Vector): Add lrecord_header.         * lisp.h (struct weak_box): Add lrecord_header.         * lisp.h (struct ephemeron): Add lrecord_header.         * lisp.h (struct weak_list): Add lrecord_header.         * lrecord.h (struct lcrecord_header): Not used, remove.         * lrecord.h (struct free_lcrecord_header): Not used, remove.         * lrecord.h (struct lcrecord_list): Not needed anymore, remove.         * lrecord.h (lcrecord_list): Not needed anymore, remove.         * lrecord.h: (enum data_description_entry_flags): Remove         XD_FLAG_FREE_LISP_OBJECT.         * lstream.c: Lrecord list Vlstream_free_list remove.         * lstream.c (Lstream_new): Allocate as lrecord.         * lstream.c (Lstream_delete): Use lrecod functions.         * lstream.c (reinit_vars_of_lstream): Vlstream_free_list         initialization remove.           * lstream.h (struct lstream): Add lrecord_header.         * emacs.c (main_1): Remove lstream initialization.         * mule-charset.c (make_charset): Allocate as lrecord.         * objects-impl.h (struct Lisp_Color_Instance): Add         lrecord_header.         * objects-impl.h (struct Lisp_Font_Instance): Add lrecord_header.         * objects.c (Fmake_color_instance): Allocate as lrecord.         * objects.c (Fmake_font_instance): Allocate as lrecord.         * objects.c (reinit_vars_of_objects): Allocate as lrecord.         * opaque.c: Lcreord list Vopaque_ptr_list remove.         * opaque.c (make_opaque): Allocate as lrecord.         * opaque.c (make_opaque_ptr): Allocate as lrecord.         * opaque.c (free_opaque_ptr): Use lrecord functions.         * opaque.c (reinit_opaque_early):         * opaque.c (init_opaque_once_early): Vopaque_ptr_list         initialization remove.         * opaque.h (Lisp_Opaque): Add lrecord_header.         * opaque.h (Lisp_Opaque_Ptr): Add lrecord_header.         * emacs.c (main_1): Remove opaque variable initialization.         * print.c (default_object_printer): Use new lrecord_header.         * print.c (print_internal): Use new lrecord_header.         * print.c (debug_p4): Use new lrecord_header.         * process.c (make_process_internal): Allocate as lrecord.         * procimpl.h (struct Lisp_Process): Add lrecord_header.         * rangetab.c (Fmake_range_table): Allocate as lrecord.         * rangetab.c (Fcopy_range_table): Allocate as lrecord.         * rangetab.h (struct Lisp_Range_Table): Add lrecord_header.         * scrollbar.c (create_scrollbar_instance): Allocate as lrecord.         * scrollbar.h (struct scrollbar_instance): Add lrecord_header.         * specifier.c (make_specifier_internal): Allocate as lrecord.         * specifier.h (struct Lisp_Specifier): Add lrecord_header.         * symbols.c:         * symbols.c (Fmake_variable_buffer_local): Allocate as lrecord.         * symbols.c (Fdontusethis_set_symbol_value_handler): Allocate         as lrecord.         * symbols.c (Fdefvaralias): Allocate as lrecord.         * symeval.h (struct symbol_value_magic): Add lrecord_header.         * toolbar.c (update_toolbar_button): Allocate as lrecord.         * toolbar.h (struct toolbar_button): Add lrecord_header.         * tooltalk.c (struct Lisp_Tooltalk_Message): Add lrecord_header.         * tooltalk.c (make_tooltalk_message): Allocate as lrecord.         * tooltalk.c (struct Lisp_Tooltalk_Pattern): Add lrecord_header.         * tooltalk.c (make_tooltalk_pattern): Allocate as lrecord.         * ui-gtk.c (allocate_ffi_data): Allocate as lrecord.         * ui-gtk.c (allocate_emacs_gtk_object_data): Allocate as lrecord.         * ui-gtk.c (allocate_emacs_gtk_boxed_data): Allocate as lrecord.         * ui-gtk.h (structs): Add lrecord_header.         * window-impl.h (struct window): Add lrecord_header.         * window-impl.h (struct window_mirror): Add lrecord_header.         * window.c (allocate_window): Allocate as lrecord.         * window.c (new_window_mirror): Allocate as lrecord.         * window.c (make_dummy_parent): Allocate as lrecord.         MEMORY_USAGE_STATS         * alloc.c (fixed_type_block_overhead): Not used anymore, remove.         * buffer.c (compute_buffer_usage): Get storage size from new         allocator.         * marker.c (compute_buffer_marker_usage): Get storage size from         new allocator.         * mule-charset.c (compute_charset_usage): Get storage size from         new allocator.         * scrollbar-gtk.c (gtk_compute_scrollbar_instance_usage): Get         storage size from new allocator.         * scrollbar-msw.c (mswindows_compute_scrollbar_instance_usage):         Get storage size from new allocator.         * scrollbar-x.c (x_compute_scrollbar_instance_usage): Get         storage size from new allocator.         * scrollbar.c (compute_scrollbar_instance_usage): Get storage         size from new allocator.         * unicode.c (compute_from_unicode_table_size_1): Get storage         size from new allocator.         * unicode.c (compute_to_unicode_table_size_1): Get storage size         from new allocator.         * window.c (compute_window_mirror_usage): Get storage size from         new allocator.         * window.c (compute_window_usage): Get storage size from new         allocator.         MC_ALLOC_TYPE_STATS:         * alloc.c (alloc_lrecord): Bump lrecord count.         * alloc.c (noseeum_alloc_lrecord): Bump lrecord count.         * alloc.c (struct lrecord_stats): Storage for counts.         * alloc.c (init_lrecord_stats): Zero statistics.         * alloc.c (inc_lrecord_stats): Increase the statistic.         * alloc.c (dec_lrecord_stats): Decrease the statistic.         * alloc.c (gc_plist_hack): Used to print the information.         * alloc.c (Fgarbage_collect): Return the collected information.         * mc-alloc.c (remove_cell): Decrease lrecord count.         * mc-alloc.h: Set flag MC_ALLOC_TYPE_STATS.         * emacs.c (main_1): Init lrecord statistics.         * lrecord.h: Add prototypes for *_lrecord_stats.         Strings:         * alloc.c (Fmake_string): Initialize ascii_begin to zero.         * alloc.c (gc_count_num_short_string_in_use): Remove.         * alloc.c (gc_count_string_total_size): Remove.         * alloc.c (gc_count_short_string_total_size): Remove.         * alloc.c (debug_string_purity): Remove.         * alloc.c (debug_string_purity_print): Remove.         * alloc.c (sweep_strings): Remove.                  Remove static C-readonly Lisp objects:         * alloc.c (c_readonly): Not needed anymore, remove.         * alloc.c (GC_CHECK_LHEADER_INVARIANTS): Remove some obsolete         lheader invariants assertions.         * buffer.c (DEFVAR_BUFFER_LOCAL_1): Allocate dynamically.         * console.c (DEFVAR_CONSOLE_LOCAL_1): Allocate dynamically.         * gpmevent.c: Indirection via MC_ALLOC_Freceive_gpm_event.         * gpmevent.c (Fgpm_enable): Allocate dynamically.         * gpmevent.c (syms_of_gpmevent): Allocate dynamically.         * lisp.h (C_READONLY): Not needed anymore, remove.         * lisp.h (DEFUN): Allocate dynamically.         * lrecord.h (C_READONLY_RECORD_HEADER_P): Not needed anymore,         remove.         * lrecord.h (SET_C_READONLY_RECORD_HEADER): Not needed anymore,         remove.         * symbols.c (guts_of_unbound_marker):         * symeval.h (defsubr): Allocate dynamically.         * symeval.h (DEFSUBR_MACRO): Allocate dynamically.         * symeval.h (DEFVAR_ SYMVAL_FWD): Allocate dynamically.         * tests.c (TESTS_DEFSUBR): Allocate dynamically.         Definition of mcpro:         * lisp.h: Add mcpro prototypes.         * alloc.c (common_init_alloc_early): Add initialization for         mcpros.         * alloc.c (mcpro_description_1): New.         * alloc.c (mcpro_description): New.         * alloc.c (mcpros_description_1): New.         * alloc.c (mcpros_description): New.         * alloc.c (mcpro_one_name_description_1): New.         * alloc.c (mcpro_one_name_description): New.         * alloc.c (mcpro_names_description_1): New.         * alloc.c (mcpro_names_description): New.         * alloc.c (mcpros): New.         * alloc.c (mcpro_names): New.         * alloc.c (mcpro_1): New.         * alloc.c (mc_pro): New.         * alloc.c (garbage_collect_1): Add mcpros to root set.         Usage of mcpro:         * alloc.c (make_string_nocopy): Add string to root set.         * symbols.c (init_symbols_once_early): Add Qunbound to root set.         Changes to the Portable Dumper:                  * alloc.c (FREE_OR_REALLOC_BEGIN): Since dumped objects can be         freed with the new allocator, remove assertion for !DUMPEDP.         * dumper.c: Adjust comments, increase PDUMP_HASHSIZE.         * dumper.c (pdump_make_hash): Shift address only 2 bytes, to         avoid collisions.         * dumper.c (pdump_objects_unmark): No more mark bits within         the object, remove.         * dumper.c (mc_addr_elt): New. Element data structure for mc         hash table.         * dumper.c (pdump_mc_hash): New hash table: `lookup table'.         * dumper.c (pdump_get_mc_addr): New. Lookup for hash table.         * dumper.c (pdump_get_indirect_mc_addr): New. Lookup for         convertibles.         * dumper.c (pdump_put_mc_addr): New. Putter for hash table.         * dumper.c (pdump_dump_mc_data): New. Writes the table for         relocation at load time to the dump file.         * dumper.c (pdump_scan_lisp_objects_by_alignment): New.         Visits all dumped Lisp objects.         * dumper.c (pdump_scan_non_lisp_objects_by_alignment): New.         Visits all other dumped objects.         * dumper.c (pdump_reloc_one_mc): New. Updates all pointers         of an object by using the hash table pdump_mc_hash.         * dumper.c (pdump_reloc_one): Replaced by pdump_reloc_one_mc.         * dumper.c (pdump): Change the structure of the dump file, add         the mc post dump relocation table to dump file.         * dumper.c (pdump_load_finish): Hand all dumped objects to the         new allocator and use the mc post dump relocation table for         relocating the dumped objects at dump file load time, free not         longer used data structures.         * dumper.c (pdump_load): Free the dump file.         * dumper.h: Remove pdump_objects_unmark.         * lrecord.h (DUMPEDP): Dumped objects can be freed, remove.              DUMP_IN_EXEC:         * Makefile.in.in: Linking for and with dump in executable only if         DUMP_IN_EXEC is defined.         * config.h.in: Add new flag `DUMP_IN_EXEC'         * emacs.c: Condition dump-data.h on DUMP_IN_EXEC.         * emacs.c (main_1): Flag `-si' only works if dump image is         written into executable.         Miscellanious         * lrecord.h (enum lrecord_type): Added numbers to all types,         very handy for debugging.         * xemacs.def.in.in: Add mc-alloc functions to make them visible         to the modules.
author crestani
date Fri, 08 Apr 2005 23:11:35 +0000
parents d8df26f08486
children c474585a3460
comparison
equal deleted inserted replaced
2719:5f6ef2b26d9f 2720:6fa9919a9a0b
48 #include "syswindows.h" 48 #include "syswindows.h"
49 #else 49 #else
50 #ifdef HAVE_MMAP 50 #ifdef HAVE_MMAP
51 #include <sys/mman.h> 51 #include <sys/mman.h>
52 #endif 52 #endif
53 #ifdef DUMP_IN_EXEC
53 #include "dump-data.h" 54 #include "dump-data.h"
55 #endif
54 #endif 56 #endif
55 57
56 typedef struct 58 typedef struct
57 { 59 {
58 const void *blockaddr; 60 const void *blockaddr;
233 int count; 235 int count;
234 } pdump_reloc_table; 236 } pdump_reloc_table;
235 237
236 static Rawbyte *pdump_rt_list = 0; 238 static Rawbyte *pdump_rt_list = 0;
237 239
240 #ifndef MC_ALLOC
238 void 241 void
239 pdump_objects_unmark (void) 242 pdump_objects_unmark (void)
240 { 243 {
241 int i; 244 int i;
242 Rawbyte *p = pdump_rt_list; 245 Rawbyte *p = pdump_rt_list;
256 } 259 }
257 } else 260 } else
258 break; 261 break;
259 } 262 }
260 } 263 }
261 264 #endif /* not MC_ALLOC */
262 265
266
267 #ifdef MC_ALLOC
268 /* The structure of the dump file looks like this:
269 0 - header
270 - dumped objects
271 stab_offset - mc allocation table (count, size, address) for individual
272 allocation and relocation at load time.
273 - nb_cv_data*struct(dest, adr) for in-object externally
274 represented data
275 - nb_cv_ptr*(adr) for pointed-to externally represented data
276 - relocation table
277 - nb_root_struct_ptrs*struct(void *, adr)
278 for global pointers to structures
279 - nb_root_blocks*struct(void *, size, info) for global
280 objects to restore
281 - root lisp object address/value couples with the count
282 preceding the list
283 */
284 #else /* not MC_ALLOC */
263 /* The structure of the dump file looks like this: 285 /* The structure of the dump file looks like this:
264 0 - header 286 0 - header
265 - dumped objects 287 - dumped objects
266 stab_offset - nb_cv_data*struct(dest, adr) for in-object externally 288 stab_offset - nb_cv_data*struct(dest, adr) for in-object externally
267 represented data 289 represented data
272 data-segment blocks to restore 294 data-segment blocks to restore
273 - relocation table 295 - relocation table
274 - root lisp object address/value couples with the count 296 - root lisp object address/value couples with the count
275 preceding the list 297 preceding the list
276 */ 298 */
299 #endif /* not MC_ALLOC */
277 300
278 301
279 #define PDUMP_SIGNATURE "XEmacsDP" 302 #define PDUMP_SIGNATURE "XEmacsDP"
280 #define PDUMP_SIGNATURE_LEN (sizeof (PDUMP_SIGNATURE) - 1) 303 #define PDUMP_SIGNATURE_LEN (sizeof (PDUMP_SIGNATURE) - 1)
281 304
409 static Bytecount max_size; 432 static Bytecount max_size;
410 static int pdump_fd; 433 static int pdump_fd;
411 static void *pdump_buf; 434 static void *pdump_buf;
412 static FILE *pdump_out; 435 static FILE *pdump_out;
413 436
437 #if defined (MC_ALLOC)
438 /* With mc_alloc, way more entries are added to the hash tables:
439 increase hash table size to avoid collisions. */
440 #define PDUMP_HASHSIZE 1000001
441 #else /* not MC_ALLOC */
414 #define PDUMP_HASHSIZE 200001 442 #define PDUMP_HASHSIZE 200001
443 #endif /* not MC_ALLOC */
415 444
416 static pdump_block_list_elt **pdump_hash; 445 static pdump_block_list_elt **pdump_hash;
417 446
418 /* Since most pointers are eight bytes aligned, the >>3 allows for a better hash */ 447 /* Since most pointers are eight bytes aligned, the >>3 allows for a better hash */
419 static int 448 static int
420 pdump_make_hash (const void *obj) 449 pdump_make_hash (const void *obj)
421 { 450 {
451 #if defined (MC_ALLOC)
452 /* Use >>2 for a better hash to avoid collisions. */
453 return ((unsigned long)(obj)>>2) % PDUMP_HASHSIZE;
454 #else /* not MC_ALLOC */
422 return ((unsigned long)(obj)>>3) % PDUMP_HASHSIZE; 455 return ((unsigned long)(obj)>>3) % PDUMP_HASHSIZE;
456 #endif /* not MC_ALLOC */
423 } 457 }
424 458
425 /* Return the entry for an already-registered memory block at OBJ, 459 /* Return the entry for an already-registered memory block at OBJ,
426 or NULL if none. */ 460 or NULL if none. */
427 461
481 515
482 if (align < list->align) 516 if (align < list->align)
483 list->align = align; 517 list->align = align;
484 } 518 }
485 } 519 }
520
521 #ifdef MC_ALLOC
522 typedef struct mc_addr_elt
523 {
524 const void *obj;
525 EMACS_INT addr;
526 } mc_addr_elt;
527
528 static mc_addr_elt *pdump_mc_hash;
529
530 /* Return the entry for an already-registered memory block at OBJ,
531 or NULL if none. */
532 static EMACS_INT
533 pdump_get_mc_addr (const void *obj)
534 {
535 int pos = pdump_make_hash (obj);
536 mc_addr_elt *mc_addr;
537
538 assert (obj != 0);
539
540 while ((mc_addr = &pdump_mc_hash[pos]) && (mc_addr->obj != 0))
541 {
542 if (mc_addr->obj == obj)
543 return mc_addr->addr;
544
545 pos++;
546 if (pos == PDUMP_HASHSIZE)
547 pos = 0;
548 }
549
550 /* If this code is reached, an heap address occurred which has not
551 been written to the lookup table before.
552 This is a bug! */
553 ABORT();
554 return 0;
555 }
556
557 /* For indirect address lookups, needed for convertibles: Ptr points
558 to an address within an object. Indirect gives the offset by how
559 many bytes the address of the object has to be adjusted to do a
560 lookup in the mc_addr translation table and get the new location of
561 the data. */
562 #define pdump_get_indirect_mc_addr(ptr, indirect) \
563 pdump_get_mc_addr ((void *)((ptr) - indirect)) + indirect
564
565 static void
566 pdump_put_mc_addr (const void *obj, EMACS_INT addr)
567 {
568 mc_addr_elt *mc_addr;
569 int pos = pdump_make_hash (obj);
570
571 while ((mc_addr = &pdump_mc_hash[pos]) && (mc_addr->obj != 0))
572 {
573 if (mc_addr->obj == obj)
574 return;
575
576 pos++;
577 if (pos == PDUMP_HASHSIZE)
578 pos = 0;
579 }
580
581 pdump_mc_hash[pos].obj = obj;
582 pdump_mc_hash[pos].addr = addr;
583 }
584 #endif /* MC_ALLOC */
486 585
487 static pdump_block_list * 586 static pdump_block_list *
488 pdump_get_block_list (const struct memory_description *desc) 587 pdump_get_block_list (const struct memory_description *desc)
489 { 588 {
490 int i; 589 int i;
1029 pdump_store_new_pointer_offsets (count, pdump_buf, elt->obj, desc, size); 1128 pdump_store_new_pointer_offsets (count, pdump_buf, elt->obj, desc, size);
1030 } 1129 }
1031 retry_fwrite (desc ? pdump_buf : elt->obj, size, count, pdump_out); 1130 retry_fwrite (desc ? pdump_buf : elt->obj, size, count, pdump_out);
1032 } 1131 }
1033 1132
1133 #ifdef MC_ALLOC
1134 /* To be able to relocate during load time, more information about the
1135 dumped objects are needed: The count (for array-like data
1136 structures), the size of the object, and the location in the dumped
1137 data.
1138 */
1139 static void
1140 pdump_dump_mc_data (pdump_block_list_elt *elt,
1141 const struct memory_description *UNUSED(desc))
1142 {
1143 EMACS_INT rdata = pdump_get_block (elt->obj)->save_offset;
1144 int j;
1145 PDUMP_WRITE_ALIGNED (int, elt->count);
1146 PDUMP_WRITE_ALIGNED (Bytecount, elt->size);
1147 for (j = 0; j < elt->count; j++)
1148 {
1149 PDUMP_WRITE_ALIGNED (EMACS_INT, rdata);
1150 rdata += elt->size;
1151 }
1152 }
1153
1154 static void
1155 pdump_scan_lisp_objects_by_alignment (void (*f)
1156 (pdump_block_list_elt *,
1157 const struct memory_description *))
1158 {
1159 int align;
1160
1161 for (align = ALIGNOF (max_align_t); align; align>>=1)
1162 {
1163 int i;
1164 pdump_block_list_elt *elt;
1165
1166 for (i=0; i<lrecord_type_count; i++)
1167 if (pdump_object_table[i].align == align)
1168 for (elt = pdump_object_table[i].first; elt; elt = elt->next)
1169 {
1170 assert (elt->count == 1);
1171 f (elt, lrecord_implementations_table[i]->description);
1172 }
1173 }
1174 }
1175
1176 static void
1177 pdump_scan_non_lisp_objects_by_alignment (void (*f)
1178 (pdump_block_list_elt *,
1179 const struct memory_description *))
1180 {
1181 int align;
1182
1183 for (align = ALIGNOF (max_align_t); align; align>>=1)
1184 {
1185 int i;
1186 pdump_block_list_elt *elt;
1187
1188 for (i=0; i<pdump_desc_table.count; i++)
1189 {
1190 pdump_desc_list_elt list = pdump_desc_table.list[i];
1191 if (list.list.align == align)
1192 for (elt = list.list.first; elt; elt = elt->next)
1193 f (elt, list.desc);
1194 }
1195
1196 for (elt = pdump_opaque_data_list.first; elt; elt = elt->next)
1197 if (pdump_size_to_align (elt->size) == align)
1198 f (elt, 0);
1199 }
1200 }
1201
1202
1203
1204 static void
1205 pdump_reloc_one_mc (void *data, const struct memory_description *desc)
1206 {
1207 int pos;
1208
1209 for (pos = 0; desc[pos].type != XD_END; pos++)
1210 {
1211 const struct memory_description *desc1 = &desc[pos];
1212 void *rdata =
1213 (Rawbyte *) data + lispdesc_indirect_count (desc1->offset,
1214 desc, data);
1215
1216 union_switcheroo:
1217
1218 /* If the flag says don't dump, then don't dump. */
1219 if ((desc1->flags) & XD_FLAG_NO_PDUMP)
1220 continue;
1221
1222 switch (desc1->type)
1223 {
1224 case XD_BYTECOUNT:
1225 case XD_ELEMCOUNT:
1226 case XD_HASHCODE:
1227 case XD_INT:
1228 case XD_LONG:
1229 case XD_INT_RESET:
1230 break;
1231 case XD_OPAQUE_DATA_PTR:
1232 case XD_ASCII_STRING:
1233 case XD_BLOCK_PTR:
1234 case XD_LO_LINK:
1235 {
1236 EMACS_INT ptr = *(EMACS_INT *) rdata;
1237 if (ptr)
1238 *(EMACS_INT *) rdata = pdump_get_mc_addr ((void *) ptr);
1239 break;
1240 }
1241 case XD_LISP_OBJECT:
1242 {
1243 Lisp_Object *pobj = (Lisp_Object *) rdata;
1244
1245 assert (desc1->data1 == 0);
1246
1247 if (POINTER_TYPE_P (XTYPE (*pobj))
1248 && ! EQ (*pobj, Qnull_pointer))
1249 *pobj = wrap_pointer_1 ((char *) pdump_get_mc_addr
1250 (XPNTR (*pobj)));
1251 break;
1252 }
1253 case XD_LISP_OBJECT_ARRAY:
1254 {
1255 EMACS_INT num = lispdesc_indirect_count (desc1->data1, desc,
1256 data);
1257 int j;
1258
1259 for (j=0; j<num; j++)
1260 {
1261 Lisp_Object *pobj = (Lisp_Object *) rdata + j;
1262
1263 if (POINTER_TYPE_P (XTYPE (*pobj))
1264 && ! EQ (*pobj, Qnull_pointer))
1265 *pobj = wrap_pointer_1 ((char *) pdump_get_mc_addr
1266 (XPNTR (*pobj)));
1267 }
1268 break;
1269 }
1270 case XD_DOC_STRING:
1271 {
1272 EMACS_INT str = *(EMACS_INT *) rdata;
1273 if (str > 0)
1274 *(EMACS_INT *) rdata = pdump_get_mc_addr ((void *) str);
1275 break;
1276 }
1277 case XD_BLOCK_ARRAY:
1278 {
1279 EMACS_INT num = lispdesc_indirect_count (desc1->data1, desc,
1280 data);
1281 int j;
1282 const struct sized_memory_description *sdesc =
1283 lispdesc_indirect_description (data, desc1->data2.descr);
1284 Bytecount size = lispdesc_block_size (rdata, sdesc);
1285
1286 /* Note: We are recursing over data in the block itself */
1287 for (j = 0; j < num; j++)
1288 pdump_reloc_one_mc ((Rawbyte *) rdata + j * size,
1289 sdesc->description);
1290
1291 break;
1292 }
1293 case XD_UNION:
1294 case XD_UNION_DYNAMIC_SIZE:
1295 desc1 = lispdesc_process_xd_union (desc1, desc, data);
1296 if (desc1)
1297 goto union_switcheroo;
1298 break;
1299
1300 case XD_OPAQUE_PTR_CONVERTIBLE:
1301 {
1302 pdump_cv_ptr_load_info *p = pdump_loaded_cv_ptr + *(EMACS_INT *)rdata;
1303 if (!p->adr)
1304 p->adr = desc1->data2.funcs->deconvert(0,
1305 pdump_start + p->save_offset,
1306 p->size);
1307 *(void **)rdata = p->adr;
1308 break;
1309 }
1310
1311 case XD_OPAQUE_DATA_CONVERTIBLE:
1312 {
1313 EMACS_INT dest_offset = (EMACS_INT) rdata;
1314 EMACS_INT indirect =
1315 lispdesc_indirect_count (desc1->offset, desc, data);
1316 pdump_cv_data_dump_info *p;
1317
1318 for(p = pdump_loaded_cv_data;
1319 pdump_get_indirect_mc_addr (p->dest_offset, indirect)
1320 != dest_offset;
1321 p++);
1322
1323 desc1->data2.funcs->deconvert(rdata, pdump_start + p->save_offset,
1324 p->size);
1325 break;
1326 }
1327
1328 default:
1329 pdump_unsupported_dump_type (desc1->type, 0);
1330 }
1331 }
1332 }
1333 #else /* not MC_ALLOC */
1034 /* Relocate a single memory block at DATA, described by DESC, from its 1334 /* Relocate a single memory block at DATA, described by DESC, from its
1035 assumed load location to its actual one by adding DELTA to all pointers 1335 assumed load location to its actual one by adding DELTA to all pointers
1036 in the block. Does not recursively relocate any other memory blocks 1336 in the block. Does not recursively relocate any other memory blocks
1037 pointed to. (We already have a list of all memory blocks in the dump 1337 pointed to. (We already have a list of all memory blocks in the dump
1038 file.) This is used once the dump data has been loaded back in, both 1338 file.) This is used once the dump data has been loaded back in, both
1162 default: 1462 default:
1163 pdump_unsupported_dump_type (desc1->type, 0); 1463 pdump_unsupported_dump_type (desc1->type, 0);
1164 } 1464 }
1165 } 1465 }
1166 } 1466 }
1467 #endif /* not MC_ALLOC */
1167 1468
1168 static void 1469 static void
1169 pdump_allocate_offset (pdump_block_list_elt *elt, 1470 pdump_allocate_offset (pdump_block_list_elt *elt,
1170 const struct memory_description *UNUSED (desc)) 1471 const struct memory_description *UNUSED (desc))
1171 { 1472 {
1773 elt->fcts->convert_free(elt->object, elt->data, elt->size); 2074 elt->fcts->convert_free(elt->object, elt->data, elt->size);
1774 } 2075 }
1775 2076
1776 fseek (pdump_out, header.stab_offset, SEEK_SET); 2077 fseek (pdump_out, header.stab_offset, SEEK_SET);
1777 2078
2079 #ifdef MC_ALLOC
2080 {
2081 EMACS_INT zero = 0;
2082 pdump_scan_lisp_objects_by_alignment (pdump_dump_mc_data);
2083 PDUMP_WRITE_ALIGNED (EMACS_INT, zero);
2084 pdump_scan_non_lisp_objects_by_alignment (pdump_dump_mc_data);
2085 PDUMP_WRITE_ALIGNED (EMACS_INT, zero);
2086 }
2087 #endif /* MC_ALLOC */
1778 pdump_dump_cv_data_info (); 2088 pdump_dump_cv_data_info ();
1779 pdump_dump_cv_ptr_info (); 2089 pdump_dump_cv_ptr_info ();
2090 #ifdef MC_ALLOC
2091 pdump_dump_rtables ();
2092 #endif /* MC_ALLOC */
1780 pdump_dump_root_block_ptrs (); 2093 pdump_dump_root_block_ptrs ();
1781 pdump_dump_root_blocks (); 2094 pdump_dump_root_blocks ();
2095 #ifndef MC_ALLOC
1782 pdump_dump_rtables (); 2096 pdump_dump_rtables ();
2097 #endif /* not MC_ALLOC */
1783 pdump_dump_root_lisp_objects (); 2098 pdump_dump_root_lisp_objects ();
1784 2099
1785 retry_fclose (pdump_out); 2100 retry_fclose (pdump_out);
1786 retry_close (pdump_fd); 2101 retry_close (pdump_fd);
1787 2102
1818 pdump_end = pdump_start + pdump_length; 2133 pdump_end = pdump_start + pdump_length;
1819 2134
1820 delta = ((EMACS_INT) pdump_start) - header->reloc_address; 2135 delta = ((EMACS_INT) pdump_start) - header->reloc_address;
1821 p = pdump_start + header->stab_offset; 2136 p = pdump_start + header->stab_offset;
1822 2137
2138 #ifdef MC_ALLOC
2139 pdump_mc_hash = xnew_array_and_zero (mc_addr_elt, PDUMP_HASHSIZE);
2140
2141 /* Allocate space for each object individually. First the
2142 Lisp_Objects, then the blocks. */
2143 count = 2;
2144 for (;;)
2145 {
2146 int elt_count = PDUMP_READ_ALIGNED (p, int);
2147 if (elt_count)
2148 {
2149 Rawbyte *mc_addr = 0;
2150 Bytecount size = PDUMP_READ_ALIGNED (p, Bytecount);
2151 for (i = 0; i < elt_count; i++)
2152 {
2153 EMACS_INT rdata = PDUMP_READ_ALIGNED (p, EMACS_INT);
2154
2155 if (i == 0)
2156 {
2157 Bytecount real_size = size * elt_count;
2158 #ifdef MC_ALLOC
2159 if (count == 2)
2160 mc_addr = (Rawbyte *) mc_alloc (real_size);
2161 else
2162 #endif /* not MC_ALLOC */
2163 mc_addr = (Rawbyte *) xmalloc_and_zero (real_size);
2164 }
2165 else
2166 mc_addr += size;
2167
2168 pdump_put_mc_addr ((void *) rdata, (EMACS_INT) mc_addr);
2169 memcpy (mc_addr, (char *) rdata + delta, size);
2170 }
2171 }
2172 else if (!(--count))
2173 break;
2174 }
2175 #endif /* MC_ALLOC */
2176
1823 /* Get the cv_data array */ 2177 /* Get the cv_data array */
1824 p = (Rawbyte *) ALIGN_PTR (p, pdump_cv_data_dump_info); 2178 p = (Rawbyte *) ALIGN_PTR (p, pdump_cv_data_dump_info);
1825 pdump_loaded_cv_data = (pdump_cv_data_dump_info *)p; 2179 pdump_loaded_cv_data = (pdump_cv_data_dump_info *)p;
1826 p += header->nb_cv_data*sizeof(pdump_cv_data_dump_info); 2180 p += header->nb_cv_data*sizeof(pdump_cv_data_dump_info);
1827 2181
1835 pdump_loaded_cv_ptr[i].save_offset = info.save_offset; 2189 pdump_loaded_cv_ptr[i].save_offset = info.save_offset;
1836 pdump_loaded_cv_ptr[i].size = info.size; 2190 pdump_loaded_cv_ptr[i].size = info.size;
1837 pdump_loaded_cv_ptr[i].adr = 0; 2191 pdump_loaded_cv_ptr[i].adr = 0;
1838 } 2192 }
1839 2193
2194 #ifdef MC_ALLOC
2195 /* Relocate the heap objects */
2196 pdump_rt_list = p;
2197 count = 2;
2198 for (;;)
2199 {
2200 pdump_reloc_table rt = PDUMP_READ_ALIGNED (p, pdump_reloc_table);
2201 p = (Rawbyte *) ALIGN_PTR (p, Rawbyte *);
2202 if (rt.desc)
2203 {
2204 char **reloc = (char **) p;
2205 for (i = 0; i < rt.count; i++)
2206 {
2207 reloc[i] = (char *) pdump_get_mc_addr (reloc[i]);
2208 pdump_reloc_one_mc (reloc[i], rt.desc);
2209 }
2210 p += rt.count * sizeof (char *);
2211 }
2212 else if (!(--count))
2213 break;
2214 }
2215 #endif /* MC_ALLOC */
2216
1840 /* Put back the pdump_root_block_ptrs */ 2217 /* Put back the pdump_root_block_ptrs */
1841 p = (Rawbyte *) ALIGN_PTR (p, pdump_static_pointer); 2218 p = (Rawbyte *) ALIGN_PTR (p, pdump_static_pointer);
1842 for (i = 0; i < header->nb_root_block_ptrs; i++) 2219 for (i = 0; i < header->nb_root_block_ptrs; i++)
1843 { 2220 {
1844 pdump_static_pointer ptr = PDUMP_READ (p, pdump_static_pointer); 2221 pdump_static_pointer ptr = PDUMP_READ (p, pdump_static_pointer);
2222 #ifdef MC_ALLOC
2223 (* ptr.address) = (Rawbyte *) pdump_get_mc_addr (ptr.value);
2224 #else /* not MC_ALLOC */
1845 (* ptr.address) = ptr.value + delta; 2225 (* ptr.address) = ptr.value + delta;
2226 #endif /* not MC_ALLOC */
1846 } 2227 }
1847 2228
1848 /* Put back the pdump_root_blocks and relocate */ 2229 /* Put back the pdump_root_blocks and relocate */
1849 for (i = 0; i < header->nb_root_blocks; i++) 2230 for (i = 0; i < header->nb_root_blocks; i++)
1850 { 2231 {
1851 pdump_root_block info = PDUMP_READ_ALIGNED (p, pdump_root_block); 2232 pdump_root_block info = PDUMP_READ_ALIGNED (p, pdump_root_block);
1852 memcpy ((void *) info.blockaddr, p, info.size); 2233 memcpy ((void *) info.blockaddr, p, info.size);
1853 if (info.desc) 2234 if (info.desc)
2235 #ifdef MC_ALLOC
2236 pdump_reloc_one_mc ((void *) info.blockaddr, info.desc);
2237 #else /* not MC_ALLOC */
1854 pdump_reloc_one ((void *) info.blockaddr, delta, info.desc); 2238 pdump_reloc_one ((void *) info.blockaddr, delta, info.desc);
2239 #endif /* not MC_ALLOC */
1855 p += info.size; 2240 p += info.size;
1856 } 2241 }
1857 2242
2243 #ifndef MC_ALLOC
1858 /* Relocate the heap objects */ 2244 /* Relocate the heap objects */
1859 pdump_rt_list = p; 2245 pdump_rt_list = p;
1860 count = 2; 2246 count = 2;
1861 for (;;) 2247 for (;;)
1862 { 2248 {
1873 p += rt.count * sizeof (Rawbyte *); 2259 p += rt.count * sizeof (Rawbyte *);
1874 } 2260 }
1875 else if (!(--count)) 2261 else if (!(--count))
1876 break; 2262 break;
1877 } 2263 }
2264 #endif /* not MC_ALLOC */
1878 2265
1879 /* Put the pdump_root_lisp_objects variables in place */ 2266 /* Put the pdump_root_lisp_objects variables in place */
1880 i = PDUMP_READ_ALIGNED (p, Elemcount); 2267 i = PDUMP_READ_ALIGNED (p, Elemcount);
1881 p = (Rawbyte *) ALIGN_PTR (p, pdump_static_Lisp_Object); 2268 p = (Rawbyte *) ALIGN_PTR (p, pdump_static_Lisp_Object);
1882 while (i--) 2269 while (i--)
1883 { 2270 {
1884 pdump_static_Lisp_Object obj = PDUMP_READ (p, pdump_static_Lisp_Object); 2271 pdump_static_Lisp_Object obj = PDUMP_READ (p, pdump_static_Lisp_Object);
1885 2272
1886 if (POINTER_TYPE_P (XTYPE (obj.value))) 2273 if (POINTER_TYPE_P (XTYPE (obj.value)))
1887 obj.value = wrap_pointer_1 ((Rawbyte *) XPNTR (obj.value) + delta); 2274 #ifdef MC_ALLOC
2275 obj.value = wrap_pointer_1 ((Rawbyte *) pdump_get_mc_addr
2276 (XPNTR (obj.value)));
2277 #else /* not MC_ALLOC */
2278 obj.value = wrap_pointer_1 ((Rawbyte *) XPNTR (obj.value) + delta);
2279 #endif /* not MC_ALLOC */
1888 2280
1889 (* obj.address) = obj.value; 2281 (* obj.address) = obj.value;
1890 } 2282 }
1891 2283
1892 /* Final cleanups */ 2284 /* Final cleanups */
1906 } 2298 }
1907 else 2299 else
1908 p += sizeof (Lisp_Object) * rt.count; 2300 p += sizeof (Lisp_Object) * rt.count;
1909 } 2301 }
1910 2302
2303 #ifdef MC_ALLOC
2304 xfree (pdump_mc_hash, mc_addr_elt *);
2305 #endif /* MC_ALLOC */
2306
1911 return 1; 2307 return 1;
1912 } 2308 }
1913 2309
1914 #ifdef WIN32_NATIVE 2310 #ifdef WIN32_NATIVE
1915 /* Free the mapped file if we decide we don't want it after all */ 2311 /* Free the mapped file if we decide we don't want it after all */
2067 2463
2068 retry_close (fd); 2464 retry_close (fd);
2069 return 1; 2465 return 1;
2070 } 2466 }
2071 2467
2468 #ifdef DUMP_IN_EXEC
2072 static int 2469 static int
2073 pdump_ram_try (void) 2470 pdump_ram_try (void)
2074 { 2471 {
2075 pdump_start = dumped_data_get (); 2472 pdump_start = dumped_data_get ();
2076 pdump_length = dumped_data_size (); 2473 pdump_length = dumped_data_size ();
2077 2474
2078 return pdump_load_check (); 2475 return pdump_load_check ();
2079 } 2476 }
2477 #endif
2080 2478
2081 #endif /* !WIN32_NATIVE */ 2479 #endif /* !WIN32_NATIVE */
2082 2480
2083 2481
2084 static int 2482 static int
2158 #else /* !WIN32_NATIVE */ 2556 #else /* !WIN32_NATIVE */
2159 Wexttext *exe_path; 2557 Wexttext *exe_path;
2160 Wexttext *w; 2558 Wexttext *w;
2161 const Wexttext *dir, *p; 2559 const Wexttext *dir, *p;
2162 2560
2561 #ifdef DUMP_IN_EXEC
2163 if (pdump_ram_try ()) 2562 if (pdump_ram_try ())
2164 { 2563 {
2165 pdump_load_finish (); 2564 pdump_load_finish ();
2166 in_pdump = 0; 2565 in_pdump = 0;
2167 return 1; 2566 return 1;
2168 } 2567 }
2568 #endif
2169 2569
2170 in_pdump = 1; 2570 in_pdump = 1;
2171 dir = argv0; 2571 dir = argv0;
2172 if (dir[0] == '-') 2572 if (dir[0] == '-')
2173 { 2573 {
2240 2640
2241 if (pdump_file_try (exe_path)) 2641 if (pdump_file_try (exe_path))
2242 { 2642 {
2243 pdump_load_finish (); 2643 pdump_load_finish ();
2244 in_pdump = 0; 2644 in_pdump = 0;
2645 #ifdef MC_ALLOC
2646 pdump_free ();
2647 #endif /* MC_ALLOC */
2245 return 1; 2648 return 1;
2246 } 2649 }
2247 2650
2248 #ifdef WIN32_NATIVE 2651 #ifdef WIN32_NATIVE
2249 if (pdump_resource_get ()) 2652 if (pdump_resource_get ())
2250 { 2653 {
2251 if (pdump_load_check ()) 2654 if (pdump_load_check ())
2252 { 2655 {
2253 pdump_load_finish (); 2656 pdump_load_finish ();
2254 in_pdump = 0; 2657 in_pdump = 0;
2658 #ifdef MC_ALLOC
2659 pdump_free ();
2660 #endif /* MC_ALLOC */
2255 return 1; 2661 return 1;
2256 } 2662 }
2257 pdump_free (); 2663 pdump_free ();
2258 } 2664 }
2259 2665