From c19759aa487f7d6f479daa00e7462425f4efc481 Mon Sep 17 00:00:00 2001 From: Austin Clements Date: Tue, 13 Apr 2021 08:44:56 -0400 Subject: runtime: eliminate externalthreadhandler This function is no longer used. Eliminating this actually fixes several problems: - It made assumptions about what registers memclrNoHeapPointers would preserve. Besides being an abstraction violation and lurking maintenance issue, this actively became a problem for regabi because the call to memclrNoHeapPointers now happens through an ABI wrapper, which is generated by the compiler and hence we can't easily control what registers it clobbers. - The amd64 implementation (at least), does not interact with the host ABI correctly. Notably, it doesn't save many of the registers that are callee-save in the host ABI but caller-save in the Go ABI. - It interacts strangely with the NOSPLIT checker because it allocates an entire M and G on its stack. It worked around this on arm64, and happened to do things the NOSPLIT checker couldn't track on 386 and amd64, and happened to be *4 bytes* below the limit on arm (so any addition to the m or g structs would cause a NOSPLIT failure). See CL 309031 for a more complete explanation. Fixes #45530. Updates #40724. Change-Id: Ic70d4d7e1c17f1d796575b3377b8529449e93576 Reviewed-on: https://go-review.googlesource.com/c/go/+/309634 Trust: Austin Clements Run-TryBot: Austin Clements TryBot-Result: Go Bot Reviewed-by: Michael Pratt Reviewed-by: Michael Knyszek --- src/runtime/sys_windows_amd64.s | 51 ----------------------------------------- 1 file changed, 51 deletions(-) (limited to 'src/runtime/sys_windows_amd64.s') diff --git a/src/runtime/sys_windows_amd64.s b/src/runtime/sys_windows_amd64.s index df1462b877..f7250c65a8 100644 --- a/src/runtime/sys_windows_amd64.s +++ b/src/runtime/sys_windows_amd64.s @@ -202,57 +202,6 @@ TEXT runtime·lastcontinuetramp(SB),NOSPLIT|NOFRAME,$0-0 MOVQ $runtime·lastcontinuehandler(SB), AX JMP sigtramp<>(SB) -TEXT runtime·externalthreadhandler(SB),NOSPLIT|NOFRAME|TOPFRAME,$0 - PUSHQ BP - MOVQ SP, BP - PUSHQ BX - PUSHQ SI - PUSHQ DI - PUSHQ 0x28(GS) - MOVQ SP, DX - - // setup dummy m, g - SUBQ $m__size, SP // space for M - MOVQ SP, 0(SP) - MOVQ $m__size, 8(SP) - CALL runtime·memclrNoHeapPointers(SB) // smashes AX,BX,CX, maybe BP - - LEAQ m_tls(SP), CX - MOVQ CX, 0x28(GS) - MOVQ SP, BX - SUBQ $g__size, SP // space for G - MOVQ SP, g(CX) - MOVQ SP, m_g0(BX) - - MOVQ SP, 0(SP) - MOVQ $g__size, 8(SP) - CALL runtime·memclrNoHeapPointers(SB) // smashes AX,BX,CX, maybe BP - LEAQ g__size(SP), BX - MOVQ BX, g_m(SP) - - LEAQ -32768(SP), CX // must be less than SizeOfStackReserve set by linker - MOVQ CX, (g_stack+stack_lo)(SP) - ADDQ $const__StackGuard, CX - MOVQ CX, g_stackguard0(SP) - MOVQ CX, g_stackguard1(SP) - MOVQ DX, (g_stack+stack_hi)(SP) - - PUSHQ AX // room for return value - PUSHQ 32(BP) // arg for handler - CALL 16(BP) - POPQ CX - POPQ AX // pass return value to Windows in AX - - get_tls(CX) - MOVQ g(CX), CX - MOVQ (g_stack+stack_hi)(CX), SP - POPQ 0x28(GS) - POPQ DI - POPQ SI - POPQ BX - POPQ BP - RET - GLOBL runtime·cbctxts(SB), NOPTR, $8 TEXT runtime·callbackasm1(SB),NOSPLIT,$0 -- cgit v1.3