[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
feature/native-comp 2f78ac3 04/11: * Add `comp--install-trampoline' mach
From: |
Andrea Corallo |
Subject: |
feature/native-comp 2f78ac3 04/11: * Add `comp--install-trampoline' machinery |
Date: |
Thu, 24 Sep 2020 04:13:18 -0400 (EDT) |
branch: feature/native-comp
commit 2f78ac32bbef78155e2f52e73d60f7b46fc8afea
Author: Andrea Corallo <akrl@sdf.org>
Commit: Andrea Corallo <akrl@sdf.org>
* Add `comp--install-trampoline' machinery
* src/comp.c (Fcomp__install_trampoline): New function to
install a subr trampoline into the function relocation table.
Once this is done any call from native compiled Lisp to the
related primitive will go through the `funcall' trampoline
making advicing effective.
---
src/comp.c | 34 ++++++++++++++++++++++++++++++++++
1 file changed, 34 insertions(+)
diff --git a/src/comp.c b/src/comp.c
index 63a58be..db6aee9 100644
--- a/src/comp.c
+++ b/src/comp.c
@@ -4102,6 +4102,39 @@ If BASE-DIR is nil use the first entry in
`comp-eln-load-path'. */)
concat2 (base_dir, Vcomp_native_version_dir));
}
+DEFUN ("comp--install-trampoline", Fcomp__install_trampoline,
+ Scomp__install_trampoline, 2, 2, 0,
+ doc: /* Install a TRAMPOLINE for primitive SUBR-NAME. */)
+ (Lisp_Object subr_name, Lisp_Object trampoline)
+{
+ CHECK_SYMBOL (subr_name);
+ CHECK_SUBR (trampoline);
+ Lisp_Object orig_subr = Fsymbol_function (subr_name);
+ CHECK_SUBR (orig_subr);
+
+ /* FIXME: add a post dump load trampoline machinery to remove this
+ check. */
+ if (will_dump_p ())
+ signal_error ("Trying to advice unexpected primitive before dumping",
+ subr_name);
+
+ Lisp_Object subr_l = Vcomp_subr_list;
+ ptrdiff_t i = ARRAYELTS (helper_link_table);
+ FOR_EACH_TAIL (subr_l)
+ {
+ Lisp_Object subr = XCAR (subr_l);
+ if (EQ (subr, orig_subr))
+ {
+ freloc.link_table[i] = XSUBR (trampoline)->function.a0;
+ return Qt;
+ }
+ i++;
+ }
+ signal_error ("Trying to install trampoline for non existent subr",
+ subr_name);
+ return Qnil;
+}
+
DEFUN ("comp--init-ctxt", Fcomp__init_ctxt, Scomp__init_ctxt,
0, 0, 0,
doc: /* Initialize the native compiler context. Return t on success.
*/)
@@ -5162,6 +5195,7 @@ native compiled one. */);
defsubr (&Scomp_el_to_eln_filename);
defsubr (&Scomp_native_driver_options_effective_p);
+ defsubr (&Scomp__install_trampoline);
defsubr (&Scomp__init_ctxt);
defsubr (&Scomp__release_ctxt);
defsubr (&Scomp__compile_ctxt_to_file);
- feature/native-comp updated (4a50f54 -> e5b052d), Andrea Corallo, 2020/09/24
- feature/native-comp 63c65b4 01/11: * lisp/emacs-lisp/comp.el (native-compile): Add OUTPUT parameter., Andrea Corallo, 2020/09/24
- feature/native-comp 2ab0966 03/11: Make CHECK_SUBR public, Andrea Corallo, 2020/09/24
- feature/native-comp 3ec1b93 05/11: * Add `comp--subr-safe-advice' entry point, Andrea Corallo, 2020/09/24
- feature/native-comp 2f78ac3 04/11: * Add `comp--install-trampoline' machinery,
Andrea Corallo <=
- feature/native-comp 0cc1804 07/11: Add a test for primitive advicing effectiveness, Andrea Corallo, 2020/09/24
- feature/native-comp b94a0a9 08/11: * lisp/emacs-lisp/comp.el (comp-never-optimize-functions): Clean-up., Andrea Corallo, 2020/09/24
- feature/native-comp 9d4fd66 02/11: * lisp/emacs-lisp/comp.el (comp-final): Log when interactively invoked., Andrea Corallo, 2020/09/24
- feature/native-comp 6d83902 10/11: * lisp/emacs-lisp/comp.el (comp-body-eff): Improve style., Andrea Corallo, 2020/09/24
- feature/native-comp 94736c4 09/11: Do not install a subr trampoline twice, Andrea Corallo, 2020/09/24
- feature/native-comp e5b052d 11/11: Rename comp--subr-safe-advice -> comp-subr-safe-advice, Andrea Corallo, 2020/09/24
- feature/native-comp db354ff 06/11: Call `comp--subr-safe-advice' from the advice machinery, Andrea Corallo, 2020/09/24