summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrea Corallo <akrl@sdf.org>2021-11-30 14:18:58 +0100
committerAndrea Corallo <akrl@sdf.org>2021-11-30 15:42:41 +0100
commit9b381a95ef6cd9194d64bfb17fd50bb99fa6cd32 (patch)
tree2beaee9f148cae181ff7948dc9fb9ee12f88b839 /src
parent7b235b1ec05c48d70ea44982f04b7b5f4052fa05 (diff)
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')
-rw-r--r--src/comp.c35
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)
/* Deferred compilation mechanism. */
/***********************************/
-/* List of sources we'll compile and load after having conventionally
- loaded the compiler and its dependencies. */
-static Lisp_Object delayed_sources;
-
/* Queue an asynchronous compilation for the source file defining
FUNCTION_NAME and perform a late load.
@@ -4846,30 +4842,16 @@ maybe_defer_native_compilation (Lisp_Object function_name,
/* This is so deferred compilation is able to compile comp
dependencies breaking circularity. */
- if (!NILP (Ffeaturep (Qcomp, Qnil)))
+ if (comp__loadable)
{
- /* Comp already loaded. */
- if (!NILP (delayed_sources))
- {
- CALLN (Ffuncall, intern_c_string ("native--compile-async"),
- delayed_sources, Qnil, Qlate);
- delayed_sources = Qnil;
- }
+ /* Startup is done, comp is usable. */
+ Frequire (Qcomp, Qnil, Qnil);
Fputhash (function_name, definition, Vcomp_deferred_pending_h);
CALLN (Ffuncall, intern_c_string ("native--compile-async"),
src, Qnil, Qlate);
}
else
- {
- delayed_sources = Fcons (src, delayed_sources);
- /* Require comp only once. */
- static bool comp_required = false;
- if (!comp_required)
- {
- comp_required = true;
- Frequire (Qcomp, Qnil, Qnil);
- }
- }
+ Vcomp__delayed_sources = Fcons (src, Vcomp__delayed_sources);
}
@@ -5328,6 +5310,13 @@ void
syms_of_comp (void)
{
#ifdef HAVE_NATIVE_COMP
+ DEFVAR_LISP ("comp--delayed-sources", Vcomp__delayed_sources,
+ doc: /* List of sources to be native compiled when
+ startup is finished. For internal use. */);
+ DEFVAR_BOOL ("comp--loadable",
+ comp__loadable,
+ doc: /* Non-nil when comp.el can be loaded. For
+ internal use. */);
/* Compiler control customizes. */
DEFVAR_BOOL ("native-comp-deferred-compilation",
native_comp_deferred_compilation,
@@ -5468,8 +5457,6 @@ compiled one. */);
staticpro (&comp.func_blocks_h);
staticpro (&comp.emitter_dispatcher);
comp.emitter_dispatcher = Qnil;
- staticpro (&delayed_sources);
- delayed_sources = Qnil;
staticpro (&loadsearch_re_list);
loadsearch_re_list = Qnil;