On Fri, 24 Jan 2003 16:31:16 +0100, Dejan Jelovic <[EMAIL PROTECTED]> wrote:
>Dominic Cooney wrote: > >> Tail calling is apparently slow because the activation >> records of the old and new method have to be swapped. >> Conversely, jmp should be quite fast. > >I'm lost. What's an "activation record"? > >Also, does that swapping you are describing need to be done when one is >calling the same function recursively? > >Dejan >www.jelovic.com Dominic, An "activation record" is an area of memory that holds info about the current method being run -- the method's arguments, local variables, etc. In CLR, we have two kinds (sort of): 1. For the IL abstract machine (called them "method states") 2. For the JIT'd native code, on the real processor stack (you'll find descriptions of "activation record" in the later chapters of books on compilers) As for tail. -- yes its performance in V1. The JIT teams has plans to improve it. And yes, as already pointed out, the win is not (necessarily) execution speed, but avoiding chomping all the memory on the stack until the program runs off the top. (note in passing that .NET compilers for "conventional" languages like C#, don't generate tail. calls, even if you craft a genuinely tail-recursive, accumulating factorial, for example. You'd want to be using a Scheme, Lisp or ML to see tail. prefixed calls in the wild) Jim You can read messages from the Advanced DOTNET archive, unsubscribe from Advanced DOTNET, or subscribe to other DevelopMentor lists at http://discuss.develop.com.
