[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] pdumper 940081a 3/6: organize todos
From: |
Daniel Colascione |
Subject: |
[Emacs-diffs] pdumper 940081a 3/6: organize todos |
Date: |
Mon, 12 Feb 2018 15:20:51 -0500 (EST) |
branch: pdumper
commit 940081a7f3e91476752b5128158923cc8a953ada
Author: Daniel Colascione <address@hidden>
Commit: Daniel Colascione <address@hidden>
organize todos
---
src/alloc.c | 9 +++++++++
src/lisp.h | 3 +++
src/pdumper.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++++---------
3 files changed, 60 insertions(+), 9 deletions(-)
diff --git a/src/alloc.c b/src/alloc.c
index fb33de4..438ccde 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 31c8ae8..6195f64 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 9c19d42..be33011 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
}
- [Emacs-diffs] pdumper updated (c9a0676 -> 5ce5068), Daniel Colascione, 2018/02/12
- [Emacs-diffs] pdumper 992c4e2 4/6: Remove obsolete commands, Daniel Colascione, 2018/02/12
- [Emacs-diffs] pdumper 940081a 3/6: organize todos,
Daniel Colascione <=
- [Emacs-diffs] pdumper 0c9029d 5/6: Merge remote-tracking branch 'origin/master' into pdumper3, Daniel Colascione, 2018/02/12
- [Emacs-diffs] pdumper 5ce5068 6/6: Merge branch 'pdumper' of git.sv.gnu.org:/srv/git/emacs into pdumper3, Daniel Colascione, 2018/02/12
- [Emacs-diffs] pdumper 25420a9 2/6: Rename raw_ptr -> ptr_raw, Daniel Colascione, 2018/02/12
- [Emacs-diffs] pdumper 6a05247 1/6: squash pdump, Daniel Colascione, 2018/02/12