aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/typecheck/typecheck.go
diff options
context:
space:
mode:
authorMatthew Dempsky <mdempsky@google.com>2021-06-22 13:44:18 -0700
committerMatthew Dempsky <mdempsky@google.com>2021-06-23 16:47:41 +0000
commit574ec1c6457c7779cd20db873fef2e2ed7e31ff1 (patch)
tree4e6ee46c1d7e1c27ae438c534441f3e5d442df10 /src/cmd/compile/internal/typecheck/typecheck.go
parent9be8303df9e3aa5f4ea1879e82a3edbf54b78dbf (diff)
downloadgo-574ec1c6457c7779cd20db873fef2e2ed7e31ff1.tar.gz
go-574ec1c6457c7779cd20db873fef2e2ed7e31ff1.zip
[dev.typeparams] cmd/compile: desugar ORECOVER into ORECOVERFP
Currently ORECOVER is a single operation that both (1) calculates the (logical) caller frame pointer and (2) calls runtime.gorecover. This is normally fine, but it's inconvenient for regabi, which wants to wrap "defer recover()" into "defer func() { recover() }" and needs (1) and (2) to happen at different times. The current solution is to apply walkRecover early to split it into the two steps, but calling it during order is a minor layering violation. It works well today because the order and walk phases are closely related anyway and walkRecover is relatively simple, but it won't work for go/defer wrapping earlier into the frontend. This CL adds a new, lower-level ORECOVERFP primitive, which represents just part (2); and OGETCALLER{PC,SP} primitives, which provide a way to compute (1) in the frontend too. OGETCALLERPC isn't needed/used today, but it seems worth including for completeness. Maybe it will be useful at some point for intrinsifying runtime.getcaller{pc,sp}, like we already do for runtime.getg. Change-Id: Iaa8ae51e09306c45c147b6759a5b7c24dcc317ca Reviewed-on: https://go-review.googlesource.com/c/go/+/330192 Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Go Bot <gobot@golang.org> Trust: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Diffstat (limited to 'src/cmd/compile/internal/typecheck/typecheck.go')
-rw-r--r--src/cmd/compile/internal/typecheck/typecheck.go12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/cmd/compile/internal/typecheck/typecheck.go b/src/cmd/compile/internal/typecheck/typecheck.go
index 0367f7b034..f7de43c79f 100644
--- a/src/cmd/compile/internal/typecheck/typecheck.go
+++ b/src/cmd/compile/internal/typecheck/typecheck.go
@@ -776,6 +776,10 @@ func typecheck1(n ir.Node, top int) ir.Node {
n := n.(*ir.CallExpr)
return tcRecover(n)
+ case ir.ORECOVERFP:
+ n := n.(*ir.CallExpr)
+ return tcRecoverFP(n)
+
case ir.OUNSAFEADD:
n := n.(*ir.BinaryExpr)
return tcUnsafeAdd(n)
@@ -809,6 +813,14 @@ func typecheck1(n ir.Node, top int) ir.Node {
n.SetType(types.Types[types.TUINTPTR])
return n
+ case ir.OGETCALLERPC, ir.OGETCALLERSP:
+ n := n.(*ir.CallExpr)
+ if len(n.Args) != 0 {
+ base.FatalfAt(n.Pos(), "unexpected arguments: %v", n)
+ }
+ n.SetType(types.Types[types.TUINTPTR])
+ return n
+
case ir.OCONVNOP:
n := n.(*ir.ConvExpr)
n.X = Expr(n.X)