Skip to content
Snippets Groups Projects
Commit 0a1ae661 authored by pmai's avatar pmai
Browse files

Allow users to disable tail-call optimization by setting a debug

optimization quality is higher than 2.  While we claim that debugging
is not degraded by TCO, some people evidently believe otherwise, so
this change tries to accomodate them, hopefully without disturbing the
status-quo too much.
parent 1f9f9486
No related branches found
No related tags found
No related merge requests found
......@@ -5,7 +5,7 @@
;;; Carnegie Mellon University, and has been placed in the public domain.
;;;
(ext:file-comment
"$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/compiler/envanal.lisp,v 1.27 1999/12/03 16:27:14 dtc Exp $")
"$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/compiler/envanal.lisp,v 1.28 2002/02/06 23:20:46 pmai Exp $")
;;;
;;; **********************************************************************
;;;
......@@ -401,8 +401,9 @@
(let ((result (return-result ret)))
(do-uses (use result)
(when (and (immediately-used-p result use)
(or (not (eq (node-derived-type use) *empty-type*))
(not (basic-combination-p use))
(eq (basic-combination-kind use) :local)))
(not (policy use (> debug 2)))
(or (not (eq (node-derived-type use) *empty-type*))
(not (basic-combination-p use))
(eq (basic-combination-kind use) :local)))
(setf (node-tail-p use) t)))))))
(undefined-value))
......@@ -1660,7 +1660,8 @@ will not show some calls that would have been displayed in a
non-tail-recursive implementation. In practice, this is not as bad as
it sounds\dash{}in fact it isn't really clearly worse, just different.
\xlref{debug-tail-recursion} for information about the debugger
implications of tail recursion.
implications of tail recursion, and how to turn it off for the sake of
more conservative backtrace information.
In order to ensure that tail-recursion is preserved in arbitrarily
complex calling patterns across separately compiled functions, the
......@@ -1700,6 +1701,10 @@ allocate stack space to represent the binding. Shallow-binding
implementations of dynamic scoping also require cleanup code to be
evaluated when the scope is exited.
In addition, optimization of tail-recursive calls is inhibited when
the \code{debug} optimization quality is greater than \code{2}
(\pxlref{debugger-policy}.)
\section{Local Call}
\label{local-call}
......
......@@ -356,6 +356,11 @@ doubt about how one function called another, it can usually be
eliminated by finding the source location in the calling frame (section
\ref{source-locations}.)
The elimination of tail-recursive frames can be prevented by disabling
tail-recursion optimization, which happens when the \code{debug}
optimization quality is greater than \code{2}
(\pxlref{debugger-policy}.)
For a more thorough discussion of tail recursion, \pxlref{tail-recursion}.
......@@ -754,11 +759,17 @@ information, and lifetime information that tells the debugger when arguments
are available (even when \code{speed} is \code{3} or the argument is set.) This is
the default.
\item[\code{\w{$>$ 2}}]
Any level greater than \code{2} gives level \code{2} and in addition
disables tail-call optimization, so that the backtrace will contain
frames for all invoked functions, even those in tail positions.
\item[\code{3}]
Level \code{2} plus all uninterned variables. In addition, lifetime
analysis is disabled (even when \code{speed} is \code{3}), ensuring that all variable
values are available at any known location within the scope of the binding.
This has a speed penalty in addition to the obvious space penalty.
analysis is disabled (even when \code{speed} is \code{3}), ensuring
that all variable values are available at any known location within
the scope of the binding. This has a speed penalty in addition to the
obvious space penalty.
\end{Lentry}
As you can see, if the \code{speed} quality is \code{3}, debugger performance is
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment