ebitengine / purego

Apache License 2.0
1.95k stars 63 forks source link

fix unintended R27 clobber on arm64 #165

Closed TotallyGamerJet closed 9 months ago

TotallyGamerJet commented 9 months ago

For some reason the Go assembler uses R27 as a scratch register when loading in a variable's address. Since callbackasm1 is called from C and the arm64 ABI states that R27 is callee saved it was unexpectedly clobbering the value. This commit now saves R27 and restores it at the end of the function.

I also cleaned up some of the other parts of this function. I store the floats in pairs which saved 4 instructions. I also use the zero register to put zero in callbackArgs.result directly

Updates #124 Closes #162

TotallyGamerJet commented 9 months ago

For future reference, Go's internal ABI is described here