Function: comp-trampoline-compile

comp-trampoline-compile is a byte-compiled function defined in comp.el.gz.

Signature

(comp-trampoline-compile SUBR-NAME)

Documentation

Synthesize compile and return a trampoline for SUBR-NAME.

Source Code

;; Defined in /usr/src/emacs/lisp/emacs-lisp/comp.el.gz
(defun comp-trampoline-compile (subr-name)
  "Synthesize compile and return a trampoline for SUBR-NAME."
  (let* ((lambda-list (comp-make-lambda-list-from-subr
                       (symbol-function subr-name)))
         ;; The synthesized trampoline must expose the exact same ABI of
         ;; the primitive we are replacing in the function reloc table.
         (form `(lambda ,lambda-list
                  (let ((f #',subr-name))
                    (,(if (memq '&rest lambda-list) #'apply 'funcall)
                     f
                     ,@(cl-loop
                        for arg in lambda-list
                        unless (memq arg '(&optional &rest))
                        collect arg)))))
         ;; Use speed 1 for compilation speed and not to optimize away
         ;; funcall calls!
         (byte-optimize nil)
         (native-comp-speed 1)
         (lexical-binding t))
    (comp--native-compile
     form nil
     (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'")))))