aboutsummaryrefslogtreecommitdiffstats
path: root/src
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
parentffa59bb1611609879151b6dfa94772f9e2144849 (diff)
downloademacs-7c93bb113ec353baa6316fa97744e65a6e109d91.tar.gz
emacs-7c93bb113ec353baa6316fa97744e65a6e109d91.zip
Rework load mechanism to make Vcomp_loaded_handles unnecessary
Diffstat (limited to 'src')
-rw-r--r--src/alloc.c19
-rw-r--r--src/comp.c30
-rw-r--r--src/pdumper.c1
3 files changed, 19 insertions, 31 deletions
diff --git a/src/alloc.c b/src/alloc.c
index 431238b13e6..faa8e703937 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -517,14 +517,6 @@ Lisp_Object const *staticvec[NSTATICS]
517 517
518int staticidx; 518int staticidx;
519 519
520/* Lisp of freed native compilation unit handles.
521
522 Because during GC Vcomp_loaded_handles can't be used (hash table) temporary
523 annotate here and update Vcomp_loaded_handles when finished.
524*/
525
526static Lisp_Object freed_cu_handles[NATIVE_COMP_FLAG];
527
528static void *pure_alloc (size_t, int); 520static void *pure_alloc (size_t, int);
529 521
530/* Return PTR rounded up to the next multiple of ALIGNMENT. */ 522/* Return PTR rounded up to the next multiple of ALIGNMENT. */
@@ -3038,10 +3030,6 @@ cleanup_vector (struct Lisp_Vector *vector)
3038 PSEUDOVEC_STRUCT (vector, Lisp_Native_Comp_Unit); 3030 PSEUDOVEC_STRUCT (vector, Lisp_Native_Comp_Unit);
3039 eassert (cu->handle); 3031 eassert (cu->handle);
3040 dynlib_close (cu->handle); 3032 dynlib_close (cu->handle);
3041 /* We'll update Vcomp_loaded_handles when finished. */
3042 freed_cu_handles[0] =
3043 Fcons (make_mint_ptr (cu->handle), freed_cu_handles[0]);
3044 set_cons_marked (XCONS (freed_cu_handles[0]));
3045 } 3033 }
3046} 3034}
3047 3035
@@ -5949,9 +5937,6 @@ garbage_collect (void)
5949 if (garbage_collection_messages) 5937 if (garbage_collection_messages)
5950 message1_nolog ("Garbage collecting..."); 5938 message1_nolog ("Garbage collecting...");
5951 5939
5952 if (NATIVE_COMP_FLAG)
5953 freed_cu_handles[0] = Qnil;
5954
5955 block_input (); 5940 block_input ();
5956 5941
5957 shrink_regexp_cache (); 5942 shrink_regexp_cache ();
@@ -6016,10 +6001,6 @@ garbage_collect (void)
6016 6001
6017 gc_in_progress = 0; 6002 gc_in_progress = 0;
6018 6003
6019 if (NATIVE_COMP_FLAG)
6020 FOR_EACH_TAIL (freed_cu_handles[0])
6021 Fputhash (XCAR (freed_cu_handles[0]), Qnil, Vcomp_loaded_handles);
6022
6023 unblock_input (); 6004 unblock_input ();
6024 6005
6025 consing_until_gc = gc_threshold 6006 consing_until_gc = gc_threshold
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 */
diff --git a/src/pdumper.c b/src/pdumper.c
index 8a758499a91..ae8fe014e0e 100644
--- a/src/pdumper.c
+++ b/src/pdumper.c
@@ -5577,7 +5577,6 @@ pdumper_load (const char *dump_filename)
5577 dump_hooks[i] (); 5577 dump_hooks[i] ();
5578 5578
5579 dump_do_all_dump_reloc_for_phase (header, dump_base, LATE_RELOCS); 5579 dump_do_all_dump_reloc_for_phase (header, dump_base, LATE_RELOCS);
5580 Vcomp_loaded_handles = CALLN (Fmake_hash_table, QCtest, Qequal);
5581 dump_do_all_dump_reloc_for_phase (header, dump_base, VERY_LATE_RELOCS); 5580 dump_do_all_dump_reloc_for_phase (header, dump_base, VERY_LATE_RELOCS);
5582 initialized = true; 5581 initialized = true;
5583 5582