From: Andrea Corallo Date: Mon, 23 Sep 2019 07:13:46 +0000 (+0200) Subject: add some call optimizer doc X-Git-Tag: emacs-28.0.90~2727^2~1115 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=bdea0f62b55e986136f5677369f354e4f5849863;p=emacs.git add some call optimizer doc --- diff --git a/lisp/emacs-lisp/comp.el b/lisp/emacs-lisp/comp.el index 34aafe401d4..913761b3735 100644 --- a/lisp/emacs-lisp/comp.el +++ b/lisp/emacs-lisp/comp.el @@ -1341,7 +1341,19 @@ This can run just once." ;;; Call optimizer pass specific code. -;; Try to avoid funcall trampoline use when possible. +;; This pass is responsible for the following optimizations: +;; - Call to subrs that are in defined in the C source and are passing through +;; funcall trampoline gets optimized into normal indirect calls. +;; This makes effectively this calls equivalent to all the subrs that got +;; dedicated byte-code ops. +;; Triggered at comp-speed >= 2. +;; - Recursive calls gets optimized into direct calls. +;; Triggered at comp-speed >= 2. +;; - Intra compilation unit procedure calls gets optimized into direct calls. +;; This can be a big win and even allow gcc to inline but does not make +;; function in the compilation unit re-definable safely without recompiling +;; the full compilation unit. +;; For this reason this is triggered only at comp-speed == 3. (defun comp-call-optim-form-call (callee args self) "" @@ -1361,6 +1373,7 @@ This can run just once." (callee-in-unit (gethash callee (comp-ctxt-funcs-h comp-ctxt)))) (if (and subrp (not (subr-native-elispp f))) + ;; Trampoline removal. (let* ((maxarg (cdr (subr-arity f))) (call-type (if (if subrp (not (numberp maxarg))