diff options
Diffstat (limited to 'lisp/emacs-lisp/comp.el')
-rw-r--r-- | lisp/emacs-lisp/comp.el | 69 |
1 files changed, 42 insertions, 27 deletions
diff --git a/lisp/emacs-lisp/comp.el b/lisp/emacs-lisp/comp.el index 7ba8e956fb2..a6b9b3f57ea 100644 --- a/lisp/emacs-lisp/comp.el +++ b/lisp/emacs-lisp/comp.el @@ -85,13 +85,17 @@ This is intended for debugging the compiler itself. :type 'boolean :version "28.1") -(defcustom native-comp-deferred-compilation-deny-list +(defcustom native-comp-jit-compilation-deny-list '() "List of regexps to exclude matching files from deferred native compilation. Files whose names match any regexp are excluded from native compilation." :type '(repeat regexp) :version "28.1") +(make-obsolete-variable 'native-comp-deferred-compilation-deny-list + 'native-comp-jit-compilation-deny-list + "29.1") + (defcustom native-comp-bootstrap-deny-list '() "List of regexps to exclude files from native compilation during bootstrap. @@ -105,7 +109,12 @@ during bootstrap." ;; correctly (see comment in `advice--add-function'). DO NOT ;; REMOVE. macroexpand rename-buffer) - "Primitive functions to exclude from trampoline optimization." + "Primitive functions to exclude from trampoline optimization. + +Primitive functions included in this list will not be called +directly by the native code being compiled, this makes +tranpolines for those primitives not necessary in case of +function redefinition/advise." :type '(repeat symbol) :version "28.1") @@ -695,7 +704,7 @@ Useful to hook into pass checkers.") ;;;###autoload (defun comp-subr-trampoline-install (subr-name) "Make SUBR-NAME effectively advice-able when called from native code." - (unless (or (null comp-enable-subr-trampolines) + (unless (or (null native-comp-enable-subr-trampolines) (memq subr-name native-comp-never-optimize-functions) (gethash subr-name comp-installed-trampolines-h)) (cl-assert (subr-primitive-p (symbol-function subr-name))) @@ -3782,6 +3791,32 @@ Return the trampoline if found or nil otherwise." when (file-exists-p filename) do (cl-return (native-elisp-load filename)))) +(defun comp--trampoline-abs-filename (subr-name) + "Return the absolute filename for a trampoline for SUBR-NAME." + (cl-loop + with dirs = (if (stringp native-comp-enable-subr-trampolines) + (list native-comp-enable-subr-trampolines) + (if native-compile-target-directory + (list (expand-file-name comp-native-version-dir + native-compile-target-directory)) + (comp-eln-load-path-eff))) + with rel-filename = (comp-trampoline-filename subr-name) + for dir in dirs + for abs-filename = (expand-file-name rel-filename dir) + unless (file-exists-p dir) + do (ignore-errors + (make-directory dir t) + (cl-return abs-filename)) + when (file-writable-p abs-filename) + do (cl-return abs-filename) + ;; Default to some temporary directory if no better option was + ;; found. + finally (cl-return + (expand-file-name + (make-temp-file-internal (file-name-sans-extension rel-filename) + 0 ".eln" nil) + temporary-file-directory)))) + (defun comp-trampoline-compile (subr-name) "Synthesize compile and return a trampoline for SUBR-NAME." (let* ((lambda-list (comp-make-lambda-list-from-subr @@ -3803,25 +3838,7 @@ Return the trampoline if found or nil otherwise." (lexical-binding t)) (comp--native-compile form nil - ;; If we've disabled nativecomp, don't write the trampolines to - ;; the eln cache (but create them). - (and (not inhibit-automatic-native-compilation) - (cl-loop - for dir in (if native-compile-target-directory - (list (expand-file-name comp-native-version-dir - native-compile-target-directory)) - (comp-eln-load-path-eff)) - for f = (expand-file-name - (comp-trampoline-filename subr-name) - dir) - unless (file-exists-p dir) - do (ignore-errors - (make-directory dir t) - (cl-return f)) - when (file-writable-p f) - do (cl-return f) - finally (error "Cannot find suitable directory for output in \ -`native-comp-eln-load-path'")))))) + (comp--trampoline-abs-filename subr-name)))) ;; Some entry point support code. @@ -4110,14 +4127,12 @@ the deferred compilation mechanism." data ;; So we return the compiled function. (native-elisp-load data))) - ;; We may have created a temporary file when we're being - ;; called with something other than a file as the argument. - ;; Delete it if we can. (when (and (not (stringp function-or-file)) (not output) comp-ctxt (comp-ctxt-output comp-ctxt) (file-exists-p (comp-ctxt-output comp-ctxt))) + ;; NOTE: Not sure if we want to remove this or being cautious. (cond ((eq 'windows-nt system-type) ;; We may still be using the temporary .eln file. (ignore-errors (delete-file (comp-ctxt-output comp-ctxt)))) @@ -4137,11 +4152,11 @@ LOAD and SELECTOR work as described in `native--compile-async'." (t (error "SELECTOR must be a function a regexp or nil"))) ;; Also exclude files from deferred compilation if ;; any of the regexps in - ;; `native-comp-deferred-compilation-deny-list' matches. + ;; `native-comp-jit-compilation-deny-list' matches. (and (eq load 'late) (cl-some (lambda (re) (string-match-p re file)) - native-comp-deferred-compilation-deny-list)))) + native-comp-jit-compilation-deny-list)))) (defun native--compile-async (files &optional recursively load selector) ;; BEWARE, this function is also called directly from C. |