Skip to content

Commit 715bdb7

Browse files
TomasRikerrtoy
authored andcommitted
Proxy functions only for functions with only required args
1 parent 7003861 commit 715bdb7

1 file changed

Lines changed: 18 additions & 5 deletions

File tree

src/defmfun-check.lisp

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -379,11 +379,24 @@
379379
(block ,name
380380
(let ((%%pretty-fname ',pretty-fname))
381381
(declare (ignorable %%pretty-fname))
382-
(flet ((,name (&rest args)
383-
,(format nil "Proxy function to forward ~S calls to ~S" name impl-name)
384-
(apply #',impl-name args)))
385-
(declare (ignorable #',name) (inline ,name))
386-
,@forms))))
382+
;; For simple functions with only required arguments, locally define
383+
;; an inlined proxy function $FOO that forwards to FOO-IMPL.
384+
;; Within the proxy function, prevent FOO-IMPL from being inlined,
385+
;; as that would cause infinite recursive inlining.
386+
;; This mechanism catches direct and indirect (e.g. MAPCAR) recursion
387+
;; avoids having to go through $FOO with argument checking each time.
388+
,@(if (and nil required-args
389+
(null optional-args)
390+
(not restp)
391+
(not keywords-present-p)
392+
(not allow-other-keys-p))
393+
`((flet ((,name ,required-args
394+
,(format nil "Proxy function to forward ~S calls to ~S" name impl-name)
395+
(declare (notinline ,impl-name))
396+
(,impl-name ,@required-args)))
397+
(declare (ignorable #',name) (inline ,name))
398+
,@forms))
399+
forms))))
387400

388401
(let ,(when deprecated-p `((,warning-done-var nil)))
389402
(defun ,name (&rest ,args)

0 commit comments

Comments
 (0)