aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/walk
diff options
context:
space:
mode:
authorCherry Zhang <cherryyz@google.com>2021-04-22 20:36:05 -0400
committerCherry Zhang <cherryyz@google.com>2021-04-23 02:29:37 +0000
commit1b0a0316802b8048d69da49dc23c5a5ab08e8ae8 (patch)
tree97fc6e0d291a6f9e01128a2e4b6350be67c624e7 /src/cmd/compile/internal/walk
parentcfac62a1cc021cae55c9c5e373ebe9c408b75a5d (diff)
downloadgo-1b0a0316802b8048d69da49dc23c5a5ab08e8ae8.tar.gz
go-1b0a0316802b8048d69da49dc23c5a5ab08e8ae8.zip
cmd/compile: escape "go" wrapper closure everywhere
For go statement, the wrapper closure needs to esacpe because it runs asynchronously. Currently, it is not allowed for closures to escape in the runtime. We have worked around this in the runtime, so it doesn't "go" any function with arguments and so doesn't need wrapping. If it ever does, it is not that we can have the closure not escape, which may lead to miscompilation. Instead, make the closure escape (which will fail the compilation). In the future we may allow go'd closure to escape in the runtime. Change-Id: I5bbe47b524371d2270c242f6c275013cd52abfc1 Reviewed-on: https://go-review.googlesource.com/c/go/+/312889 Trust: Cherry Zhang <cherryyz@google.com> Reviewed-by: Than McIntosh <thanm@google.com>
Diffstat (limited to 'src/cmd/compile/internal/walk')
-rw-r--r--src/cmd/compile/internal/walk/order.go6
1 files changed, 2 insertions, 4 deletions
diff --git a/src/cmd/compile/internal/walk/order.go b/src/cmd/compile/internal/walk/order.go
index 7037b8ea60..99a166119a 100644
--- a/src/cmd/compile/internal/walk/order.go
+++ b/src/cmd/compile/internal/walk/order.go
@@ -1582,10 +1582,8 @@ func (o *orderState) wrapGoDefer(n *ir.GoDeferStmt) {
// (needs heap allocation).
cloEscapes := func() bool {
if n.Op() == ir.OGO {
- // For "go", assume that all closures escape (with an
- // exception for the runtime, which doesn't permit
- // heap-allocated closures).
- return base.Ctxt.Pkgpath != "runtime"
+ // For "go", assume that all closures escape.
+ return true
}
// For defer, just use whatever result escape analysis
// has determined for the defer.