1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-01-22 12:33:53 -08:00

Rework load mechanism to make Vcomp_loaded_handles unnecessary

This commit is contained in:
Andrea Corallo 2020-02-03 16:40:45 +00:00
parent ffa59bb161
commit 7c93bb113e
3 changed files with 19 additions and 31 deletions

View file

@ -517,14 +517,6 @@ Lisp_Object const *staticvec[NSTATICS]
int staticidx;
/* Lisp of freed native compilation unit handles.
Because during GC Vcomp_loaded_handles can't be used (hash table) temporary
annotate here and update Vcomp_loaded_handles when finished.
*/
static Lisp_Object freed_cu_handles[NATIVE_COMP_FLAG];
static void *pure_alloc (size_t, int);
/* Return PTR rounded up to the next multiple of ALIGNMENT. */
@ -3038,10 +3030,6 @@ cleanup_vector (struct Lisp_Vector *vector)
PSEUDOVEC_STRUCT (vector, Lisp_Native_Comp_Unit);
eassert (cu->handle);
dynlib_close (cu->handle);
/* We'll update Vcomp_loaded_handles when finished. */
freed_cu_handles[0] =
Fcons (make_mint_ptr (cu->handle), freed_cu_handles[0]);
set_cons_marked (XCONS (freed_cu_handles[0]));
}
}
@ -5949,9 +5937,6 @@ garbage_collect (void)
if (garbage_collection_messages)
message1_nolog ("Garbage collecting...");
if (NATIVE_COMP_FLAG)
freed_cu_handles[0] = Qnil;
block_input ();
shrink_regexp_cache ();
@ -6016,10 +6001,6 @@ garbage_collect (void)
gc_in_progress = 0;
if (NATIVE_COMP_FLAG)
FOR_EACH_TAIL (freed_cu_handles[0])
Fputhash (XCAR (freed_cu_handles[0]), Qnil, Vcomp_loaded_handles);
unblock_input ();
consing_until_gc = gc_threshold

View file

@ -42,6 +42,7 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
#define DATA_RELOC_IMPURE_SYM "d_reloc_imp"
#define FUNC_LINK_TABLE_SYM "freloc_link_table"
#define LINK_TABLE_HASH_SYM "freloc_hash"
#define COMP_UNIT_SYM "comp_unit"
#define TEXT_DATA_RELOC_SYM "text_data_reloc"
#define TEXT_DATA_RELOC_IMPURE_SYM "text_data_reloc_imp"
@ -1888,6 +1889,13 @@ emit_ctxt_code (void)
gcc_jit_type_get_pointer (comp.void_ptr_type),
PURE_RELOC_SYM));
gcc_jit_context_new_global (
comp.ctxt,
NULL,
GCC_JIT_GLOBAL_EXPORTED,
gcc_jit_type_get_pointer (comp.lisp_obj_ptr_type),
COMP_UNIT_SYM);
declare_imported_data ();
/* Functions imported from Lisp code. */
@ -3284,9 +3292,13 @@ load_comp_unit (struct Lisp_Native_Comp_Unit *comp_u, bool loading_dump)
{
dynlib_handle_ptr handle = comp_u->handle;
Lisp_Object lisp_handle = make_mint_ptr (handle);
bool reloading_cu = !NILP (Fgethash (lisp_handle, Vcomp_loaded_handles, Qnil));
Lisp_Object comp_u_obj;
XSETNATIVE_COMP_UNIT (comp_u_obj, comp_u);
Lisp_Object comp_u_lisp_obj;
XSETNATIVE_COMP_UNIT (comp_u_lisp_obj, comp_u);
Lisp_Object *saved_cu = dynlib_sym (handle, COMP_UNIT_SYM);
if (!saved_cu)
xsignal1 (Qnative_lisp_file_inconsistent, comp_u->file);
bool reloading_cu = *saved_cu ? true : false;
if (reloading_cu)
/* '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)
We must *never* mess with static pointers in an already loaded
eln. */
{
comp_u_obj = Fgethash (lisp_handle, Vcomp_loaded_handles, Qnil);
comp_u = XNATIVE_COMP_UNIT (comp_u_obj);
comp_u_lisp_obj = *saved_cu;
comp_u = XNATIVE_COMP_UNIT (comp_u_lisp_obj);
}
else
Fputhash (lisp_handle, comp_u_obj, Vcomp_loaded_handles);
*saved_cu = comp_u_lisp_obj;
freloc_check_fill ();
@ -3356,7 +3368,7 @@ load_comp_unit (struct Lisp_Native_Comp_Unit *comp_u, bool loading_dump)
if (!loading_dump)
/* Executing this will perform all the expected environment
modifications. */
top_level_run (comp_u_obj);
top_level_run (comp_u_lisp_obj);
return;
}
@ -3538,10 +3550,6 @@ syms_of_comp (void)
doc: /* Hash table symbol-function -> function-c-name. For
internal use during */);
Vcomp_sym_subr_c_name_h = CALLN (Fmake_hash_table);
DEFVAR_LISP ("comp-loaded-handles", Vcomp_loaded_handles,
doc: /* Hash table keeping track of the currently
loaded compilation unit: handle -> comp_u */);
Vcomp_loaded_handles = CALLN (Fmake_hash_table, QCtest, Qequal);
}
#endif /* HAVE_NATIVE_COMP */

View file

@ -5577,7 +5577,6 @@ pdumper_load (const char *dump_filename)
dump_hooks[i] ();
dump_do_all_dump_reloc_for_phase (header, dump_base, LATE_RELOCS);
Vcomp_loaded_handles = CALLN (Fmake_hash_table, QCtest, Qequal);
dump_do_all_dump_reloc_for_phase (header, dump_base, VERY_LATE_RELOCS);
initialized = true;