[Openmcl-devel] Static Program Analysis
gb at clozure.com
Thu Jan 11 19:40:21 EST 2007
One of the reasons why tools like this don't exist (or don't exist in
great number) is they'r hard to write, both in the sense of being
tricky, non-trivial pieces of code and because CL doesn't provide
portable means to do the kind of code-walking that CL compilers may do
in an ad hoc, probably non-extensible way.
An X3J13 proposal to provide some of that support - I think that
it was called SYNTACTIC-ENVIRONMENT-ACCESS - was once passed,
and the facilities it offered were describe in CLtL2. There were
some design problems with the original proposal: a function called
DEFINE-DECLARATION either couldn't have worked or wouldn't have
been particularly as part of the basis for a general-purpose
code-walker or similar tools. (It's been a long time, and I
don't remember the issues clearly.)
PCL ("Portable Common Loops", a portable CLOS implementation)
used a code-walker to determine things like whether a method
body contained apparent calls to CALL-NEXT-METHOD and likely
a few other things. (It'd be interesting to know whether
a variable bound to a specialized method parameter is ever
SETQed, since some optimizations may be possible if the
class of an object is known at compile-time and determining
the class of a variable bound to a parameter is easier if
you don't have to worry about SETQ.)
Franz gave a presentation at ILC 2 years ago in which they
suggested semi-standard adoptation of a framework that they
use. My impression at the time was that it was similar to
the old SYNTACTC-ENVIRONMENT-ACCESS proposal with some of
the problems addressed and some holes filled. (I may be
mis-characterizing it, and have been meaning to think
harder about it than I have over the last couple of years.)
The natural, lisp-y way of looking at some of this is to
say "If I just had an industrial strength code-walker, I
could use that tool to build other tools that perform
compiler-like analysis." People have had some difficulty
defining exactly what tools an implementation should offer
in order to make the development of a portable code-walker
easier, and the closest thing to a "portable code-walker"
that I know of is probably PCL's. (PCL's code-walker
defined a high-level interface, implemented in large chunks
of implementation-specific code. It worked in MCL 20 years
ago, but the last time anyone tried to get it working in
OpenMCL is was obvious that bitrot had set in.)
I'm a little more interested in the approach of (for instance)
reviving/productizing/conditionalizing the PCL walker than
I am in trying to standardize on a portable layer underneath
On Thu, 11 Jan 2007, Brent Fulgham wrote:
> If I remember correctly, Stalin is a Scheme compiler -- so it falls into the CMUCL/SBCL optimization camp.
> I'm curious if any tools exist to perform analysis on Lisp code so that a user could the review the program to deal with specific coding errors.
> ----- Original Message ----
> From: Hamilton Link <helink at sandia.gov>
> To: Brent Fulgham <bfulg at pacbell.net>; openmcl-devel <openmcl-devel at clozure.com>
> Sent: Thursday, January 11, 2007 1:27:05 PM
> Subject: Re: [Openmcl-devel] Static Program Analysis
> I don't know about lisp, but there are such things for scheme... Stalin
> is one that springs to mind, if I am recalling correctly what it does.
> Brent Fulgham wrote:
>> I was reading that the Common Lisp standard supports various type declarations that may be used by the compiler to perform some optimizations. I also know I've seen various messages from the OpenMCL compiler that it performs some type of analysis, since it identifies unreferenced variables, undeclared functions, etc.
>> I'm curious if any tools exist in Common Lisp (or perhaps are already part of the compiler) that perform static analysis, along the lines of the Erlang Dialyzer (http://www.it.uu.se/research/group/hipe/dialyzer/) or even DrScheme's MrSpidey (http://www.cs.brown.edu/~sk/Publications/Papers/Published/ffkwf-mrspidey/).
>> These tools can identify cases where a user attempts to execute non-functions, perform math on non-numbers, etc.
>> The only thing a Google search turned up for me was an ancient (circa mid-80's) reference to an internal HP project called "MicroScope". I don't see much else that is more recent. The concensus on the #lisp IRC channel was that some static analysis is done in SBCL/CMUCL, but no one knew of any external tools.
>> Openmcl-devel mailing list
>> Openmcl-devel at clozure.com
> Openmcl-devel mailing list
> Openmcl-devel at clozure.com
More information about the Openmcl-devel