aboutsummaryrefslogtreecommitdiffstats
path: root/etc
diff options
context:
space:
mode:
authorAndrea Corallo2026-03-12 14:30:54 +0100
committerAndrea Corallo2026-03-12 14:30:54 +0100
commit6198bb89b453a8b93113ac6bbb102043f5636334 (patch)
tree0006eddd65f0a0508be443f1a0cc3f22d437c74f /etc
parentfe121ef586b4adf2befc7e2af42d65f7acc25891 (diff)
downloademacs-scratch/better-comp.tar.gz
emacs-scratch/better-comp.zip
nativecomp: optimize local CU calls at speed 2scratch/better-comp
* etc/NEWS: Document speed-2 local call optimization. * etc/TODO: Remove completed item. * lisp/emacs-lisp/comp.el (comp--cu-local-func-c-name-v): New function. (comp--call-optim-form-call): Enable named local direct calls at speed 2. (comp--function-trampoline-form): New helper. (comp-trampoline-compile, comp-local-function-trampoline-compile): Share trampoline generation. * lisp/emacs-lisp/comp-run.el (comp-local-function-trampoline--install-now): New function. (comp-local-function-trampoline-install): Install local trampolines. Defer trampoline compilation until after load. * src/comp.c (emit_call, emit_ctxt_code, compile_function) (load_comp_unit, unload_comp_unit): Add local function relocation support. (native_comp_local_function_p): New function. (comp--install-local-function-trampoline): New subr. (syms_of_comp): Register it and update trampoline docs. * src/comp.h (Lisp_Native_Comp_Unit): Add local relocation slot. (native_comp_local_function_p): Declare. * src/data.c (Ffset): Install local trampolines for redefined named local native functions. Keep skipping anonymous lambdas. * src/pdumper.c: Clear local relocation state. * test/src/comp-tests.el (comp-tests--run-in-sub-emacs): New helper. (comp-tests--direct-call-redefinition-form): New helper. (comp-tests-direct-call-redefinition-speed-split): New test. (comp-tests-anonymous-lambda-recompile): New test. (comp-tests-direct-call-with-lambdas): Use an explicit output file.
Diffstat (limited to 'etc')
-rw-r--r--etc/NEWS6
-rw-r--r--etc/TODO9
2 files changed, 6 insertions, 9 deletions
diff --git a/etc/NEWS b/etc/NEWS
index 6107ee153f5..8f67b3f870f 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -3885,6 +3885,12 @@ At native compilation speed 2 and above, declared function types are
3885used for type propagation, value prediction, and optimization within 3885used for type propagation, value prediction, and optimization within
3886function bodies. 3886function bodies.
3887 3887
3888** Native compilation speed 2 now optimizes local calls.
3889Named calls between native-compiled functions in the same compilation
3890unit can now be optimized at speed 2 while still honoring later
3891redefinition through a trampoline. At speed 3, these calls keep the
3892previous direct-call behavior.
3893
3888** Nested backquotes are not supported any more in Pcase patterns. 3894** Nested backquotes are not supported any more in Pcase patterns.
3889 3895
3890--- 3896---
diff --git a/etc/TODO b/etc/TODO
index b93236d3759..e577fec0e6e 100644
--- a/etc/TODO
+++ b/etc/TODO
@@ -993,15 +993,6 @@ It would make it easy to add (and remove) mappings like
993 993
994*** Performance 994*** Performance
995 995
996**** Intra compilation unit call optimization
997
998We could have a mechanism similar to what we use for optimizing calls
999to primitive functions. IE using a link table for each compilation
1000unit (CU) such that calls from functions in a CU targeting functions
1001in the same CU don't have to go through funcall. If one of these
1002functions is redefined, a trampoline is compiled and installed to
1003restore the redirection through funcall.
1004
1005**** Better runtime function inlining 996**** Better runtime function inlining
1006 997
1007Several functions could be open-coded in generated code once exposed to 998Several functions could be open-coded in generated code once exposed to