mirror of
https://git.savannah.gnu.org/git/emacs.git
synced 2024-12-01 08:17:38 +00:00
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.
This commit is contained in:
parent
7b235b1ec0
commit
9b381a95ef
@ -519,6 +519,19 @@ DIRS are relative."
|
||||
xdg-dir)
|
||||
(t emacs-d-dir))))
|
||||
|
||||
(defvar comp--delayed-sources)
|
||||
(defvar comp--loadable)
|
||||
(declare-function native--compile-async "comp.el"
|
||||
(files &optional recursively load selector))
|
||||
(defun startup--honor-delayed-native-compilations ()
|
||||
"Honor pending delayed deferred native compilations."
|
||||
(when (and (native-comp-available-p)
|
||||
comp--delayed-sources)
|
||||
(require 'comp)
|
||||
(setq comp--loadable t)
|
||||
(native--compile-async comp--delayed-sources nil 'late)
|
||||
(setq comp--delayed-sources nil)))
|
||||
|
||||
(defvar native-comp-eln-load-path)
|
||||
(defun normal-top-level ()
|
||||
"Emacs calls this function when it first starts up.
|
||||
@ -785,7 +798,8 @@ It is the default value of the variable `top-level'."
|
||||
(if (string-match "\\`DISPLAY=" varval)
|
||||
(setq display varval))))
|
||||
(when display
|
||||
(delete display process-environment)))))
|
||||
(delete display process-environment))))
|
||||
(startup--honor-delayed-native-compilations))
|
||||
|
||||
;; Precompute the keyboard equivalents in the menu bar items.
|
||||
;; Command-line options supported by tty's:
|
||||
|
35
src/comp.c
35
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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user