[Prev][Next][Index][Thread]

Re: Fun-O Basic Edition Compiler



In article <3C2A2420.2010404@quiotix.com>, Jeffrey Siegal 
<jbs@quiotix.com> wrote:

> >        G4/867   K7/700
> > d2c      6.0      3.8
> > Lisp              4.7
> > Java     3.9     25.6
> > C        4.2      3.1
> 
> 
> Stalin (P-III/850): 3.0

What I'd expect.  Stalin is known to be good.

 
> For reference, your C version takes 3.8 on this system.  From inspection 
> of the generated assembly, the difference appears to come from the 
> Stalin compiling the last call to Tak as a tail call (using a C  goto) 
> but gcc not doing so.

In a function this tight, that's enough to explain it.  If we can get 
d2c to make tail calls and drop the orig_sp arg when it's not needed 
then we'll be the same.

- d2c currently only does tail-call elimination on local functions, and 
only self-calls at that :-(  Basically, just enough so that code can 
have loops without blowing the stack.  It shouldn't be *too* hard to 
make mutual-call elimination in a set of local fuctions.  Tail-call 
elimination for Generic Functions is a harder problem (in any 
implementation) and tail-call ellmination for toplevel functions is hard 
when you're generating a C function per Dylan function.  Self-calls can 
of course be handled using a simple goto or loop.  Maybe that's worth 
doing.

- orig_sp is a stack pointer used to pass arguments to functions for 
which you have no idea what arguments they take.  This could be 
eliminated in many functions.  Basically, a function only needs it if it 
makes at least one call using a "general" entry point, or if a function 
it calls needs it.  This can easily be discovered during optimization.


Both these things are down in the noise for most programs as far as 
speed goes, but maybe doing OK on micro-benchmarks is important for 
marketing purposes.  I'd like to see proper tail-call elimination from a 
"supported programming styles" point of view.

 
> (This is "safe" mode.  All run-time checks are enabled except 
> integer/fixint overflow, which Stalin doesn't support.  Integers will 
> silently wrap.)

As in the Dylan, Java and C code.

-- Bruce



Follow-Ups: References: