Re: Runtime optimizations

From: Matthew Danish (mdanish_at_andrew.cmu.edu)
Date: 03/02/04


Date: Tue, 2 Mar 2004 12:22:46 -0500

On Tue, Mar 02, 2004 at 08:56:19AM -0800, projectshave@yahoo.com wrote:
> Barry Margolin <barmar@alum.mit.edu> wrote in message news:<barmar-8381F0.16173101032004@comcast.ash.giganews.com>...
> > In article <20040301200359.GE31147@mapcar.org>,
> > Matthew Danish <mdanish@andrew.cmu.edu> wrote:
> >
> > > > If that's true, then does Allegro do any runtime optimizations? As a
> > > > dynamic language, a Lisp compiler could do a much better job if it did
> > > > type-aware specialization at runtime, if it had a better picture of
> > > > the type heirarchy, if it could propagate constants around, etc. Is
> > > > anything like this done in Allegro now?
> > >
> > > I sure hope so. I can't say much about Allegro, but CMUCL does
> > > intensive type-inferencing and makes use of the information to pick
> > > efficient representations and storage classes. It does copy
> > > propagation, constant folding, trace scheduling, register allocation,
> > > etc.
> >
> > I don't think it does this optimization dynamically at run time. It's
> > done based on static analysis of the code when it's first compiled.

First, yes, I misread his question.

> Thanks for the info. I also think these optimizations are done at
> compile-time, not run-time. If the compiler (cmucl or allegro) has a
> decent interface, one could call it dynamically. But this might still
> involve file I/O, which is slow relative to JIT compile time. If the
> compiler were separated nicely like FLINT (SML/NJ), one could do more
> with it.

Unlike SML which exists in a static world, the ANSI CL standard requires
an interface to the compiler which does not involve file I/O (unless
you're dealing with a compiler like GCL which uses GCC and temp files).
It's called COMPILE and it can be invoked at any time. In addition, I
am sure that you can fiddle with all sorts of fun compiler things at
run-time; I have done so in SBCL. One of the great parts about working
on most CL compilers is that you can dynamically modify many portions of
them directly from the top-level. Of course, if you screw up the
ability to compile a function, you may not be able to fix it without
restarting the lisp =)

I'm sure the SBCL and CMUCL people don't mind patches for interesting
optimizations, so long as they don't break other things.

-- 
; Matthew Danish <mdanish@andrew.cmu.edu>
; OpenPGP public key: C24B6010 on keyring.debian.org
; Signed or encrypted mail welcome.
; "There is no dark side of the moon really; matter of fact, it's all dark."


Relevant Pages

  • Re: How to avoid undesired default values?
    ... are documented in the documentation that comes with your compiler. ... of why static analysis for uninitialized variables does no work. ... This is why the good complete checking for uninitialized variables is done ...
    (comp.lang.fortran)
  • Re: Segfault only with optimization
    ... Realise that output is not the only measure of correctness. ... To KNOW that there is a buffer overrun the program MUST ... Static analysis is when you analyse the code *without* running it. ... compiler warnings or errors). ...
    (comp.lang.c)
  • Re: subroutine stack and C machine model
    ... was your canonical non-syntactic distinction. ... What matters to a compiler is what can ... did some static analysis on it and fixed all the memory leaks, ...
    (comp.lang.c)
  • Re: self-confidence of compiler
    ... What you are looking for is static analysis of the code, ... beyond what a compiler is ... Perhaps more importantly than the processing power (at least in my ... must be able to work out - would make the C# language specification ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Speed issue on Windows
    ... So my question is...why is ruby so slow on win32? ... just file I/O. ... A better compiler? ...
    (comp.lang.ruby)