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/cmd/internal/objabi/funcid.go | 44 +++++++++++++++++++-------------------- src/cmd/link/internal/ld/pe.go | 4 +--- 2 files changed, 22 insertions(+), 26 deletions(-) (limited to 'src/cmd') diff --git a/src/cmd/internal/objabi/funcid.go b/src/cmd/internal/objabi/funcid.go index 4229ae2c02..2634106cdf 100644 --- a/src/cmd/internal/objabi/funcid.go +++ b/src/cmd/internal/objabi/funcid.go @@ -29,7 +29,6 @@ const ( FuncID_asyncPreempt FuncID_cgocallback FuncID_debugCallV1 - FuncID_externalthreadhandler FuncID_gcBgMarkWorker FuncID_goexit FuncID_gogo @@ -50,28 +49,27 @@ const ( ) var funcIDs = map[string]FuncID{ - "abort": FuncID_abort, - "asmcgocall": FuncID_asmcgocall, - "asyncPreempt": FuncID_asyncPreempt, - "cgocallback": FuncID_cgocallback, - "debugCallV1": FuncID_debugCallV1, - "externalthreadhandler": FuncID_externalthreadhandler, - "gcBgMarkWorker": FuncID_gcBgMarkWorker, - "go": FuncID_rt0_go, - "goexit": FuncID_goexit, - "gogo": FuncID_gogo, - "gopanic": FuncID_gopanic, - "handleAsyncEvent": FuncID_handleAsyncEvent, - "jmpdefer": FuncID_jmpdefer, - "main": FuncID_runtime_main, - "mcall": FuncID_mcall, - "morestack": FuncID_morestack, - "mstart": FuncID_mstart, - "panicwrap": FuncID_panicwrap, - "runfinq": FuncID_runfinq, - "sigpanic": FuncID_sigpanic, - "switch": FuncID_systemstack_switch, - "systemstack": FuncID_systemstack, + "abort": FuncID_abort, + "asmcgocall": FuncID_asmcgocall, + "asyncPreempt": FuncID_asyncPreempt, + "cgocallback": FuncID_cgocallback, + "debugCallV1": FuncID_debugCallV1, + "gcBgMarkWorker": FuncID_gcBgMarkWorker, + "go": FuncID_rt0_go, + "goexit": FuncID_goexit, + "gogo": FuncID_gogo, + "gopanic": FuncID_gopanic, + "handleAsyncEvent": FuncID_handleAsyncEvent, + "jmpdefer": FuncID_jmpdefer, + "main": FuncID_runtime_main, + "mcall": FuncID_mcall, + "morestack": FuncID_morestack, + "mstart": FuncID_mstart, + "panicwrap": FuncID_panicwrap, + "runfinq": FuncID_runfinq, + "sigpanic": FuncID_sigpanic, + "switch": FuncID_systemstack_switch, + "systemstack": FuncID_systemstack, // Don't show in call stack but otherwise not special. "deferreturn": FuncID_wrapper, diff --git a/src/cmd/link/internal/ld/pe.go b/src/cmd/link/internal/ld/pe.go index dc1b53010a..3ed8943828 100644 --- a/src/cmd/link/internal/ld/pe.go +++ b/src/cmd/link/internal/ld/pe.go @@ -947,9 +947,7 @@ func (f *peFile) writeOptionalHeader(ctxt *Link) { // calls that may need more stack than we think. // // The default stack reserve size directly affects only the main - // thread and threads that enter in externalthreadhandler. - // For this, it must be greater than the stack size assumed by - // externalthreadhandler. + // thread. // // For other threads, the runtime explicitly asks the kernel // to use the default stack size so that all stacks are -- cgit v1.3