aboutsummaryrefslogtreecommitdiffstats
path: root/src/comp.c
diff options
context:
space:
mode:
authorAlan Mackenzie2022-01-11 21:57:54 +0000
committerAlan Mackenzie2022-01-11 21:57:54 +0000
commit2128cd8c08da84ab40608ac5db0fecfce733cfad (patch)
treee295275b1a99aed2e5e0cc270f91614062c670f6 /src/comp.c
parent4e77177b063f9da8a48709aa3ef416d0ac21837b (diff)
parent18dac472553e6cd1102b644c2175012e12215c18 (diff)
downloademacs-2128cd8c08da84ab40608ac5db0fecfce733cfad.tar.gz
emacs-2128cd8c08da84ab40608ac5db0fecfce733cfad.zip
Merge branch 'master' into scratch/correct-warning-pos
Diffstat (limited to 'src/comp.c')
-rw-r--r--src/comp.c67
1 files changed, 31 insertions, 36 deletions
diff --git a/src/comp.c b/src/comp.c
index 73555c0d2c1..9abc5d96906 100644
--- a/src/comp.c
+++ b/src/comp.c
@@ -1,5 +1,5 @@
1/* Compile Emacs Lisp into native code. 1/* Compile Emacs Lisp into native code.
2 Copyright (C) 2019-2021 Free Software Foundation, Inc. 2 Copyright (C) 2019-2022 Free Software Foundation, Inc.
3 3
4Author: Andrea Corallo <akrl@sdf.org> 4Author: Andrea Corallo <akrl@sdf.org>
5 5
@@ -5069,10 +5069,6 @@ register_native_comp_unit (Lisp_Object comp_u)
5069/* Deferred compilation mechanism. */ 5069/* Deferred compilation mechanism. */
5070/***********************************/ 5070/***********************************/
5071 5071
5072/* List of sources we'll compile and load after having conventionally
5073 loaded the compiler and its dependencies. */
5074static Lisp_Object delayed_sources;
5075
5076/* Queue an asynchronous compilation for the source file defining 5072/* Queue an asynchronous compilation for the source file defining
5077 FUNCTION_NAME and perform a late load. 5073 FUNCTION_NAME and perform a late load.
5078 5074
@@ -5129,30 +5125,16 @@ maybe_defer_native_compilation (Lisp_Object function_name,
5129 5125
5130 /* This is so deferred compilation is able to compile comp 5126 /* This is so deferred compilation is able to compile comp
5131 dependencies breaking circularity. */ 5127 dependencies breaking circularity. */
5132 if (!NILP (Ffeaturep (Qcomp, Qnil))) 5128 if (comp__loadable)
5133 { 5129 {
5134 /* Comp already loaded. */ 5130 /* Startup is done, comp is usable. */
5135 if (!NILP (delayed_sources)) 5131 Frequire (Qcomp, Qnil, Qnil);
5136 {
5137 CALLN (Ffuncall, intern_c_string ("native--compile-async"),
5138 delayed_sources, Qnil, Qlate);
5139 delayed_sources = Qnil;
5140 }
5141 Fputhash (function_name, definition, Vcomp_deferred_pending_h); 5132 Fputhash (function_name, definition, Vcomp_deferred_pending_h);
5142 CALLN (Ffuncall, intern_c_string ("native--compile-async"), 5133 CALLN (Ffuncall, intern_c_string ("native--compile-async"),
5143 src, Qnil, Qlate); 5134 src, Qnil, Qlate);
5144 } 5135 }
5145 else 5136 else
5146 { 5137 Vcomp__delayed_sources = Fcons (src, Vcomp__delayed_sources);
5147 delayed_sources = Fcons (src, delayed_sources);
5148 /* Require comp only once. */
5149 static bool comp_required = false;
5150 if (!comp_required)
5151 {
5152 comp_required = true;
5153 Frequire (Qcomp, Qnil, Qnil);
5154 }
5155 }
5156} 5138}
5157 5139
5158 5140
@@ -5441,21 +5423,29 @@ make_subr (Lisp_Object symbol_name, Lisp_Object minarg, Lisp_Object maxarg,
5441 if (CONSP (minarg)) 5423 if (CONSP (minarg))
5442 { 5424 {
5443 /* Dynamic code. */ 5425 /* Dynamic code. */
5444 x->s.lambda_list[0] = maxarg; 5426#ifdef HAVE_NATIVE_COMP
5427 x->s.lambda_list = maxarg;
5428#endif
5445 maxarg = XCDR (minarg); 5429 maxarg = XCDR (minarg);
5446 minarg = XCAR (minarg); 5430 minarg = XCAR (minarg);
5447 } 5431 }
5448 else 5432 else
5449 x->s.lambda_list[0] = Qnil; 5433 {
5434#ifdef HAVE_NATIVE_COMP
5435 x->s.lambda_list = Qnil;
5436#endif
5437 }
5450 x->s.function.a0 = func; 5438 x->s.function.a0 = func;
5451 x->s.min_args = XFIXNUM (minarg); 5439 x->s.min_args = XFIXNUM (minarg);
5452 x->s.max_args = FIXNUMP (maxarg) ? XFIXNUM (maxarg) : MANY; 5440 x->s.max_args = FIXNUMP (maxarg) ? XFIXNUM (maxarg) : MANY;
5453 x->s.symbol_name = xstrdup (SSDATA (symbol_name)); 5441 x->s.symbol_name = xstrdup (SSDATA (symbol_name));
5454 x->s.native_intspec = intspec; 5442 x->s.native_intspec = intspec;
5455 x->s.doc = XFIXNUM (doc_idx); 5443 x->s.doc = XFIXNUM (doc_idx);
5456 x->s.native_comp_u[0] = comp_u; 5444#ifdef HAVE_NATIVE_COMP
5457 x->s.native_c_name[0] = xstrdup (SSDATA (c_name)); 5445 x->s.native_comp_u = comp_u;
5458 x->s.type[0] = type; 5446 x->s.native_c_name = xstrdup (SSDATA (c_name));
5447 x->s.type = type;
5448#endif
5459 Lisp_Object tem; 5449 Lisp_Object tem;
5460 XSETSUBR (tem, &x->s); 5450 XSETSUBR (tem, &x->s);
5461 5451
@@ -5575,16 +5565,16 @@ LATE_LOAD has to be non-nil when loading for deferred compilation. */)
5575 Fmake_temp_file_internal (filename, Qnil, build_string (".eln.tmp"), 5565 Fmake_temp_file_internal (filename, Qnil, build_string (".eln.tmp"),
5576 Qnil); 5566 Qnil);
5577 if (NILP (Ffile_writable_p (tmp_filename))) 5567 if (NILP (Ffile_writable_p (tmp_filename)))
5578 comp_u->handle = dynlib_open (SSDATA (encoded_filename)); 5568 comp_u->handle = dynlib_open_for_eln (SSDATA (encoded_filename));
5579 else 5569 else
5580 { 5570 {
5581 Frename_file (filename, tmp_filename, Qt); 5571 Frename_file (filename, tmp_filename, Qt);
5582 comp_u->handle = dynlib_open (SSDATA (ENCODE_FILE (tmp_filename))); 5572 comp_u->handle = dynlib_open_for_eln (SSDATA (ENCODE_FILE (tmp_filename)));
5583 Frename_file (tmp_filename, filename, Qnil); 5573 Frename_file (tmp_filename, filename, Qnil);
5584 } 5574 }
5585 } 5575 }
5586 else 5576 else
5587 comp_u->handle = dynlib_open (SSDATA (encoded_filename)); 5577 comp_u->handle = dynlib_open_for_eln (SSDATA (encoded_filename));
5588 5578
5589 if (!comp_u->handle) 5579 if (!comp_u->handle)
5590 xsignal2 (Qnative_lisp_load_failed, filename, 5580 xsignal2 (Qnative_lisp_load_failed, filename,
@@ -5615,6 +5605,13 @@ void
5615syms_of_comp (void) 5605syms_of_comp (void)
5616{ 5606{
5617#ifdef HAVE_NATIVE_COMP 5607#ifdef HAVE_NATIVE_COMP
5608 DEFVAR_LISP ("comp--delayed-sources", Vcomp__delayed_sources,
5609 doc: /* List of sources to be native-compiled when startup is finished.
5610For internal use. */);
5611 DEFVAR_BOOL ("comp--loadable",
5612 comp__loadable,
5613 doc: /* Non-nil when comp.el can be loaded.
5614For internal use. */);
5618 /* Compiler control customizes. */ 5615 /* Compiler control customizes. */
5619 DEFVAR_BOOL ("native-comp-deferred-compilation", 5616 DEFVAR_BOOL ("native-comp-deferred-compilation",
5620 native_comp_deferred_compilation, 5617 native_comp_deferred_compilation,
@@ -5756,8 +5753,6 @@ compiled one. */);
5756 staticpro (&comp.func_blocks_h); 5753 staticpro (&comp.func_blocks_h);
5757 staticpro (&comp.emitter_dispatcher); 5754 staticpro (&comp.emitter_dispatcher);
5758 comp.emitter_dispatcher = Qnil; 5755 comp.emitter_dispatcher = Qnil;
5759 staticpro (&delayed_sources);
5760 delayed_sources = Qnil;
5761 staticpro (&loadsearch_re_list); 5756 staticpro (&loadsearch_re_list);
5762 loadsearch_re_list = Qnil; 5757 loadsearch_re_list = Qnil;
5763 5758
@@ -5814,9 +5809,9 @@ protect the trampolines against GC. */);
5814 Vcomp_installed_trampolines_h = CALLN (Fmake_hash_table); 5809 Vcomp_installed_trampolines_h = CALLN (Fmake_hash_table);
5815 5810
5816 DEFVAR_LISP ("comp-no-native-file-h", V_comp_no_native_file_h, 5811 DEFVAR_LISP ("comp-no-native-file-h", V_comp_no_native_file_h,
5817 doc: /* Files for which no deferred compilation has to 5812 doc: /* Files for which no deferred compilation has to be performed.
5818be performed because the bytecode version was explicitly requested by 5813These files' compilation should not be deferred because the bytecode
5819the user during load. 5814version was explicitly requested by the user during load.
5820For internal use. */); 5815For internal use. */);
5821 V_comp_no_native_file_h = CALLN (Fmake_hash_table, QCtest, Qequal); 5816 V_comp_no_native_file_h = CALLN (Fmake_hash_table, QCtest, Qequal);
5822 5817