summaryrefslogtreecommitdiff
path: root/src/comp.c
diff options
context:
space:
mode:
authorAndrea Corallo <akrl@sdf.org>2020-03-15 21:44:05 +0000
committerAndrea Corallo <akrl@sdf.org>2020-03-16 23:08:34 +0000
commit159f61baa9e374cfd17acf1a45c0d553b57b7ac9 (patch)
tree6832e7e815fb71c2f95e69af4056122ed1bbd1d8 /src/comp.c
parentea8864fb672a7ff2d1da1b91885239f60e16b359 (diff)
downloademacs-159f61baa9e374cfd17acf1a45c0d553b57b7ac9.tar.gz
emacs-159f61baa9e374cfd17acf1a45c0d553b57b7ac9.tar.bz2
emacs-159f61baa9e374cfd17acf1a45c0d553b57b7ac9.zip
Trigger native compilation when loading bytecode
Introduce a first mechanism to trigger compilation when lex elc files are loaded. This is off by default and has to be better tested.
Diffstat (limited to 'src/comp.c')
-rw-r--r--src/comp.c38
1 files changed, 37 insertions, 1 deletions
diff --git a/src/comp.c b/src/comp.c
index b9ecef07f32..74b74a83b77 100644
--- a/src/comp.c
+++ b/src/comp.c
@@ -492,7 +492,7 @@ declare_imported_func (Lisp_Object subr_sym, gcc_jit_type *ret_type,
/* String containing the function ptr name. */
Lisp_Object f_ptr_name =
- CALLN (Ffuncall, intern_c_string (STR (comp-c-func-name)),
+ CALLN (Ffuncall, intern_c_string ("comp-c-func-name"),
subr_sym, make_string ("R", 1));
gcc_jit_type *f_ptr_type =
@@ -3360,6 +3360,40 @@ helper_PSEUDOVECTOR_TYPEP_XUNTAG (Lisp_Object a, enum pvec_type code)
}
+/***********************************/
+/* Deferred compilation mechanism. */
+/***********************************/
+
+void
+maybe_defer_native_compilation (Lisp_Object function_name,
+ Lisp_Object definition)
+{
+ Lisp_Object src = Qnil;
+ Lisp_Object load_list = Vcurrent_load_list;
+
+ FOR_EACH_TAIL (load_list)
+ {
+ src = XCAR (load_list);
+ if (!CONSP (src))
+ break;
+ }
+
+ if (!comp_deferred_compilation
+ || noninteractive
+ || !NILP (Vpurify_flag)
+ || !COMPILEDP (definition)
+ || !FIXNUMP (AREF (definition, COMPILED_ARGLIST))
+ || !STRINGP (src)
+ || !suffix_p (src, ".elc"))
+ return;
+
+ src = concat2 (CALL1I (file-name-sans-extension, src),
+ build_pure_c_string (".el"));
+ if (!NILP (Ffile_exists_p (src)))
+ CALLN (Ffuncall, intern_c_string ("native-compile-async"), src, Qnil);
+}
+
+
/**************************************/
/* Functions used to load eln files. */
/**************************************/
@@ -3552,6 +3586,8 @@ void
syms_of_comp (void)
{
/* Compiler control customizes. */
+ DEFVAR_BOOL ("comp-deferred-compilation", comp_deferred_compilation,
+ doc: /* If t compile asyncronously every .elc file loaded. */);
DEFSYM (Qcomp_speed, "comp-speed");
DEFSYM (Qcomp_debug, "comp-debug");