[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Cost of a Function Call in EL?



PureBytes Links

Trading Reference Links

> Remember the CS assembly course where we learned that a function
> call involves saving all the status (register values), and
> returning from a function call means to recover them? 

That depends entirely on the compiler implementation.  If your 
compiler carries variable values &etc in registers for efficiency, 
then yes, you have to save them when you make a function call.  
(Because you don't know if the function will write over those values 
in the registers.)  But that assumes a reasonably sophisticated 
optimizing compiler, and I think it's safe to assume the EL compiler 
doesn't fall into that category.

If the compiler is a simple non-optimizing compiler, then there may 
not be ANY registers that need to be saved, other than the obvious 
PC, stack, etc registers that are automatically saved/restored by the 
JSR (or whatever) instruction.

In EL's case I'd guess there might be some overhead in *setting up* a 
function, once you're in it.  But actually calling a function might 
not take much overhead at all.

Gary