diff options
| author | Andrea Corallo | 2026-03-12 14:30:54 +0100 |
|---|---|---|
| committer | Andrea Corallo | 2026-03-12 14:30:54 +0100 |
| commit | 6198bb89b453a8b93113ac6bbb102043f5636334 (patch) | |
| tree | 0006eddd65f0a0508be443f1a0cc3f22d437c74f /src/comp.h | |
| parent | fe121ef586b4adf2befc7e2af42d65f7acc25891 (diff) | |
| download | emacs-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 'src/comp.h')
| -rw-r--r-- | src/comp.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/comp.h b/src/comp.h index 16f2aab7b9a..5b4fec9d132 100644 --- a/src/comp.h +++ b/src/comp.h | |||
| @@ -44,6 +44,7 @@ struct Lisp_Native_Comp_Unit | |||
| 44 | Lisp_Object data_vec; | 44 | Lisp_Object data_vec; |
| 45 | /* STUFFS WE DO NOT DUMP!! */ | 45 | /* STUFFS WE DO NOT DUMP!! */ |
| 46 | Lisp_Object *data_relocs; | 46 | Lisp_Object *data_relocs; |
| 47 | void **local_func_relocs; | ||
| 47 | bool loaded_once; | 48 | bool loaded_once; |
| 48 | bool load_ongoing; | 49 | bool load_ongoing; |
| 49 | dynlib_handle_ptr handle; | 50 | dynlib_handle_ptr handle; |
| @@ -75,6 +76,8 @@ extern Lisp_Object load_comp_unit (struct Lisp_Native_Comp_Unit *comp_u, | |||
| 75 | 76 | ||
| 76 | extern void unload_comp_unit (struct Lisp_Native_Comp_Unit *); | 77 | extern void unload_comp_unit (struct Lisp_Native_Comp_Unit *); |
| 77 | 78 | ||
| 79 | extern bool native_comp_local_function_p (Lisp_Object function); | ||
| 80 | |||
| 78 | extern Lisp_Object native_function_doc (Lisp_Object function); | 81 | extern Lisp_Object native_function_doc (Lisp_Object function); |
| 79 | 82 | ||
| 80 | extern void syms_of_comp (void); | 83 | extern void syms_of_comp (void); |
| @@ -97,6 +100,13 @@ static inline | |||
| 97 | void unload_comp_unit (struct Lisp_Native_Comp_Unit *cu) | 100 | void unload_comp_unit (struct Lisp_Native_Comp_Unit *cu) |
| 98 | {} | 101 | {} |
| 99 | 102 | ||
| 103 | static inline bool | ||
| 104 | native_comp_local_function_p (Lisp_Object function) | ||
| 105 | { | ||
| 106 | (void) function; | ||
| 107 | return false; | ||
| 108 | } | ||
| 109 | |||
| 100 | extern void syms_of_comp (void); | 110 | extern void syms_of_comp (void); |
| 101 | 111 | ||
| 102 | INLINE_HEADER_END | 112 | INLINE_HEADER_END |