|
I recognize that the "0" is irrelevant, but what I'm asking is whether I actually need to explicitly push anything additional onto the stack before a void return.
For example, say I have a dummy function like
function void Foo() {
return
}
which gets called from main
function void main() {
do Foo()
}
That gets compiled to a
call main.Foo 0
which internally pushes the return-address and various pointers onto the stack (figure 8.5) and then goes to main.Foo. If main.Foo is compiled as just
function main.Foo 0
// push constant 0 omitted
return
That return statement gets assembled to a relatively complex set of operations (figure 8.5 again). If you walk through that logic, it will wind up returning "saved THAT" (from figure 8.4).
One can walk through various other scenarios, and see that you might end up with some other random value that was on top of the stack when the void function returned, or one of the local variables, etc, but since it doesn't matter what value is returned.
So my argument is that the `push constant 0` is superfluous, we don't need to do that in order to return from a void function without breaking our system. OTOH, I can imagine that I'm confused on some aspect of the mechanics, or that there is an edge case that I'm not accounting for.
|