1
0
mirror of https://github.com/golang/go synced 2024-11-12 01:10:21 -07:00

cmd/internal/obj/riscv: mark stack bounds check prologue nonpreemptible

This is similar to CL 207350, for RISCV64.

May fix #50263.
Updates #35470.

Change-Id: I0d39e195e8254d65fa1aca1cdf1fc553aa8b7cba
Reviewed-on: https://go-review.googlesource.com/c/go/+/373434
Trust: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
This commit is contained in:
Cherry Mui 2021-12-20 12:45:04 -05:00
parent 7c94355b73
commit 59d04d104d

View File

@ -790,6 +790,12 @@ func stacksplit(ctxt *obj.Link, p *obj.Prog, cursym *obj.LSym, newprog obj.ProgA
p.To.Type = obj.TYPE_REG
p.To.Reg = REG_X10
// Mark the stack bound check and morestack call async nonpreemptible.
// If we get preempted here, when resumed the preemption request is
// cleared, but we'll still call morestack, which will double the stack
// unnecessarily. See issue #35470.
p = ctxt.StartUnsafePoint(p, newprog)
var to_done, to_more *obj.Prog
if framesize <= objabi.StackSmall {
@ -854,7 +860,7 @@ func stacksplit(ctxt *obj.Link, p *obj.Prog, cursym *obj.LSym, newprog obj.ProgA
to_done = p
}
p = ctxt.EmitEntryLiveness(cursym, p, newprog)
p = ctxt.EmitEntryStackMap(cursym, p, newprog)
// CALL runtime.morestack(SB)
p = obj.Appendp(p, newprog)
@ -872,6 +878,8 @@ func stacksplit(ctxt *obj.Link, p *obj.Prog, cursym *obj.LSym, newprog obj.ProgA
}
jalToSym(ctxt, p, REG_X5)
p = ctxt.EndUnsafePoint(p, newprog, -1)
// JMP start
p = obj.Appendp(p, newprog)
p.As = AJAL