From: Daniel Colascione Date: Mon, 12 Feb 2018 12:44:20 +0000 (-0800) Subject: organize todos X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=8e2e1748847192eb9dc70ec904c6b0d0fd14e724;p=emacs.git organize todos --- diff --git a/src/alloc.c b/src/alloc.c index fb33de49c8e..438ccde961b 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -240,6 +240,12 @@ EMACS_INT gc_relative_threshold; EMACS_INT memory_full_cons_threshold; +#ifdef HAVE_PDUMPER +/* Number of finalizers run: used to loop over GC until we stop + generating garbage. */ +int number_finalizers_run; +#endif + /* True during GC. */ bool gc_in_progress; @@ -4052,6 +4058,9 @@ static void run_finalizer_function (Lisp_Object function) { ptrdiff_t count = SPECPDL_INDEX (); +#ifdef HAVE_PDUMPER + ++number_finalizers_run; +#endif specbind (Qinhibit_quit, Qt); internal_condition_case_1 (call0, function, Qt, run_finalizer_handler); diff --git a/src/lisp.h b/src/lisp.h index 31c8ae8ce22..6195f64e278 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -3806,6 +3806,9 @@ extern Lisp_Object zero_vector; extern EMACS_INT consing_since_gc; extern EMACS_INT gc_relative_threshold; extern EMACS_INT memory_full_cons_threshold; +#ifdef HAVE_PDUMPER +extern int number_finalizers_run; +#endif #ifdef ENABLE_CHECKING extern Lisp_Object Vdead; #endif diff --git a/src/pdumper.c b/src/pdumper.c index 9c19d42499e..be33011a207 100644 --- a/src/pdumper.c +++ b/src/pdumper.c @@ -26,6 +26,32 @@ #include "pdumper.h" #include "window.h" + +/* + TODO: + + - Make sure global finalizer list makes it across the dump. + + - Respect dump_object_contents. + + - Two-pass dumping: first assemble object list, then write all. + + - Don't emit relocations that happen to set Emacs memory locations + to values they will already have. + + - Check at dump time that relocations are properly aligned. + + - Nullify frame_and_buffer_state. + + - Preferred base address for relocation-free non-PIC startup. + + - Compressed dump support. + + - Automate detection of struct layout changes. + +*/ + + #ifdef HAVE_PDUMPER #ifdef __GNUC__ @@ -422,6 +448,10 @@ struct dump_context Lisp_Object old_purify_flag; Lisp_Object old_post_gc_hook; +#ifdef REL_ALLOC + bool blocked_ralloc; +#endif + /* File descriptor for dumpfile; < 0 if closed. */ int fd; /* Name of dump file --- used for error reporting. */ @@ -3332,15 +3362,13 @@ dump_user_remembered_data_cold (struct dump_context *ctx) static void dump_unwind_cleanup (void *data) { - // XXX: omit relocations that duplicate BSS? - // XXX: prevent ralloc moving - // XXX: dumb mode for GC ( finalizers?) - // XXX: make sure finalizers stick - // XXX: check that calling thread is main thread - // XXX: check relocation alignment. struct dump_context *ctx = data; if (ctx->fd >= 0) emacs_close (ctx->fd); +#ifdef REL_ALLOC + if (ctx->blocked_ralloc) + r_alloc_inhibit_buffer_relocation (0); +#endif Vpurify_flag = ctx->old_purify_flag; unblock_input (); } @@ -3629,6 +3657,15 @@ types. */) "dumper. Dumping with the portable dumper may produce " "unexpected results."); + if (!main_thread_p (current_thread)) + error ("Function can be called only on main thread"); + + /* Clear out any detritus in memory. */ + do { + number_finalizers_run = 0; + Fgarbage_collect (); + } while (number_finalizers_run); + ptrdiff_t count = SPECPDL_INDEX (); /* Bind `command-line-processed' to nil before dumping, @@ -3678,6 +3715,11 @@ types. */) record_unwind_protect_ptr (dump_unwind_cleanup, ctx); block_input (); +#ifdef REL_ALLOC + r_alloc_inhibit_buffer_relocation (1); + ctx->blocked_ralloc = true; +#endif + ctx->old_purify_flag = Vpurify_flag; Vpurify_flag = Qnil; @@ -3824,9 +3866,6 @@ types. */) return unbind_to (count, Qnil); - // XXX: nullify frame_and_buffer_state - - // XXX: preferred base address }