aboutsummaryrefslogtreecommitdiffstats
path: root/src/comp.c
diff options
context:
space:
mode:
authorAndrea Corallo2020-02-03 16:40:45 +0000
committerAndrea Corallo2020-02-03 21:56:46 +0000
commit7c93bb113ec353baa6316fa97744e65a6e109d91 (patch)
tree3226d91aedb0e9ca92ab581dc5b3709e19ceb4b9 /src/comp.c
parentffa59bb1611609879151b6dfa94772f9e2144849 (diff)
downloademacs-7c93bb113ec353baa6316fa97744e65a6e109d91.tar.gz
emacs-7c93bb113ec353baa6316fa97744e65a6e109d91.zip
Rework load mechanism to make Vcomp_loaded_handles unnecessary
Diffstat (limited to 'src/comp.c')
-rw-r--r--src/comp.c30
1 files changed, 19 insertions, 11 deletions
diff --git a/src/comp.c b/src/comp.c
index 7a1ccdcb83c..ebe7b8b9a9a 100644
--- a/src/comp.c
+++ b/src/comp.c
@@ -42,6 +42,7 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
42#define DATA_RELOC_IMPURE_SYM "d_reloc_imp" 42#define DATA_RELOC_IMPURE_SYM "d_reloc_imp"
43#define FUNC_LINK_TABLE_SYM "freloc_link_table" 43#define FUNC_LINK_TABLE_SYM "freloc_link_table"
44#define LINK_TABLE_HASH_SYM "freloc_hash" 44#define LINK_TABLE_HASH_SYM "freloc_hash"
45#define COMP_UNIT_SYM "comp_unit"
45#define TEXT_DATA_RELOC_SYM "text_data_reloc" 46#define TEXT_DATA_RELOC_SYM "text_data_reloc"
46#define TEXT_DATA_RELOC_IMPURE_SYM "text_data_reloc_imp" 47#define TEXT_DATA_RELOC_IMPURE_SYM "text_data_reloc_imp"
47 48
@@ -1888,6 +1889,13 @@ emit_ctxt_code (void)
1888 gcc_jit_type_get_pointer (comp.void_ptr_type), 1889 gcc_jit_type_get_pointer (comp.void_ptr_type),
1889 PURE_RELOC_SYM)); 1890 PURE_RELOC_SYM));
1890 1891
1892 gcc_jit_context_new_global (
1893 comp.ctxt,
1894 NULL,
1895 GCC_JIT_GLOBAL_EXPORTED,
1896 gcc_jit_type_get_pointer (comp.lisp_obj_ptr_type),
1897 COMP_UNIT_SYM);
1898
1891 declare_imported_data (); 1899 declare_imported_data ();
1892 1900
1893 /* Functions imported from Lisp code. */ 1901 /* Functions imported from Lisp code. */
@@ -3284,9 +3292,13 @@ load_comp_unit (struct Lisp_Native_Comp_Unit *comp_u, bool loading_dump)
3284{ 3292{
3285 dynlib_handle_ptr handle = comp_u->handle; 3293 dynlib_handle_ptr handle = comp_u->handle;
3286 Lisp_Object lisp_handle = make_mint_ptr (handle); 3294 Lisp_Object lisp_handle = make_mint_ptr (handle);
3287 bool reloading_cu = !NILP (Fgethash (lisp_handle, Vcomp_loaded_handles, Qnil)); 3295 Lisp_Object comp_u_lisp_obj;
3288 Lisp_Object comp_u_obj; 3296 XSETNATIVE_COMP_UNIT (comp_u_lisp_obj, comp_u);
3289 XSETNATIVE_COMP_UNIT (comp_u_obj, comp_u); 3297
3298 Lisp_Object *saved_cu = dynlib_sym (handle, COMP_UNIT_SYM);
3299 if (!saved_cu)
3300 xsignal1 (Qnative_lisp_file_inconsistent, comp_u->file);
3301 bool reloading_cu = *saved_cu ? true : false;
3290 3302
3291 if (reloading_cu) 3303 if (reloading_cu)
3292 /* 'dlopen' returns the same handle when trying to load two times 3304 /* 'dlopen' returns the same handle when trying to load two times
@@ -3297,11 +3309,11 @@ load_comp_unit (struct Lisp_Native_Comp_Unit *comp_u, bool loading_dump)
3297 We must *never* mess with static pointers in an already loaded 3309 We must *never* mess with static pointers in an already loaded
3298 eln. */ 3310 eln. */
3299 { 3311 {
3300 comp_u_obj = Fgethash (lisp_handle, Vcomp_loaded_handles, Qnil); 3312 comp_u_lisp_obj = *saved_cu;
3301 comp_u = XNATIVE_COMP_UNIT (comp_u_obj); 3313 comp_u = XNATIVE_COMP_UNIT (comp_u_lisp_obj);
3302 } 3314 }
3303 else 3315 else
3304 Fputhash (lisp_handle, comp_u_obj, Vcomp_loaded_handles); 3316 *saved_cu = comp_u_lisp_obj;
3305 3317
3306 freloc_check_fill (); 3318 freloc_check_fill ();
3307 3319
@@ -3356,7 +3368,7 @@ load_comp_unit (struct Lisp_Native_Comp_Unit *comp_u, bool loading_dump)
3356 if (!loading_dump) 3368 if (!loading_dump)
3357 /* Executing this will perform all the expected environment 3369 /* Executing this will perform all the expected environment
3358 modifications. */ 3370 modifications. */
3359 top_level_run (comp_u_obj); 3371 top_level_run (comp_u_lisp_obj);
3360 3372
3361 return; 3373 return;
3362} 3374}
@@ -3538,10 +3550,6 @@ syms_of_comp (void)
3538 doc: /* Hash table symbol-function -> function-c-name. For 3550 doc: /* Hash table symbol-function -> function-c-name. For
3539 internal use during */); 3551 internal use during */);
3540 Vcomp_sym_subr_c_name_h = CALLN (Fmake_hash_table); 3552 Vcomp_sym_subr_c_name_h = CALLN (Fmake_hash_table);
3541 DEFVAR_LISP ("comp-loaded-handles", Vcomp_loaded_handles,
3542 doc: /* Hash table keeping track of the currently
3543 loaded compilation unit: handle -> comp_u */);
3544 Vcomp_loaded_handles = CALLN (Fmake_hash_table, QCtest, Qequal);
3545} 3553}
3546 3554
3547#endif /* HAVE_NATIVE_COMP */ 3555#endif /* HAVE_NATIVE_COMP */