aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndrea Corallo2020-03-18 19:48:50 +0000
committerAndrea Corallo2020-03-19 13:50:25 +0000
commitb53fc68535211a59fde7200713340d911b48ecec (patch)
treec3ff45482ff24c0a8e7c38cb68ee29e2c37cc15c /src
parent034d9b319c2d596d090364476a193fbc409026d6 (diff)
downloademacs-b53fc68535211a59fde7200713340d911b48ecec.tar.gz
emacs-b53fc68535211a59fde7200713340d911b48ecec.zip
Extend low level code for late load
Diffstat (limited to 'src')
-rw-r--r--src/comp.c36
-rw-r--r--src/comp.h4
-rw-r--r--src/lread.c2
-rw-r--r--src/pdumper.c2
4 files changed, 20 insertions, 24 deletions
diff --git a/src/comp.c b/src/comp.c
index 74b74a83b77..3f2b45c85fd 100644
--- a/src/comp.c
+++ b/src/comp.c
@@ -3368,27 +3368,18 @@ void
3368maybe_defer_native_compilation (Lisp_Object function_name, 3368maybe_defer_native_compilation (Lisp_Object function_name,
3369 Lisp_Object definition) 3369 Lisp_Object definition)
3370{ 3370{
3371 Lisp_Object src = Qnil;
3372 Lisp_Object load_list = Vcurrent_load_list;
3373
3374 FOR_EACH_TAIL (load_list)
3375 {
3376 src = XCAR (load_list);
3377 if (!CONSP (src))
3378 break;
3379 }
3380
3381 if (!comp_deferred_compilation 3371 if (!comp_deferred_compilation
3382 || noninteractive 3372 || noninteractive
3383 || !NILP (Vpurify_flag) 3373 || !NILP (Vpurify_flag)
3384 || !COMPILEDP (definition) 3374 || !COMPILEDP (definition)
3385 || !FIXNUMP (AREF (definition, COMPILED_ARGLIST)) 3375 || !FIXNUMP (AREF (definition, COMPILED_ARGLIST))
3386 || !STRINGP (src) 3376 || !STRINGP (Vload_file_name)
3387 || !suffix_p (src, ".elc")) 3377 || !suffix_p (Vload_file_name, ".elc"))
3388 return; 3378 return;
3389 3379
3390 src = concat2 (CALL1I (file-name-sans-extension, src), 3380 Lisp_Object src =
3391 build_pure_c_string (".el")); 3381 concat2 (CALL1I (file-name-sans-extension, Vload_file_name),
3382 build_pure_c_string (".el"));
3392 if (!NILP (Ffile_exists_p (src))) 3383 if (!NILP (Ffile_exists_p (src)))
3393 CALLN (Ffuncall, intern_c_string ("native-compile-async"), src, Qnil); 3384 CALLN (Ffuncall, intern_c_string ("native-compile-async"), src, Qnil);
3394} 3385}
@@ -3413,7 +3404,8 @@ load_static_obj (struct Lisp_Native_Comp_Unit *comp_u, const char *name)
3413} 3404}
3414 3405
3415void 3406void
3416load_comp_unit (struct Lisp_Native_Comp_Unit *comp_u, bool loading_dump) 3407load_comp_unit (struct Lisp_Native_Comp_Unit *comp_u, bool loading_dump,
3408 bool late_load)
3417{ 3409{
3418 dynlib_handle_ptr handle = comp_u->handle; 3410 dynlib_handle_ptr handle = comp_u->handle;
3419 Lisp_Object comp_u_lisp_obj; 3411 Lisp_Object comp_u_lisp_obj;
@@ -3447,7 +3439,9 @@ load_comp_unit (struct Lisp_Native_Comp_Unit *comp_u, bool loading_dump)
3447 3439
3448 freloc_check_fill (); 3440 freloc_check_fill ();
3449 3441
3450 void (*top_level_run)(Lisp_Object) = dynlib_sym (handle, "top_level_run"); 3442 void (*top_level_run)(Lisp_Object)
3443 = dynlib_sym (handle,
3444 late_load ? "late_top_level_run" : "top_level_run");
3451 3445
3452 if (!reloading_cu) 3446 if (!reloading_cu)
3453 { 3447 {
@@ -3564,9 +3558,11 @@ DEFUN ("comp--register-subr", Fcomp__register_subr, Scomp__register_subr,
3564} 3558}
3565 3559
3566/* Load related routines. */ 3560/* Load related routines. */
3567DEFUN ("native-elisp-load", Fnative_elisp_load, Snative_elisp_load, 1, 1, 0, 3561DEFUN ("native-elisp-load", Fnative_elisp_load, Snative_elisp_load, 1, 2, 0,
3568 doc: /* Load native elisp code FILE. */) 3562 doc: /* Load native elisp code FILE.
3569 (Lisp_Object file) 3563 LATE_LOAD has to be non nil when loading for deferred
3564 compilation. */)
3565 (Lisp_Object file, Lisp_Object late_load)
3570{ 3566{
3571 CHECK_STRING (file); 3567 CHECK_STRING (file);
3572 3568
@@ -3576,7 +3572,7 @@ DEFUN ("native-elisp-load", Fnative_elisp_load, Snative_elisp_load, 1, 1, 0,
3576 xsignal2 (Qnative_lisp_load_failed, file, build_string (dynlib_error ())); 3572 xsignal2 (Qnative_lisp_load_failed, file, build_string (dynlib_error ()));
3577 comp_u->file = file; 3573 comp_u->file = file;
3578 comp_u->data_vec = Qnil; 3574 comp_u->data_vec = Qnil;
3579 load_comp_unit (comp_u, false); 3575 load_comp_unit (comp_u, false, !NILP (late_load));
3580 3576
3581 return Qt; 3577 return Qt;
3582} 3578}
diff --git a/src/comp.h b/src/comp.h
index f3bcd4c09bc..f5baa88853e 100644
--- a/src/comp.h
+++ b/src/comp.h
@@ -64,8 +64,8 @@ XNATIVE_COMP_UNIT (Lisp_Object a)
64 64
65extern void hash_native_abi (void); 65extern void hash_native_abi (void);
66 66
67extern void load_comp_unit (struct Lisp_Native_Comp_Unit *comp_u, 67void load_comp_unit (struct Lisp_Native_Comp_Unit *comp_u, bool loading_dump,
68 bool loading_dump); 68 bool late_load);
69extern void syms_of_comp (void); 69extern void syms_of_comp (void);
70 70
71extern void maybe_defer_native_compilation (Lisp_Object function_name, 71extern void maybe_defer_native_compilation (Lisp_Object function_name,
diff --git a/src/lread.c b/src/lread.c
index 2d90bccdc07..b2f437130ce 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -1483,7 +1483,7 @@ Return t if the file exists and loads successfully. */)
1483 { 1483 {
1484 specbind (Qcurrent_load_list, Qnil); 1484 specbind (Qcurrent_load_list, Qnil);
1485 LOADHIST_ATTACH (found); 1485 LOADHIST_ATTACH (found);
1486 Fnative_elisp_load (found); 1486 Fnative_elisp_load (found, Qnil);
1487 build_load_history (found, true); 1487 build_load_history (found, true);
1488 } 1488 }
1489 else 1489 else
diff --git a/src/pdumper.c b/src/pdumper.c
index 2e2220a9b29..55f95fd0e75 100644
--- a/src/pdumper.c
+++ b/src/pdumper.c
@@ -5303,7 +5303,7 @@ dump_do_dump_relocation (const uintptr_t dump_base,
5303 comp_u->handle = dynlib_open (SSDATA (comp_u->file)); 5303 comp_u->handle = dynlib_open (SSDATA (comp_u->file));
5304 if (!comp_u->handle) 5304 if (!comp_u->handle)
5305 error ("%s", dynlib_error ()); 5305 error ("%s", dynlib_error ());
5306 load_comp_unit (comp_u, true); 5306 load_comp_unit (comp_u, true, false);
5307 break; 5307 break;
5308 } 5308 }
5309 case RELOC_NATIVE_SUBR: 5309 case RELOC_NATIVE_SUBR: