mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
runtime: use compileCallback for ctrlhandler
This replaces the externalthreadhandler-based implementation of ctrlhandler with one based on compileCallback. This is a step toward eliminating externalthreadhandler. For #45530. Change-Id: I2de2f2f37777af292db67ccf8057b7566aab81f8 Reviewed-on: https://go-review.googlesource.com/c/go/+/309632 Trust: Austin Clements <austin@google.com> Run-TryBot: Austin Clements <austin@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Michael Pratt <mpratt@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>
This commit is contained in:
parent
069983e5db
commit
e512bc2cf0
6 changed files with 9 additions and 34 deletions
|
|
@ -947,8 +947,8 @@ func (f *peFile) writeOptionalHeader(ctxt *Link) {
|
||||||
// calls that may need more stack than we think.
|
// calls that may need more stack than we think.
|
||||||
//
|
//
|
||||||
// The default stack reserve size directly affects only the main
|
// The default stack reserve size directly affects only the main
|
||||||
// thread, ctrlhandler thread, and profileloop thread. For
|
// thread and threads that enter in externalthreadhandler.
|
||||||
// these, it must be greater than the stack size assumed by
|
// For this, it must be greater than the stack size assumed by
|
||||||
// externalthreadhandler.
|
// externalthreadhandler.
|
||||||
//
|
//
|
||||||
// For other threads, the runtime explicitly asks the kernel
|
// For other threads, the runtime explicitly asks the kernel
|
||||||
|
|
|
||||||
|
|
@ -149,9 +149,6 @@ var (
|
||||||
// to start new os thread.
|
// to start new os thread.
|
||||||
func tstart_stdcall(newm *m)
|
func tstart_stdcall(newm *m)
|
||||||
|
|
||||||
// Called by OS using stdcall ABI.
|
|
||||||
func ctrlhandler()
|
|
||||||
|
|
||||||
// Init-time helper
|
// Init-time helper
|
||||||
func wintls()
|
func wintls()
|
||||||
|
|
||||||
|
|
@ -557,8 +554,6 @@ func osinit() {
|
||||||
|
|
||||||
initExceptionHandler()
|
initExceptionHandler()
|
||||||
|
|
||||||
stdcall2(_SetConsoleCtrlHandler, funcPC(ctrlhandler), 1)
|
|
||||||
|
|
||||||
initHighResTimer()
|
initHighResTimer()
|
||||||
timeBeginPeriodRetValue = osRelax(false)
|
timeBeginPeriodRetValue = osRelax(false)
|
||||||
|
|
||||||
|
|
@ -685,8 +680,12 @@ func goenvs() {
|
||||||
|
|
||||||
stdcall1(_FreeEnvironmentStringsW, uintptr(strings))
|
stdcall1(_FreeEnvironmentStringsW, uintptr(strings))
|
||||||
|
|
||||||
// We call this all the way here, late in init, so that malloc works
|
// We call these all the way here, late in init, so that malloc works
|
||||||
// for the callback function this generates.
|
// for the callback functions these generate.
|
||||||
|
var fn interface{} = ctrlHandler
|
||||||
|
ctrlHandlerPC := compileCallback(*efaceOf(&fn), true)
|
||||||
|
stdcall2(_SetConsoleCtrlHandler, ctrlHandlerPC, 1)
|
||||||
|
|
||||||
monitorSuspendResume()
|
monitorSuspendResume()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1176,7 +1175,7 @@ func usleep(us uint32) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func ctrlhandler1(_type uint32) uint32 {
|
func ctrlHandler(_type uint32) uintptr {
|
||||||
var s uint32
|
var s uint32
|
||||||
|
|
||||||
switch _type {
|
switch _type {
|
||||||
|
|
|
||||||
|
|
@ -156,15 +156,6 @@ TEXT runtime·lastcontinuetramp<ABIInternal>(SB),NOSPLIT,$0-0
|
||||||
MOVL $runtime·lastcontinuehandler(SB), AX
|
MOVL $runtime·lastcontinuehandler(SB), AX
|
||||||
JMP sigtramp<>(SB)
|
JMP sigtramp<>(SB)
|
||||||
|
|
||||||
// Called by OS using stdcall ABI: bool ctrlhandler(uint32).
|
|
||||||
TEXT runtime·ctrlhandler<ABIInternal>(SB),NOSPLIT,$0
|
|
||||||
PUSHL $runtime·ctrlhandler1(SB)
|
|
||||||
NOP SP // tell vet SP changed - stop checking offsets
|
|
||||||
CALL runtime·externalthreadhandler<ABIInternal>(SB)
|
|
||||||
MOVL 4(SP), CX
|
|
||||||
ADDL $12, SP
|
|
||||||
JMP CX
|
|
||||||
|
|
||||||
// Called by OS using stdcall ABI: uint32 profileloop(void*).
|
// Called by OS using stdcall ABI: uint32 profileloop(void*).
|
||||||
TEXT runtime·profileloop<ABIInternal>(SB),NOSPLIT,$0
|
TEXT runtime·profileloop<ABIInternal>(SB),NOSPLIT,$0
|
||||||
PUSHL $runtime·profileloop1(SB)
|
PUSHL $runtime·profileloop1(SB)
|
||||||
|
|
|
||||||
|
|
@ -202,13 +202,6 @@ TEXT runtime·lastcontinuetramp<ABIInternal>(SB),NOSPLIT|NOFRAME,$0-0
|
||||||
MOVQ $runtime·lastcontinuehandler(SB), AX
|
MOVQ $runtime·lastcontinuehandler(SB), AX
|
||||||
JMP sigtramp<>(SB)
|
JMP sigtramp<>(SB)
|
||||||
|
|
||||||
TEXT runtime·ctrlhandler<ABIInternal>(SB),NOSPLIT|NOFRAME,$8
|
|
||||||
MOVQ CX, 16(SP) // spill
|
|
||||||
MOVQ $runtime·ctrlhandler1(SB), CX
|
|
||||||
MOVQ CX, 0(SP)
|
|
||||||
CALL runtime·externalthreadhandler<ABIInternal>(SB)
|
|
||||||
RET
|
|
||||||
|
|
||||||
TEXT runtime·profileloop<ABIInternal>(SB),NOSPLIT|NOFRAME,$8
|
TEXT runtime·profileloop<ABIInternal>(SB),NOSPLIT|NOFRAME,$8
|
||||||
MOVQ $runtime·profileloop1(SB), CX
|
MOVQ $runtime·profileloop1(SB), CX
|
||||||
MOVQ CX, 0(SP)
|
MOVQ CX, 0(SP)
|
||||||
|
|
|
||||||
|
|
@ -233,10 +233,6 @@ TEXT runtime·lastcontinuetramp<ABIInternal>(SB),NOSPLIT|NOFRAME,$0
|
||||||
MOVW $runtime·lastcontinuehandler(SB), R1
|
MOVW $runtime·lastcontinuehandler(SB), R1
|
||||||
B sigtramp<>(SB)
|
B sigtramp<>(SB)
|
||||||
|
|
||||||
TEXT runtime·ctrlhandler<ABIInternal>(SB),NOSPLIT|NOFRAME,$0
|
|
||||||
MOVW $runtime·ctrlhandler1(SB), R1
|
|
||||||
B runtime·externalthreadhandler<ABIInternal>(SB)
|
|
||||||
|
|
||||||
TEXT runtime·profileloop<ABIInternal>(SB),NOSPLIT|NOFRAME,$0
|
TEXT runtime·profileloop<ABIInternal>(SB),NOSPLIT|NOFRAME,$0
|
||||||
MOVW $runtime·profileloop1(SB), R1
|
MOVW $runtime·profileloop1(SB), R1
|
||||||
B runtime·externalthreadhandler<ABIInternal>(SB)
|
B runtime·externalthreadhandler<ABIInternal>(SB)
|
||||||
|
|
|
||||||
|
|
@ -299,10 +299,6 @@ TEXT runtime·lastcontinuetramp(SB),NOSPLIT|NOFRAME,$0
|
||||||
MOVD $runtime·lastcontinuehandler<ABIInternal>(SB), R1
|
MOVD $runtime·lastcontinuehandler<ABIInternal>(SB), R1
|
||||||
B sigtramp<>(SB)
|
B sigtramp<>(SB)
|
||||||
|
|
||||||
TEXT runtime·ctrlhandler<ABIInternal>(SB),NOSPLIT|NOFRAME,$0
|
|
||||||
MOVD $runtime·ctrlhandler1(SB), R1
|
|
||||||
B runtime·externalthreadhandler<ABIInternal>(SB)
|
|
||||||
|
|
||||||
TEXT runtime·profileloop<ABIInternal>(SB),NOSPLIT|NOFRAME,$0
|
TEXT runtime·profileloop<ABIInternal>(SB),NOSPLIT|NOFRAME,$0
|
||||||
MOVD $runtime·profileloop1(SB), R1
|
MOVD $runtime·profileloop1(SB), R1
|
||||||
B runtime·externalthreadhandler<ABIInternal>(SB)
|
B runtime·externalthreadhandler<ABIInternal>(SB)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue