Re: method calls and extra indirection

Rhys Weatherley <[email protected]>
Newsgroups gmane.comp.gnu.dotgnu.developer
Organization Southern Storm Software, Pty Ltd
Message-ID <[email protected]>
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.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.