1
2
3
4
5 package escape
6
7 import (
8 "cmd/compile/internal/base"
9 "cmd/compile/internal/ir"
10 "cmd/compile/internal/typecheck"
11 "cmd/compile/internal/types"
12 )
13
14
15
16
17
18
19
20 func fixRecoverCall(call *ir.CallExpr) {
21 if call.Op() != ir.ORECOVER {
22 return
23 }
24
25 pos := call.Pos()
26
27
28 var fp ir.Node = ir.NewCallExpr(pos, ir.OGETCALLERSP, nil, nil)
29 if off := base.Ctxt.FixedFrameSize(); off != 0 {
30 fp = ir.NewBinaryExpr(fp.Pos(), ir.OADD, fp, ir.NewInt(off))
31 }
32
33 fp = ir.NewConvExpr(pos, ir.OCONVNOP, types.NewPtr(types.Types[types.TINT32]), fp)
34
35 call.SetOp(ir.ORECOVERFP)
36 call.Args = []ir.Node{typecheck.Expr(fp)}
37 }
38
View as plain text