Dino of BBG FX team asked me — when you mark a small f1() function inline (like manually copying the code into main()), you save yourself a jump or a new stack frame?
A: both a jump and a new stack frame.
It turns out a new stack frame would require a jump, because after the new stack frame is created, thread jumps to the beginning of f1().
However, there’s something to set up before the jump — Suppose f1() is on Line 5 in main(), then Line 6’s address has to be saved to CPU register, otherwise the thread has no idea where to” jump back” after returning from f1(). According to my codebashing training (required at RTS team), this Line 6’s address is saved in the main() stack frame, not the f1() stack frame!
Note the Line 6’s address is not a heap address not a stack address but an pointer into the code area.