emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

feature/native-comp 7c93bb1 1/2: Rework load mechanism to make Vcomp_loa


From: Andrea Corallo
Subject: feature/native-comp 7c93bb1 1/2: Rework load mechanism to make Vcomp_loaded_handles unnecessary
Date: Tue, 4 Feb 2020 06:08:51 -0500 (EST)

branch: feature/native-comp
commit 7c93bb113ec353baa6316fa97744e65a6e109d91
Author: Andrea Corallo <address@hidden>
Commit: Andrea Corallo <address@hidden>

    Rework load mechanism to make Vcomp_loaded_handles unnecessary
---
 src/alloc.c   | 19 -------------------
 src/comp.c    | 30 +++++++++++++++++++-----------
 src/pdumper.c |  1 -
 3 files changed, 19 insertions(+), 31 deletions(-)

diff --git a/src/alloc.c b/src/alloc.c
index 431238b..faa8e70 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -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
diff --git a/src/comp.c b/src/comp.c
index 7a1ccdc..ebe7b8b 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/>.  */
 #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 */
diff --git a/src/pdumper.c b/src/pdumper.c
index 8a75849..ae8fe01 100644
--- a/src/pdumper.c
+++ b/src/pdumper.c
@@ -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;
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]