diff options
| author | Andrea Corallo | 2021-11-30 14:18:58 +0100 |
|---|---|---|
| committer | Andrea Corallo | 2021-11-30 15:42:41 +0100 |
| commit | 9b381a95ef6cd9194d64bfb17fd50bb99fa6cd32 (patch) | |
| tree | 2beaee9f148cae181ff7948dc9fb9ee12f88b839 /src/comp.c | |
| parent | 7b235b1ec05c48d70ea44982f04b7b5f4052fa05 (diff) | |
| download | emacs-9b381a95ef6cd9194d64bfb17fd50bb99fa6cd32.tar.gz emacs-9b381a95ef6cd9194d64bfb17fd50bb99fa6cd32.zip | |
Improve native compiler startup circular dependecy prevention mechanism
* src/comp.c (maybe_defer_native_compilation): Update to accumulate
delayed objects in `comp--delayed-sources'.
(syms_of_comp): Add `comp--delayed-sources' and `comp--loadable'
vars.
* lisp/startup.el (startup--honor-delayed-native-compilations): New
function.
(normal-top-level): Call it.
Diffstat (limited to 'src/comp.c')
| -rw-r--r-- | src/comp.c | 35 |
1 files changed, 11 insertions, 24 deletions
diff --git a/src/comp.c b/src/comp.c index 5b947fc99b6..ab7006cca64 100644 --- a/src/comp.c +++ b/src/comp.c | |||
| @@ -4786,10 +4786,6 @@ register_native_comp_unit (Lisp_Object comp_u) | |||
| 4786 | /* Deferred compilation mechanism. */ | 4786 | /* Deferred compilation mechanism. */ |
| 4787 | /***********************************/ | 4787 | /***********************************/ |
| 4788 | 4788 | ||
| 4789 | /* List of sources we'll compile and load after having conventionally | ||
| 4790 | loaded the compiler and its dependencies. */ | ||
| 4791 | static Lisp_Object delayed_sources; | ||
| 4792 | |||
| 4793 | /* Queue an asynchronous compilation for the source file defining | 4789 | /* Queue an asynchronous compilation for the source file defining |
| 4794 | FUNCTION_NAME and perform a late load. | 4790 | FUNCTION_NAME and perform a late load. |
| 4795 | 4791 | ||
| @@ -4846,30 +4842,16 @@ maybe_defer_native_compilation (Lisp_Object function_name, | |||
| 4846 | 4842 | ||
| 4847 | /* This is so deferred compilation is able to compile comp | 4843 | /* This is so deferred compilation is able to compile comp |
| 4848 | dependencies breaking circularity. */ | 4844 | dependencies breaking circularity. */ |
| 4849 | if (!NILP (Ffeaturep (Qcomp, Qnil))) | 4845 | if (comp__loadable) |
| 4850 | { | 4846 | { |
| 4851 | /* Comp already loaded. */ | 4847 | /* Startup is done, comp is usable. */ |
| 4852 | if (!NILP (delayed_sources)) | 4848 | Frequire (Qcomp, Qnil, Qnil); |
| 4853 | { | ||
| 4854 | CALLN (Ffuncall, intern_c_string ("native--compile-async"), | ||
| 4855 | delayed_sources, Qnil, Qlate); | ||
| 4856 | delayed_sources = Qnil; | ||
| 4857 | } | ||
| 4858 | Fputhash (function_name, definition, Vcomp_deferred_pending_h); | 4849 | Fputhash (function_name, definition, Vcomp_deferred_pending_h); |
| 4859 | CALLN (Ffuncall, intern_c_string ("native--compile-async"), | 4850 | CALLN (Ffuncall, intern_c_string ("native--compile-async"), |
| 4860 | src, Qnil, Qlate); | 4851 | src, Qnil, Qlate); |
| 4861 | } | 4852 | } |
| 4862 | else | 4853 | else |
| 4863 | { | 4854 | Vcomp__delayed_sources = Fcons (src, Vcomp__delayed_sources); |
| 4864 | delayed_sources = Fcons (src, delayed_sources); | ||
| 4865 | /* Require comp only once. */ | ||
| 4866 | static bool comp_required = false; | ||
| 4867 | if (!comp_required) | ||
| 4868 | { | ||
| 4869 | comp_required = true; | ||
| 4870 | Frequire (Qcomp, Qnil, Qnil); | ||
| 4871 | } | ||
| 4872 | } | ||
| 4873 | } | 4855 | } |
| 4874 | 4856 | ||
| 4875 | 4857 | ||
| @@ -5328,6 +5310,13 @@ void | |||
| 5328 | syms_of_comp (void) | 5310 | syms_of_comp (void) |
| 5329 | { | 5311 | { |
| 5330 | #ifdef HAVE_NATIVE_COMP | 5312 | #ifdef HAVE_NATIVE_COMP |
| 5313 | DEFVAR_LISP ("comp--delayed-sources", Vcomp__delayed_sources, | ||
| 5314 | doc: /* List of sources to be native compiled when | ||
| 5315 | startup is finished. For internal use. */); | ||
| 5316 | DEFVAR_BOOL ("comp--loadable", | ||
| 5317 | comp__loadable, | ||
| 5318 | doc: /* Non-nil when comp.el can be loaded. For | ||
| 5319 | internal use. */); | ||
| 5331 | /* Compiler control customizes. */ | 5320 | /* Compiler control customizes. */ |
| 5332 | DEFVAR_BOOL ("native-comp-deferred-compilation", | 5321 | DEFVAR_BOOL ("native-comp-deferred-compilation", |
| 5333 | native_comp_deferred_compilation, | 5322 | native_comp_deferred_compilation, |
| @@ -5468,8 +5457,6 @@ compiled one. */); | |||
| 5468 | staticpro (&comp.func_blocks_h); | 5457 | staticpro (&comp.func_blocks_h); |
| 5469 | staticpro (&comp.emitter_dispatcher); | 5458 | staticpro (&comp.emitter_dispatcher); |
| 5470 | comp.emitter_dispatcher = Qnil; | 5459 | comp.emitter_dispatcher = Qnil; |
| 5471 | staticpro (&delayed_sources); | ||
| 5472 | delayed_sources = Qnil; | ||
| 5473 | staticpro (&loadsearch_re_list); | 5460 | staticpro (&loadsearch_re_list); |
| 5474 | loadsearch_re_list = Qnil; | 5461 | loadsearch_re_list = Qnil; |
| 5475 | 5462 | ||