• Russ Cox's avatar
    cmd/ld: fix large stack split for preempt check · 031c107c
    Russ Cox authored
    If the stack frame size is larger than the known-unmapped region at the
    bottom of the address space, then the stack split prologue cannot use the usual
    condition:
    
            SP - size >= stackguard
    
    because SP - size may wrap around to a very large number.
    Instead, if the stack frame is large, the prologue tests:
    
            SP - stackguard >= size
    
    (This ends up being a few instructions more expensive, so we don't do it always.)
    
    Preemption requests register by setting stackguard to a very large value, so
    that the first test (SP - size >= stackguard) cannot possibly succeed.
    Unfortunately, that same very large value causes a wraparound in the
    second test (SP - stackguard >= size), making it succeed incorrectly.
    
    To avoid *that* wraparound, we have to amend the test:
    
            stackguard != StackPreempt && SP - stackguard >= size
    
    This test is only used for functions with large frames, which essentially
    always split the stack, so the cost of the few instructions is noise.
    
    This CL and CL 11085043 together fix the known issues with preemption,
    at the beginning of a function, so we will be able to try turning it on again.
    
    R=ken2
    CC=golang-dev
    https://golang.org/cl/11205043
    031c107c
Name
Last commit
Last update
..
archive Loading commit data...
bufio Loading commit data...
builtin Loading commit data...
bytes Loading commit data...
compress Loading commit data...
container Loading commit data...
crypto Loading commit data...
database/sql Loading commit data...
debug Loading commit data...
encoding Loading commit data...
errors Loading commit data...
expvar Loading commit data...
flag Loading commit data...
fmt Loading commit data...
go Loading commit data...
hash Loading commit data...
html Loading commit data...
image Loading commit data...
index/suffixarray Loading commit data...
io Loading commit data...
log Loading commit data...
math Loading commit data...
mime Loading commit data...
net Loading commit data...
os Loading commit data...
path Loading commit data...
reflect Loading commit data...
regexp Loading commit data...
runtime Loading commit data...
sort Loading commit data...
strconv Loading commit data...
strings Loading commit data...
sync Loading commit data...
syscall Loading commit data...
testing Loading commit data...
text Loading commit data...
time Loading commit data...
unicode Loading commit data...
unsafe Loading commit data...