]> git.eshelyaron.com Git - emacs.git/commitdiff
rationalize load functions
authorAndrea Corallo <akrl@sdf.org>
Sun, 22 Dec 2019 08:28:39 +0000 (09:28 +0100)
committerAndrea Corallo <akrl@sdf.org>
Wed, 1 Jan 2020 10:38:14 +0000 (11:38 +0100)
src/comp.c
src/comp.h
src/lisp.h

index 9f8c24f3cf081864dc044262dfd8c94b5889770c..6d496e89bf7ad82747b2e31e36f2b24b5d201cdb 100644 (file)
@@ -3218,9 +3218,8 @@ load_static_obj (dynlib_handle_ptr handle, const char *name)
 }
 
 static void
-load_comp_unit (Lisp_Object comp_u_obj, Lisp_Object file)
+load_comp_unit (struct Lisp_Native_Comp_Unit *comp_u)
 {
-  struct Lisp_Native_Comp_Unit *comp_u = XNATIVE_COMP_UNIT (comp_u_obj);
   dynlib_handle_ptr handle = comp_u->handle;
   struct thread_state ***current_thread_reloc =
     dynlib_sym (handle, CURRENT_THREAD_RELOC_SYM);
@@ -3234,7 +3233,7 @@ load_comp_unit (Lisp_Object comp_u_obj, Lisp_Object file)
        && data_relocs
        && freloc_link_table
        && top_level_run))
-    xsignal1 (Qnative_lisp_file_inconsistent, file);
+    xsignal1 (Qnative_lisp_file_inconsistent, comp_u->file);
 
   *current_thread_reloc = &current_thread;
   *pure_reloc = (EMACS_INT **)&pure;
@@ -3250,6 +3249,9 @@ load_comp_unit (Lisp_Object comp_u_obj, Lisp_Object file)
   /* Imported functions.  */
   *freloc_link_table = freloc.link_table;
 
+  Lisp_Object comp_u_obj;
+  XSETNATIVE_COMP_UNIT (comp_u_obj, comp_u);
+
   /* Executing this will perform all the expected environment modification.  */
   top_level_run (comp_u_obj);
 
@@ -3319,11 +3321,13 @@ DEFUN ("native-elisp-load", Fnative_elisp_load, Snative_elisp_load, 1, 1, 0,
   copy_file_fd (fd_out, fd_in, &st, Qnil, file);
   dynlib_handle_ptr handle =
     dynlib_open (format_string ("/proc/%d/fd/%d", getpid (), fd_out));
-  Lisp_Object comp_u = make_native_comp_u (fd_in, handle);
   if (!handle)
     xsignal2 (Qnative_lisp_load_failed, file, build_string (dynlib_error ()));
-
-  load_comp_unit (comp_u, file);
+  struct Lisp_Native_Comp_Unit *comp_u = allocate_native_comp_unit();
+  comp_u->file = file;
+  comp_u->fd = fd_out;
+  comp_u->handle = handle;
+  load_comp_unit (comp_u);
 
   return Qt;
 }
index 8b83911f53c15f70bd12f52b1382500516063b7b..677ffdc4d7f3421ea385b48b63816110a295735c 100644 (file)
@@ -26,6 +26,8 @@ along with GNU Emacs.  If not, see <https://www.gnu.org/licenses/>.  */
 struct Lisp_Native_Comp_Unit
 {
   union vectorlike_header header;
+  /* Original eln file loaded (just for debug purpose). */
+  Lisp_Object file;
   /* Analogous to the constant vector but per compilation unit.  */
   Lisp_Object data_vec;
   /* Compilation unit file descriptor and handle.  */
index 81ccae5683ff4807501ec600644096ff64723610..3c3a9e22cf3f9eccff9993196fbbba3b7bca3486 100644 (file)
@@ -4769,17 +4769,11 @@ SUBRP_NATIVE_COMPILEDP (Lisp_Object a)
   return SUBRP (a) && XSUBR (a)->native_comp_u;
 }
 
-INLINE Lisp_Object
-make_native_comp_u (int fd, dynlib_handle_ptr handle)
-{
-  struct Lisp_Native_Comp_Unit *x =
-    ALLOCATE_ZEROED_PSEUDOVECTOR (struct Lisp_Native_Comp_Unit, data_vec,
-                                 PVEC_NATIVE_COMP_UNIT);
-  x->fd = fd;
-  x->handle = handle;
-  Lisp_Object cu;
-  XSETNATIVE_COMP_UNIT (cu, x);
-  return cu;
+INLINE struct Lisp_Native_Comp_Unit *
+allocate_native_comp_unit (void)
+{
+  return ALLOCATE_ZEROED_PSEUDOVECTOR (struct Lisp_Native_Comp_Unit, data_vec,
+                                      PVEC_NATIVE_COMP_UNIT);
 }
 #endif