[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [DotGNU]method calls and extra indirection
From: |
Rhys Weatherley |
Subject: |
Re: [DotGNU]method calls and extra indirection |
Date: |
Sat, 3 Apr 2004 08:21:01 +1000 |
User-agent: |
KMail/1.4.3 |
On Saturday 03 April 2004 03:10 am, Llewellyn Pritchard wrote:
> Now my question is, why/what prevents you from declaring locals here (this
> specific example is a bit stupid)? I dont see this in any of the CASES.
Local variables that are declared in the individual case blocks will not be
shared between multiple cases, leading to greater memory usage in the
intepreter's local variable frame. This can have a significant impact when
you recursively call back into the interpreter from itself. I try to avoid
recursive calls where possible, but I cannot eliminate them all.
Theoretically, the C compiler should use dynamic flow analysis to determine
when it can reuse the same stack slot for multiple variables, and reduce the
frame size itself. But gcc doesn't appear to do that particularly well on
the mega-huge switch statements in pnet. So I have to "help" it by spelling
out where the reusable slots are.
You'll find that there is a lot of odd stuff like that in CVM that is actually
designed to achieve greater performance or less memory usage. It just isn't
readily apparent to the untrained eye. Some of these tricks are only
apparent once you've written 2-3 bad VM's and learnt from your mistakes. :-)
Cheers,
Rhys.