aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/internal/obj/mips/obj0.go
diff options
context:
space:
mode:
authorCherry Zhang <cherryyz@google.com>2019-10-26 22:49:13 -0400
committerCherry Zhang <cherryyz@google.com>2019-11-07 19:18:49 +0000
commit69dcdbd2ba54e65faafbb40327e4db41dd255ad7 (patch)
tree7dd1f952d7bae2957d52387a07bd2820694477a0 /src/cmd/internal/obj/mips/obj0.go
parent1b0b9809046c1862f8ea0240fe016e516c67676f (diff)
downloadgo-69dcdbd2ba54e65faafbb40327e4db41dd255ad7.tar.xz
cmd/internal/obj/mips: mark unsafe points
For async preemption, we will be using REGTMP as a temporary register in injected call on MIPS, which will clobber it. So any code that uses REGTMP is not safe for async preemption. In the assembler backend, we expand a Prog to multiple machine instructions and use REGTMP as a temporary register if necessary. These need to be marked unsafe. In fact, most of the multi-instruction Progs use REGTMP, so we mark all of them, except ones that are whitelisted. Change-Id: Ic00ae5589683c2c9525abdaee076d884df6b0d1e Reviewed-on: https://go-review.googlesource.com/c/go/+/203718 Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org>
Diffstat (limited to 'src/cmd/internal/obj/mips/obj0.go')
-rw-r--r--src/cmd/internal/obj/mips/obj0.go6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/cmd/internal/obj/mips/obj0.go b/src/cmd/internal/obj/mips/obj0.go
index f096c7ff14..3d8e91ce44 100644
--- a/src/cmd/internal/obj/mips/obj0.go
+++ b/src/cmd/internal/obj/mips/obj0.go
@@ -339,6 +339,10 @@ func preprocess(ctxt *obj.Link, cursym *obj.LSym, newprog obj.ProgAlloc) {
// Store link register before decrement SP, so if a signal comes
// during the execution of the function prologue, the traceback
// code will not see a half-updated stack frame.
+ // This sequence is not async preemptible, as if we open a frame
+ // at the current SP, it will clobber the saved LR.
+ q = c.ctxt.StartUnsafePoint(q, c.newprog)
+
q = obj.Appendp(q, newprog)
q.As = mov
q.Pos = p.Pos
@@ -356,6 +360,8 @@ func preprocess(ctxt *obj.Link, cursym *obj.LSym, newprog obj.ProgAlloc) {
q.To.Type = obj.TYPE_REG
q.To.Reg = REGSP
q.Spadj = +autosize
+
+ q = c.ctxt.EndUnsafePoint(q, c.newprog, -1)
}
if c.cursym.Func.Text.From.Sym.Wrapper() && c.cursym.Func.Text.Mark&LEAF == 0 {