mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
runtime: change arm software div/mod call sequence not to modify stack
Instead of pushing the denominator argument on the stack, the denominator is now passed in m. This fixes a variety of bugs related to trying to take stack traces backwards from the middle of the software div/mod routines. Some of those bugs have been kludged around in the past, but others have not. Instead of trying to patch up after breaking the stack, this CL stops breaking the stack. This is an update of https://golang.org/cl/19810043, which was rolled back in https://golang.org/cl/20350043. The problem in the original CL was that there were divisions at bad times, when m was not available. These were divisions by constant denominators, either in C code or in assembly. The Go compiler knows how to generate division by multiplication for constant denominators, but the C compiler did not. There is no longer any C code, so that's taken care of. There was one problematic DIV in runtime.usleep (assembly) but https://golang.org/cl/12898 took care of that one. So now this approach is safe. Reject DIV/MOD in NOSPLIT functions to keep them from coming back. Fixes #6681. Fixes #6699. Fixes #10486. Change-Id: I09a13c76ad08ba75b3bd5d46a3eb78e66a84ab38 Reviewed-on: https://go-review.googlesource.com/12899 Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
parent
7904946eeb
commit
b2dfacf35e
4 changed files with 87 additions and 73 deletions
|
|
@ -222,6 +222,7 @@ type g struct {
|
|||
|
||||
_panic *_panic // innermost panic - offset known to liblink
|
||||
_defer *_defer // innermost defer
|
||||
m *m // current m; offset known to arm liblink
|
||||
stackAlloc uintptr // stack allocation is [stack.lo,stack.lo+stackAlloc)
|
||||
sched gobuf
|
||||
syscallsp uintptr // if status==Gsyscall, syscallsp = sched.sp to use during gc
|
||||
|
|
@ -245,7 +246,6 @@ type g struct {
|
|||
sysblocktraced bool // StartTrace has emitted EvGoInSyscall about this goroutine
|
||||
sysexitticks int64 // cputicks when syscall has returned (for tracing)
|
||||
sysexitseq uint64 // trace seq when syscall has returned (for tracing)
|
||||
m *m // for debuggers, but offset not hard-coded
|
||||
lockedm *m
|
||||
sig uint32
|
||||
writebuf []byte
|
||||
|
|
@ -273,8 +273,9 @@ type mscratch struct {
|
|||
}
|
||||
|
||||
type m struct {
|
||||
g0 *g // goroutine with scheduling stack
|
||||
morebuf gobuf // gobuf arg to morestack
|
||||
g0 *g // goroutine with scheduling stack
|
||||
morebuf gobuf // gobuf arg to morestack
|
||||
divmod uint32 // div/mod denominator for arm - known to liblink
|
||||
|
||||
// Fields not known to debuggers.
|
||||
procid uint64 // for debuggers, but offset not hard-coded
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue