From 74d229783cb6a2d3d972732d3ea10facd55f6f5d Mon Sep 17 00:00:00 2001 From: Nikodemus Siivola Date: Fri, 8 Apr 2011 13:02:26 +0000 Subject: [PATCH] 1.0.47.15: %FUNCALL IR1 translator macroexpands the function form Code compiled correctly without this, but added an unnecessary cast to FUNCTION for the lambda in (FUNCALL (LAMBDA ...) ...) forms, which prevented local-call conversion and inlining for the lambda. Note: (FUNCALL (FUNCTION (LAMBDA ...)) ...) forms did not suffer from this. Step on the way to fixing lp#720382. --- NEWS | 2 ++ src/compiler/ir1-translators.lisp | 5 ++++- tests/compiler.pure.lisp | 8 ++++++++ version.lisp-expr | 2 +- 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index 135f26a..6092a89 100644 --- a/NEWS +++ b/NEWS @@ -9,6 +9,8 @@ changes relative to sbcl-1.0.47: * optimization: slightly faster ISQRT. (lp#713343) * bug fix: TRACE behaves better when attempting to trace undefined functions. (lp#740717) + * bug fix: missed optimizations for (FUNCALL (LAMBDA ...) ...) in + comparison to (FUNCALL #'(LAMBDA ...) ...). changes in sbcl-1.0.47 relative to sbcl-1.0.46: * bug fix: fix mach port rights leaks in mach exception handling code on diff --git a/src/compiler/ir1-translators.lisp b/src/compiler/ir1-translators.lisp index 238d04e..79c2afc 100644 --- a/src/compiler/ir1-translators.lisp +++ b/src/compiler/ir1-translators.lisp @@ -590,7 +590,10 @@ be a lambda expression." `(%funcall ,(ensure-lvar-fun-form function 'function) ,@arg-names)))) (def-ir1-translator %funcall ((function &rest args) start next result) - (let ((op (when (consp function) (car function)))) + ;; MACROEXPAND so that (LAMBDA ...) forms arriving here don't get an + ;; extra cast inserted for them. + (let* ((function (sb!xc:macroexpand function *lexenv*)) + (op (when (consp function) (car function)))) (cond ((eq op 'function) (with-fun-name-leaf (leaf (second function) start) (ir1-convert start next result `(,leaf ,@args)))) diff --git a/tests/compiler.pure.lisp b/tests/compiler.pure.lisp index bd70465..77fa813 100644 --- a/tests/compiler.pure.lisp +++ b/tests/compiler.pure.lisp @@ -3792,6 +3792,14 @@ s))) (g a))))) +(with-test (:name :funcall-lambda-inlined) + (assert (not + (ctu:find-code-constants + (compile nil + `(lambda (x y) + (+ x (funcall (lambda (z) z) y)))) + :type 'function)))) + ;;; This doesn't test LVAR-FUN-IS directly, but captures it ;;; pretty accurately anyways. (with-test (:name :lvar-fun-is) diff --git a/version.lisp-expr b/version.lisp-expr index f174645..25c1fbd 100644 --- a/version.lisp-expr +++ b/version.lisp-expr @@ -20,4 +20,4 @@ ;;; checkins which aren't released. (And occasionally for internal ;;; versions, especially for internal versions off the main CVS ;;; branch, it gets hairier, e.g. "0.pre7.14.flaky4.13".) -"1.0.47.14" +"1.0.47.15" -- 1.7.10.4