[Compiler-sig] max stack depth calculation

Neil Schemenauer nas-pycompiler at arctrix.com
Sun Mar 28 21:57:49 EST 2004


The stack depth calculation that I checked in for the AST compiler
could end up being fairly expensive.  It tries to find control paths
that give the highest entry stack depth for each basic block.  Once
you know the entry stack depths, you can examine each block and find
the one that uses the largest stack.

I had a thought today on how to make the calculation more efficient.
Could we assume that the entry stack depth for each basic block is
the same, regardless of the control path taken?

I've tried changing the calculation to make use of that assumption.
It does sometimes end up with a smaller stack than the old
calculation.  However, I haven't found a case were it leads to a
stack overflow.

  Neil



More information about the Compiler-sig mailing list