Commit d8bc833d authored by Francois-Rene Rideau's avatar Francois-Rene Rideau

Better optimization-setting support, especially for clisp.

Better tests. Thanks to Robert Brown.
parent a78e13ed
......@@ -315,9 +315,11 @@
(DBG :optimization-settings)
#-(or allegro ecl-bytecmp gcl mkcl)
(loop :for i :from 0 :to 3 :do
(with-optimization-settings (`((speed ,i) (space ,i) (safety ,i) (debug ,i)))
(let ((s (get-optimization-settings)))
(loop :for q :in '(speed space safety debug) :do
#+mkcl (DBG :os i q s (assoc q s))
(assert-equal i (second (assoc q s)))))))
(loop :with settings = (get-optimization-settings)
:for i :from 0 :to 3 :do
(with-optimization-settings (`((speed ,i) (space ,i) (safety ,i) (debug ,i)))
(let ((s (get-optimization-settings)))
(loop :for q :in '(speed space safety debug) :do
#+mkcl (DBG :os i q s (assoc q s))
(assert-equal i (second (assoc q s))))))
(assert-equal (get-optimization-settings) settings))
......@@ -82,7 +82,7 @@ This can help you produce more deterministic output for FASLs."))
(let ((settings '(speed space safety debug compilation-speed #+(or cmu scl) c::brevity)))
#.`(loop :for x :in settings
,@(or #+(or abcl ecl gcl mkcl xcl) '(:for v :in +optimization-variables+))
:for y = (or #+clisp (gethash x system::*optimize*)
:for y = (or #+clisp (gethash x system::*optimize* 0)
#+(or abcl ecl mkcl xcl) (symbol-value v)
#+(or cmu scl) (slot-value c::*default-cookie*
(case x (compilation-speed 'c::cspeed)
......@@ -97,6 +97,13 @@ This can help you produce more deterministic output for FASLs."))
(unless (equal *previous-optimization-settings* settings)
(setf *previous-optimization-settings* settings))))
(defmacro with-optimization-settings ((&optional (settings *optimization-settings*)) &body body)
#+clisp
(let ((previous-settings (gensym "PREVIOUS-SETTINGS")))
`(let ((,previous-settings (get-optimization-settings)))
,@(when settings `((proclaim `(optimize ,@,settings))))
(unwind-protect (progn ,@body)
(proclaim `(optimize ,@,previous-settings)))))
#-clisp
`(let ,(loop :for v :in +optimization-variables+ :collect `(,v ,v))
,@(when settings `((proclaim `(optimize ,@,settings))))
,@body)))
......
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