]> git.eshelyaron.com Git - emacs.git/commitdiff
organize todos
authorDaniel Colascione <dancol@dancol.org>
Mon, 12 Feb 2018 12:44:20 +0000 (04:44 -0800)
committerDaniel Colascione <dancol@dancol.org>
Mon, 12 Feb 2018 12:44:20 +0000 (04:44 -0800)
src/alloc.c
src/lisp.h
src/pdumper.c

index fb33de49c8eb5304ce134367127c8d5d4034208f..438ccde961baf4dcc75f7a89cffb6cfc9d52d6ff 100644 (file)
@@ -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);
index 31c8ae8ce229f2c15e8f84475665ce2cf34c746f..6195f64e278737902593bf2313585639ad2c9b30 100644 (file)
@@ -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
index 9c19d42499eba45e2117817865a7dbc6b65bc99c..be33011a207845586c7b4b201adaa32273e33525 100644 (file)
 #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
 
 }