From d9db77704026ab0871325d431cae765981d167c2 Mon Sep 17 00:00:00 2001 From: Andrea Corallo Date: Mon, 23 Sep 2019 10:51:40 +0200 Subject: [PATCH] rework comp-call-optim-form-call --- lisp/emacs-lisp/comp.el | 51 +++++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/lisp/emacs-lisp/comp.el b/lisp/emacs-lisp/comp.el index 913761b3735..2525287716a 100644 --- a/lisp/emacs-lisp/comp.el +++ b/lisp/emacs-lisp/comp.el @@ -1372,31 +1372,32 @@ This can run just once." (subrp (subrp f)) (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)) - (comp-nargs-p callee-in-unit)) - 'callref - 'call)) - (args (if (eq call-type 'callref) - args - (fill-args args maxarg)))) - (comp-add-subr-to-relocs callee) - `(,call-type ,callee ,@(clean-args-ref args))) - ;; Intra compilation unit procedure call optimization. - (when (or (eq callee self) - ;; Attention speed 3 triggers that for non self calls too!! - (and (>= comp-speed 3) - callee-in-unit)) - (let* ((func-args (comp-func-args callee-in-unit)) - (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 ,callee ,@(clean-args-ref args))))))))) + (cond + ((and subrp (not (subr-native-elispp f))) + ;; Trampoline removal. + (let* ((maxarg (cdr (subr-arity f))) + (call-type (if (if subrp + (not (numberp maxarg)) + (comp-nargs-p callee-in-unit)) + 'callref + 'call)) + (args (if (eq call-type 'callref) + args + (fill-args args maxarg)))) + (comp-add-subr-to-relocs callee) + `(,call-type ,callee ,@(clean-args-ref args)))) + ;; Intra compilation unit procedure call optimization. + ;; Attention speed 3 triggers that for non self calls too!! + ((or (eq callee self) + (and (>= comp-speed 3) + callee-in-unit)) + (let* ((func-args (comp-func-args callee-in-unit)) + (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 ,callee ,@(clean-args-ref args))))))))) (defun comp-call-optim-func () "Perform trampoline call optimization for the current function." -- 2.39.5