Raymond Toy pushed to branch master at cmucl / cmucl
Commits: 48d1f01f by Raymond Toy at 2016-09-10T12:40:03-07:00 Fix #24: compile already compiled function
If the function is already compiled and we don't have the source for it any more, just return without recompiling anything.
- - - - - ae93b43b by Raymond Toy at 2016-09-10T12:40:34-07:00 Add test for issue #24.
- - - - - 94259938 by Raymond Toy at 2016-09-25T18:59:48-07:00 Don't try to get the lambda-expression for a function
Since we're just going to return the original compiled function, there's no point in trying to get the function-lambda-expression of the function. So, if we're given a function, just return the (default) definition.
- - - - - d6ae3337 by Raymond Toy at 2016-09-26T02:01:07+00:00 Merge branch 'rtoy-fix-24-compile-foo' into 'master'
Fix #24: compilation of (compile 'foo)
If the function is already compiled and we don't have the source for it, we don't need to do anything, per CLHS.
Test case added as well.
See merge request !12 - - - - -
2 changed files:
- src/compiler/main.lisp - tests/issues.lisp
Changes:
===================================== src/compiler/main.lisp ===================================== --- a/src/compiler/main.lisp +++ b/src/compiler/main.lisp @@ -2041,11 +2041,7 @@ ((or cons eval:interpreted-function) `#',(get-lambda-to-compile definition)) (function - (multiple-value-bind (exp lexenv) - (function-lambda-expression definition) - (if (and exp (not lexenv)) - `#',exp - `',definition))))) + definition))) (*source-info* (make-lisp-source-info form)) (*top-level-lambdas* ()) (*converting-for-interpreter* nil) @@ -2069,6 +2065,14 @@ (*gensym-counter* 0) (*current-function-names* (list name)) (intl::*default-domain* intl::*default-domain*)) + ;; As mentioned above, we can return the same function if the + ;; function was already compiled. We do this when FORM is EQ + ;; to DEFINITION (which happens above if we have a compiled + ;; function that we don't have the source for or was defined + ;; in a non-null environment. + (when (and name (eq form definition)) + (return-from compile + (values name nil nil))) (with-debug-counters (clear-stuff) (find-source-paths form 0)
===================================== tests/issues.lisp ===================================== --- a/tests/issues.lisp +++ b/tests/issues.lisp @@ -310,3 +310,8 @@ (assert-true (pathnamep fasl-file)) (assert-equalp (list fasl-file nil nil) (multiple-value-list (compile-file test-file :load t))))) + +(define-test issue.24 + (:tag :issues) + (let* ((test-file #.(merge-pathnames #p"resources/issue-24.lisp" cl:*load-pathname*))) + (assert-true (compile-file test-file :load t))))
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/compare/f810fc97740f2bd1405247fcc...