]> Cypherpunks.ru repositories - gostls13.git/commit
cmd/compile: be sure to wrap defer/go calls with arguments
authorCherry Zhang <cherryyz@google.com>
Thu, 25 Mar 2021 17:24:16 +0000 (13:24 -0400)
committerCherry Zhang <cherryyz@google.com>
Tue, 30 Mar 2021 00:47:34 +0000 (00:47 +0000)
commite27f3966bbb95d0f3330a60202eabe8dff57a311
tree1f775505b4ab50957c8a1bbc84417f5eae087a9e
parentbd6628e62dd5ef1e389d6551a83ef4f2baabebb5
cmd/compile: be sure to wrap defer/go calls with arguments

CL 298669 implemented wrapping for defer/go calls so the function
being called with defer or go statement has no arguments. This
simplifies the compiler and the runtime, especially with the
new ABI.

If the called function does not have any argument, we don't need
to wrap. But the code missed the cases of method receiver, as
well as some apparent argumentless builtin calls which may later
be rewritten to having arguments (e.g. recover). This CL makes
sure to wrap those cases. Also add a check to ensure that go and
defer calls are indeed argumentless.

Handle "defer recover()" specially, as recover() is lowered to
runtime.gorecover(FP) where FP is the frame's FP. FP needs to be
evaluated before wrapping.

Updates #40724.

Change-Id: I2758b6c69ab6aa02dd588441a457fe28ddd0d5a5
Reviewed-on: https://go-review.googlesource.com/c/go/+/304771
Trust: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
src/cmd/compile/internal/ssagen/ssa.go
src/cmd/compile/internal/walk/builtin.go
src/cmd/compile/internal/walk/expr.go
src/cmd/compile/internal/walk/order.go