aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndrea Corallo2020-09-19 16:44:53 +0200
committerAndrea Corallo2020-09-23 21:08:02 +0200
commit2f78ac32bbef78155e2f52e73d60f7b46fc8afea (patch)
tree5f7835651c1310a8811c5def0d9e3c020a2986b1 /src
parent2ab0966b2fdf3a64d061727f005d32c5aad27594 (diff)
downloademacs-2f78ac32bbef78155e2f52e73d60f7b46fc8afea.tar.gz
emacs-2f78ac32bbef78155e2f52e73d60f7b46fc8afea.zip
* 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.
Diffstat (limited to 'src')
-rw-r--r--src/comp.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/comp.c b/src/comp.c
index 63a58be264c..db6aee9d7b1 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'. */)
4102 concat2 (base_dir, Vcomp_native_version_dir)); 4102 concat2 (base_dir, Vcomp_native_version_dir));
4103} 4103}
4104 4104
4105DEFUN ("comp--install-trampoline", Fcomp__install_trampoline,
4106 Scomp__install_trampoline, 2, 2, 0,
4107 doc: /* Install a TRAMPOLINE for primitive SUBR-NAME. */)
4108 (Lisp_Object subr_name, Lisp_Object trampoline)
4109{
4110 CHECK_SYMBOL (subr_name);
4111 CHECK_SUBR (trampoline);
4112 Lisp_Object orig_subr = Fsymbol_function (subr_name);
4113 CHECK_SUBR (orig_subr);
4114
4115 /* FIXME: add a post dump load trampoline machinery to remove this
4116 check. */
4117 if (will_dump_p ())
4118 signal_error ("Trying to advice unexpected primitive before dumping",
4119 subr_name);
4120
4121 Lisp_Object subr_l = Vcomp_subr_list;
4122 ptrdiff_t i = ARRAYELTS (helper_link_table);
4123 FOR_EACH_TAIL (subr_l)
4124 {
4125 Lisp_Object subr = XCAR (subr_l);
4126 if (EQ (subr, orig_subr))
4127 {
4128 freloc.link_table[i] = XSUBR (trampoline)->function.a0;
4129 return Qt;
4130 }
4131 i++;
4132 }
4133 signal_error ("Trying to install trampoline for non existent subr",
4134 subr_name);
4135 return Qnil;
4136}
4137
4105DEFUN ("comp--init-ctxt", Fcomp__init_ctxt, Scomp__init_ctxt, 4138DEFUN ("comp--init-ctxt", Fcomp__init_ctxt, Scomp__init_ctxt,
4106 0, 0, 0, 4139 0, 0, 0,
4107 doc: /* Initialize the native compiler context. Return t on success. */) 4140 doc: /* Initialize the native compiler context. Return t on success. */)
@@ -5162,6 +5195,7 @@ native compiled one. */);
5162 5195
5163 defsubr (&Scomp_el_to_eln_filename); 5196 defsubr (&Scomp_el_to_eln_filename);
5164 defsubr (&Scomp_native_driver_options_effective_p); 5197 defsubr (&Scomp_native_driver_options_effective_p);
5198 defsubr (&Scomp__install_trampoline);
5165 defsubr (&Scomp__init_ctxt); 5199 defsubr (&Scomp__init_ctxt);
5166 defsubr (&Scomp__release_ctxt); 5200 defsubr (&Scomp__release_ctxt);
5167 defsubr (&Scomp__compile_ctxt_to_file); 5201 defsubr (&Scomp__compile_ctxt_to_file);