From 96a67450887314cedbd9e8634ad92b76a0443779 Mon Sep 17 00:00:00 2001 From: Cherry Zhang Date: Thu, 8 Apr 2021 12:13:58 -0400 Subject: [PATCH] runtime: use register ABI in panicIndex/Slice functions runtime.panicIndex*/panicSlice* functions move the arguments in the right place then tail calls goPanicIndex*/Slice* using internal ABI. (It uses internal ABI to avoid wrappers, because the callee needs to get the caller's PC, to know whether it panics in the runtime.) This CL makes it to use the register ABI if it is enabled. Change-Id: Id2ebb51b4bfb3e9aa7cb66d0a9aee63fccee5ecd Reviewed-on: https://go-review.googlesource.com/c/go/+/308649 Trust: Cherry Zhang Run-TryBot: Cherry Zhang Reviewed-by: Michael Knyszek TryBot-Result: Go Bot --- src/runtime/asm_amd64.s | 70 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/src/runtime/asm_amd64.s b/src/runtime/asm_amd64.s index cc31e5c657..77f4939b30 100644 --- a/src/runtime/asm_amd64.s +++ b/src/runtime/asm_amd64.s @@ -1874,68 +1874,138 @@ TEXT runtime·debugCallPanicked(SB),NOSPLIT,$16-16 // The tail call makes these stubs disappear in backtraces. // Defined as ABIInternal since they do not use the stack-based Go ABI. TEXT runtime·panicIndex(SB),NOSPLIT,$0-16 +#ifdef GOEXPERIMENT_regabiargs + MOVQ CX, BX +#else MOVQ AX, x+0(FP) MOVQ CX, y+8(FP) +#endif JMP runtime·goPanicIndex(SB) TEXT runtime·panicIndexU(SB),NOSPLIT,$0-16 +#ifdef GOEXPERIMENT_regabiargs + MOVQ CX, BX +#else MOVQ AX, x+0(FP) MOVQ CX, y+8(FP) +#endif JMP runtime·goPanicIndexU(SB) TEXT runtime·panicSliceAlen(SB),NOSPLIT,$0-16 +#ifdef GOEXPERIMENT_regabiargs + MOVQ CX, AX + MOVQ DX, BX +#else MOVQ CX, x+0(FP) MOVQ DX, y+8(FP) +#endif JMP runtime·goPanicSliceAlen(SB) TEXT runtime·panicSliceAlenU(SB),NOSPLIT,$0-16 +#ifdef GOEXPERIMENT_regabiargs + MOVQ CX, AX + MOVQ DX, BX +#else MOVQ CX, x+0(FP) MOVQ DX, y+8(FP) +#endif JMP runtime·goPanicSliceAlenU(SB) TEXT runtime·panicSliceAcap(SB),NOSPLIT,$0-16 +#ifdef GOEXPERIMENT_regabiargs + MOVQ CX, AX + MOVQ DX, BX +#else MOVQ CX, x+0(FP) MOVQ DX, y+8(FP) +#endif JMP runtime·goPanicSliceAcap(SB) TEXT runtime·panicSliceAcapU(SB),NOSPLIT,$0-16 +#ifdef GOEXPERIMENT_regabiargs + MOVQ CX, AX + MOVQ DX, BX +#else MOVQ CX, x+0(FP) MOVQ DX, y+8(FP) +#endif JMP runtime·goPanicSliceAcapU(SB) TEXT runtime·panicSliceB(SB),NOSPLIT,$0-16 +#ifdef GOEXPERIMENT_regabiargs + MOVQ CX, BX +#else MOVQ AX, x+0(FP) MOVQ CX, y+8(FP) +#endif JMP runtime·goPanicSliceB(SB) TEXT runtime·panicSliceBU(SB),NOSPLIT,$0-16 +#ifdef GOEXPERIMENT_regabiargs + MOVQ CX, BX +#else MOVQ AX, x+0(FP) MOVQ CX, y+8(FP) +#endif JMP runtime·goPanicSliceBU(SB) TEXT runtime·panicSlice3Alen(SB),NOSPLIT,$0-16 +#ifdef GOEXPERIMENT_regabiargs + MOVQ DX, AX +#else MOVQ DX, x+0(FP) MOVQ BX, y+8(FP) +#endif JMP runtime·goPanicSlice3Alen(SB) TEXT runtime·panicSlice3AlenU(SB),NOSPLIT,$0-16 +#ifdef GOEXPERIMENT_regabiargs + MOVQ DX, AX +#else MOVQ DX, x+0(FP) MOVQ BX, y+8(FP) +#endif JMP runtime·goPanicSlice3AlenU(SB) TEXT runtime·panicSlice3Acap(SB),NOSPLIT,$0-16 +#ifdef GOEXPERIMENT_regabiargs + MOVQ DX, AX +#else MOVQ DX, x+0(FP) MOVQ BX, y+8(FP) +#endif JMP runtime·goPanicSlice3Acap(SB) TEXT runtime·panicSlice3AcapU(SB),NOSPLIT,$0-16 +#ifdef GOEXPERIMENT_regabiargs + MOVQ DX, AX +#else MOVQ DX, x+0(FP) MOVQ BX, y+8(FP) +#endif JMP runtime·goPanicSlice3AcapU(SB) TEXT runtime·panicSlice3B(SB),NOSPLIT,$0-16 +#ifdef GOEXPERIMENT_regabiargs + MOVQ CX, AX + MOVQ DX, BX +#else MOVQ CX, x+0(FP) MOVQ DX, y+8(FP) +#endif JMP runtime·goPanicSlice3B(SB) TEXT runtime·panicSlice3BU(SB),NOSPLIT,$0-16 +#ifdef GOEXPERIMENT_regabiargs + MOVQ CX, AX + MOVQ DX, BX +#else MOVQ CX, x+0(FP) MOVQ DX, y+8(FP) +#endif JMP runtime·goPanicSlice3BU(SB) TEXT runtime·panicSlice3C(SB),NOSPLIT,$0-16 +#ifdef GOEXPERIMENT_regabiargs + MOVQ CX, BX +#else MOVQ AX, x+0(FP) MOVQ CX, y+8(FP) +#endif JMP runtime·goPanicSlice3C(SB) TEXT runtime·panicSlice3CU(SB),NOSPLIT,$0-16 +#ifdef GOEXPERIMENT_regabiargs + MOVQ CX, BX +#else MOVQ AX, x+0(FP) MOVQ CX, y+8(FP) +#endif JMP runtime·goPanicSlice3CU(SB) #ifdef GOOS_android