Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pc: Add unsafe asm implementation for arm64 (#10)
On arm, there's a link register (LR) that typically contains the return address. For non-leaf functions, the function saves the LR to the stack. In our asm implementation, the LR will contain the return address to the caller `errtrace.Wrap`, but we want its' caller. We can rely on the SP containing the address saved by the caller, as the SP is not modified by the caller, but by the callee. This is based on: https://go.googlesource.com/go/+/refs/heads/master/src/cmd/compile/abi-internal.md#architecture-specifics-arm64-architecture-stack-layout specifically: ``` | return PC | ← RSP points to ``` Benchmark results: ``` │ main.txt │ asm.txt │ │ sec/op │ sec/op vs base │ GetCaller 203.150n ± 1% 2.062n ± 0% -98.98% (p=0.000 n=10) │ main.txt │ asm.txt │ │ sec/op │ sec/op vs base │ Wrap 221.50n ± 0% 15.95n ± 1% -92.80% (p=0.000 n=10) ```
- Loading branch information