emacs-diffs
[Top][All Lists]
Advanced

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

feature/native-comp 87c6aa1 4/7: Make primitive redefinition effective t


From: Andrea Corallo
Subject: feature/native-comp 87c6aa1 4/7: Make primitive redefinition effective through trampoline synthesis
Date: Tue, 6 Oct 2020 12:37:43 -0400 (EDT)

branch: feature/native-comp
commit 87c6aa13b30281398688ec8693a0205bb84bc648
Author: Andrea Corallo <akrl@sdf.org>
Commit: Andrea Corallo <akrl@sdf.org>

    Make primitive redefinition effective through trampoline synthesis
    
        * lisp/loadup.el (dump-mode): Set `comp-enable-subr-trampolines'
        when finished bootstrap.
        * src/data.c (Ffset): Call `comp-enable-subr-trampolines' when
        redefining a subr.
        * src/comp.c (syms_of_comp): Define `comp-subr-trampoline-install'
        symbol.
        (syms_of_comp): Define `comp-enable-subr-trampolines' variable.
---
 lisp/loadup.el | 5 +++++
 src/comp.c     | 6 ++++++
 src/data.c     | 7 +++++++
 3 files changed, 18 insertions(+)

diff --git a/lisp/loadup.el b/lisp/loadup.el
index f218ec1..9112670 100644
--- a/lisp/loadup.el
+++ b/lisp/loadup.el
@@ -510,6 +510,11 @@ lost after dumping")))
                         ((equal dump-mode "bootstrap") "emacs")
                         ((equal dump-mode "pbootstrap") "bootstrap-emacs.pdmp")
                         (t (error "unrecognized dump mode %s" dump-mode)))))
+      (when (and (boundp 'comp-ctxt)
+                 (equal dump-mode "pdump"))
+        ;; Don't enable this before bootstrap is completed the as the
+        ;; compiler infrastructure may not be usable.
+        (setq comp-enable-subr-trampolines t))
       (message "Dumping under the name %s" output)
       (condition-case ()
           (delete-file output)
diff --git a/src/comp.c b/src/comp.c
index 5663c9e..076236e 100644
--- a/src/comp.c
+++ b/src/comp.c
@@ -5141,6 +5141,7 @@ native compiled one.  */);
   DEFSYM (Qlate, "late");
   DEFSYM (Qlambda_fixup, "lambda-fixup");
   DEFSYM (Qgccjit, "gccjit");
+  DEFSYM (Qcomp_subr_trampoline_install, "comp-subr-trampoline-install")
 
   /* To be signaled by the compiler.  */
   DEFSYM (Qnative_compiler_error, "native-compiler-error");
@@ -5246,6 +5247,11 @@ The last directory of this list is assumed to be the 
system one.  */);
      dump reload.  */
   Vcomp_eln_load_path = Fcons (build_string ("../native-lisp/"), Qnil);
 
+  DEFVAR_BOOL ("comp-enable-subr-trampolines", comp_enable_subr_trampolines,
+              doc: /* When non-nil enable trampoline synthesis
+                      triggerd by `fset' making primitives
+                      redefinable effectivelly.  */);
+
   DEFVAR_LISP ("comp-installed-trampolines-h", Vcomp_installed_trampolines_h,
               doc: /* Hash table subr-name -> bool.  */);
   Vcomp_installed_trampolines_h = CALLN (Fmake_hash_table);
diff --git a/src/data.c b/src/data.c
index 8c39c31..c6629dd 100644
--- a/src/data.c
+++ b/src/data.c
@@ -775,6 +775,13 @@ DEFUN ("fset", Ffset, Sfset, 2, 2, 0,
 
   eassert (valid_lisp_object_p (definition));
 
+#ifdef HAVE_NATIVE_COMP
+  if (comp_enable_subr_trampolines
+      && SUBRP (function)
+      && !SUBR_NATIVE_COMPILEDP (function))
+    CALLN (Ffuncall, Qcomp_subr_trampoline_install, symbol);
+#endif
+
   set_symbol_function (symbol, definition);
 
   return definition;



reply via email to

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