totalspectrum/spin2cpp

register save/restore refactor

Wuerfel21 opened this issue · 0 comments

I feel there's some pretty decent size and performance savings to be had by re-doing pushregs/popregs . On the P2 side, mostly, anyways.

If the other three save registers are moved in front of the locals and the semantics of COUNT_ are changed (such that it always holds the saved local count for the current stack frame), the entire save/restore can be done in one big block transfer and the check for the zero count case is eliminated. Push could obviously be called with CALLPA to save a decent bit of space. Also, is popregs ever not the last thing before RET? (unwind aside) That could be turned into a tail call instead then.

I tried to make it happen, but got stuck on getting it to emit the registers in the right place.

On P1, the COUNT_ and frame pointer could be stored in words for a RAM save. Would that cause issues when the stack is allocated from heap? (Is that even supported/viable on P1?) EDIT: should work with now GC allocator if pointer is in lower word?