• Austin Clements's avatar
    runtime: only shrink stacks at synchronous safe points · 60586034
    Austin Clements authored
    We're about to introduce asynchronous safe points, where we won't have
    precise pointer maps for all stack frames. That's okay for scanning
    the stack (conservatively), but not for shrinking the stack.
    
    Hence, this CL prepares for this by only shrinking the stack as part
    of the stack scan if the goroutine is stopped at a synchronous safe
    point. Otherwise, it queues up the stack shrink for the next
    synchronous safe point.
    
    We already have one condition under which we can't shrink the stack
    for very similar reasons: syscalls. Currently, we just give up on
    shrinking the stack if it's in a syscall. But with this mechanism, we
    defer that stack shrink until the next synchronous safe point.
    
    For #10958, #24543.
    
    Change-Id: Ifa1dec6f33fdf30f9067be2ce3f7ab8a7f62ce38
    Reviewed-on: https://go-review.googlesource.com/c/go/+/201438
    Run-TryBot: Austin Clements <austin@google.com>
    TryBot-Result: Gobot Gobot <gobot@golang.org>
    Reviewed-by: default avatarCherry Zhang <cherryyz@google.com>
    60586034
runtime2.go 36.3 KB