From 68d89bb8e05afc2aa050b4c5ad0df4b3af03c45d Mon Sep 17 00:00:00 2001 From: Austin Clements Date: Wed, 3 Apr 2019 14:47:55 -0400 Subject: runtime: separate stack freeing from stack shrinking Currently, shrinkstack will free the stack if the goroutine is dead. There are only two places that call shrinkstack: scanstack, which will never call it if the goroutine is dead; and markrootFreeGStacks, which only calls it on dead goroutines. Clean this up by separating stack freeing out of shrinkstack. Change-Id: I7d7891e620550c32a2220833923a025704986681 Reviewed-on: https://go-review.googlesource.com/c/go/+/170890 Run-TryBot: Austin Clements TryBot-Result: Gobot Gobot Reviewed-by: Michael Knyszek --- src/runtime/stack.go | 10 ---------- 1 file changed, 10 deletions(-) (limited to 'src/runtime/stack.go') diff --git a/src/runtime/stack.go b/src/runtime/stack.go index 85902a6b68..d5d09ba7d7 100644 --- a/src/runtime/stack.go +++ b/src/runtime/stack.go @@ -1077,16 +1077,6 @@ func gostartcallfn(gobuf *gobuf, fv *funcval) { // gp must be stopped, but the world need not be. func shrinkstack(gp *g) { gstatus := readgstatus(gp) - if gstatus&^_Gscan == _Gdead { - if gp.stack.lo != 0 { - // Free whole stack - it will get reallocated - // if G is used again. - stackfree(gp.stack) - gp.stack.lo = 0 - gp.stack.hi = 0 - } - return - } if gp.stack.lo == 0 { throw("missing stack in shrinkstack") } -- cgit v1.3