Right now we are telling NanoJIT to save the callee save registers. However, it is not clear whether this is actually needed or not, and whether these registers are correctly restored at function exit.
Adding these does seem to cause a lot of register spilling and restoring at branches.
I noticed that the registers saved initially are popped in the guard section.
Looking at the generated code it seems to me though that when the code fragment has 'ret' instructions then the guard will never be executed - so in that case the saved registers will not be restored?
Is it mandatory to include the guard?
Here is a reply on this issue from Edwin Smith:
Yes, NumSavedRegs refers to the callee-saved registers. They're treated as extra
parameters and return values, causing them to be "alive" for the whole fragment,
since their last use will be the exit (guard) or return instruction. Any callee-saved
registers that aren't used by the register allocator should just be preserved without
any spills.
I don't think the guard is required, as long as all paths through the code
reach a return or non-truning call (i.e. throw), things should be fine. But my memory
is foggy in that area.
Right now we are telling NanoJIT to save the callee save registers. However, it is not clear whether this is actually needed or not, and whether these registers are correctly restored at function exit.
Adding these does seem to cause a lot of register spilling and restoring at branches.
This issue is related to:
https://github.com/adobe/avmplus/issues/4
Content reproduced: I have noticed that in lirasm immediately after the LIR_start instruction, there are additional instructions to save registers.
Similarly in LirHelper - this is done done in emitStart():
In lirasm when a fragment is ended a guard is inserted:
I noticed that the registers saved initially are popped in the guard section. Looking at the generated code it seems to me though that when the code fragment has 'ret' instructions then the guard will never be executed - so in that case the saved registers will not be restored?
Is it mandatory to include the guard?
Here is a reply on this issue from Edwin Smith: