> As an optimization for shallow nested functions (e.g., 3 levels or less), > it seems to me you could just avoid the stack walking entirely and add > $k-1$ arguments to each function at level $k$, i.e., at most 2 arguments > in all. This may even be an easy first implementation.I use this method with filtering unused in nested function args and local vars in my YAFL frontend (not finished :(( - at this moment generate LLVM bytecode but doesn't have all runtime suport code writed) Vladimir
On Nov 22, 2004, at 12:34 PM, Vladimir Merzliakov wrote:>> As an optimization for shallow nested functions (e.g., 3 levels or >> less), it seems to me you could just avoid the stack walking entirely >> and add $k-1$ arguments to each function at level $k$, i.e., at most >> 2 arguments in all. This may even be an easy first implementation. > > I use this method with filtering unused in nested function args and > local vars > in my YAFL frontend (not finished :(( - at this moment generate LLVM > bytecode but doesn't have all runtime suport code writed)So do you mean you pass static links for parent function stack frames as arguments? How do you generate them? --Vikram http://www.cs.uiuc.edu/~vadve http://llvm.cs.uiuc.edu/
>> I use this method with filtering unused in nested function args and local >> vars >> in my YAFL frontend (not finished :(( - at this moment generate LLVM >> bytecode but doesn't have all runtime suport code writed) > > So do you mean you pass static links for parent function stack frames as > arguments? How do you generate them? >Sorry, I must more careful read text. I use diff. method. All definitions in my YAFL parsed program AST have set of references to expressions where it used. All expressions know what function body contain it. All functions know what function contain it (if nested). I iterate by nested functions in deep and cache information about used declarations from parent function: args, locals, used grantparent declarations. Declaration used iff declaration used in code current processed nested function or in it nested function bodies or in it parent(grantparents) nested functions called from (it or it nested functions). Collect this information for non-nested function and all it nested functions i genereted LLVM code for function and all nested functions adding additional args to nested function for used declarations from parent function. Sorry for maybe not clear algorithm but it work for me. Vladimir