Function: comp--call-optim-form-call
comp--call-optim-form-call is a byte-compiled function defined in
comp.el.gz.
Signature
(comp--call-optim-form-call CALLEE ARGS)
Source Code
;; Defined in /usr/src/emacs/lisp/emacs-lisp/comp.el.gz
(defun comp--call-optim-form-call (callee args)
(cl-flet ((fill-args (args total)
;; Fill missing args to reach TOTAL
(append args (cl-loop repeat (- total (length args))
collect (make--comp-mvar :constant nil)))))
(when (and callee
(or (symbolp callee)
(gethash callee (comp-ctxt-byte-func-to-func-h comp-ctxt)))
(not (memq callee native-comp-never-optimize-functions)))
(let* ((f (if (symbolp callee)
(symbol-function callee)
(cl-assert (byte-code-function-p callee))
callee))
;; Below call to `subrp' returns nil on an advised
;; primitive F, so that we do not optimize calls to F
;; with the funcall trampoline removal below. But if F
;; is advised while we compile its call, it is very
;; likely to be advised also when that call is executed.
;; And in that case an "unoptimized" call to F is
;; actually cheaper since it avoids the call to the
;; intermediate native trampoline (bug#67005).
(subrp (subrp f))
(comp-func-callee (comp--func-in-unit callee)))
(cond
((and subrp (not (native-comp-function-p f)))
;; Trampoline removal.
(let* ((callee (intern (subr-name f))) ; Fix aliased names.
(maxarg (cdr (subr-arity f)))
(call-type (if (if subrp
(not (numberp maxarg))
(comp-nargs-p comp-func-callee))
'callref
'call))
(args (if (eq call-type 'callref)
args
(fill-args args maxarg))))
`(,call-type ,callee ,@args)))
;; Intra compilation unit procedure call optimization.
;; Attention speed 3 triggers this for non self calls too!!
((and comp-func-callee
(comp-func-c-name comp-func-callee)
(or (and (>= (comp-func-speed comp-func) 3)
(comp--func-unique-in-cu-p callee))
(and (>= (comp-func-speed comp-func) 2)
;; Anonymous lambdas can't be redefined so are
;; always safe to optimize.
(byte-code-function-p callee))))
(let* ((func-args (comp-func-l-args comp-func-callee))
(nargs (comp-nargs-p func-args))
(call-type (if nargs 'direct-callref 'direct-call))
(args (if (eq call-type 'direct-callref)
args
(fill-args args (comp-args-max func-args)))))
`(,call-type ,(comp-func-c-name comp-func-callee) ,@args)))
((comp--type-hint-p callee)
`(call ,callee ,@args)))))))