From: Andrea Corallo Date: Sun, 22 Dec 2019 08:28:39 +0000 (+0100) Subject: rationalize load functions X-Git-Tag: emacs-28.0.90~2727^2~898 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=b275ddd63a24b15dd8f90ea0c4f27341a8dfa977;p=emacs.git rationalize load functions --- diff --git a/src/comp.c b/src/comp.c index 9f8c24f3cf0..6d496e89bf7 100644 --- a/src/comp.c +++ b/src/comp.c @@ -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 = ¤t_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; } diff --git a/src/comp.h b/src/comp.h index 8b83911f53c..677ffdc4d7f 100644 --- a/src/comp.h +++ b/src/comp.h @@ -26,6 +26,8 @@ along with GNU Emacs. If not, see . */ 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. */ diff --git a/src/lisp.h b/src/lisp.h index 81ccae5683f..3c3a9e22cf3 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -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