Commit 6b4dc0c1 authored by Juan Jose Garcia Ripoll's avatar Juan Jose Garcia Ripoll
Browse files

Yet another iteration about where to store the inline form of a function: the...

Yet another iteration about where to store the inline form of a function: the storage has to be enclosed by an eval-when form so that it is never executed when the form is in a LET, LAMBDA, or other expression that can potentially create a closure.
parent 6426a1de
......@@ -138,9 +138,11 @@ special variable declarations, as these have been extracted before."
(second decl)))))
env)
(INLINE
(declare-inline (rest decl) env))
(loop for name in (rest decl) do (setf env (declare-inline name env)))
env)
(NOTINLINE
(declare-notinline (rest decl) env))
(loop for name in (rest decl) do (setf env (declare-notinline name env)))
env)
(DECLARATION
(validate-alien-declaration (rest decl) #'cmperr)
(cmp-env-extend-declaration 'alien (rest decl) env))
......
......@@ -124,30 +124,22 @@
;;; Proclamation and declaration handling.
(defun declare-inline (fname-list &optional (env *cmp-env*))
(unless (every #'si::valid-function-name-p fname-list)
(defun declare-inline (fname &optional (env *cmp-env*) (definition t))
(unless (si::valid-function-name-p fname)
(cmperr "Not a valid argument to INLINE declaration~%~4I~A"
fname-list))
(cmp-env-extend-declaration 'INLINE
(loop for name in fname-list
collect (cons name t))
env))
(defun declare-notinline (fname-list &optional (env *cmp-env*))
(unless (every #'si::valid-function-name-p fname-list)
(cmperr "Not a valid argument to NOTINLINE declaration~%~4I~A"
fname-list))
(cmp-env-extend-declaration 'INLINE
(loop for name in fname-list
collect (cons name nil))
env))
(cmp-env-extend-declaration 'INLINE (list (cons fname definition)) env))
(defun declare-notinline (fname &optional (env *cmp-env*))
(declare-inline fname env nil))
(defun proclaim-inline (fname-list)
(dolist (fun fname-list)
(unless (si::valid-function-name-p fun)
(error "Not a valid function name ~s in INLINE proclamation" fun))
(sys:put-sysprop fun 'INLINE t)
(sys:rem-sysprop fun 'NOTINLINE)))
(unless (sys:get-sysprop fun 'INLINE)
(sys:put-sysprop fun 'INLINE t)
(sys:rem-sysprop fun 'NOTINLINE))))
(defun proclaim-notinline (fname-list)
(dolist (fun fname-list)
......@@ -179,10 +171,14 @@
;;; a symbol property.
(defun maybe-install-inline-function (fname form env)
(let* ((x (cmp-env-search-declaration 'inline env))
(flag (assoc fname x :test #'same-fname-p)))
(when (and flag (cdr flag))
(rplacd flag form))
(when (sys:get-sysprop fname 'inline)
(cmpnote "Storing inline form for ~a" fname)
`(eval-when (:compile-toplevel :load-toplevel :execute)
(si::put-sysprop ',fname 'inline ',form)))))
(flag (assoc fname x :test #'same-fname-p))
(declared (and flag (cdr flag)))
(proclaimed (sys:get-sysprop fname 'inline)))
`(progn
,(when declared
`(eval-when (:compile-toplevel)
(c::declare-inline ',fname *cmp-env-root* ',form)))
,(when proclaimed
`(eval-when (:compile-toplevel :load-toplevel :execute)
(si::put-sysprop ',fname 'inline ',form))))))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment