]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile, cmd/internal/obj/ppc64: mark unsafe points
authorCherry Zhang <cherryyz@google.com>
Mon, 28 Oct 2019 04:50:39 +0000 (00:50 -0400)
committerCherry Zhang <cherryyz@google.com>
Thu, 7 Nov 2019 19:20:35 +0000 (19:20 +0000)
We'll use CTR as a scratch register for call injection. Mark code
sequences that use CTR as unsafe for async preemption. Currently
it is only used in LoweredZero and LoweredMove. It is unfortunate
that they are nonpreemptible. But I think it is still better than
using LR for call injection and marking all leaf functions
nonpreemptible.

Also mark the prologue of large frame functions nonpreemptible,
as we write below SP.

Change-Id: I05a75431499f3f4b2f23651a7b17f7fcf2afbe06
Reviewed-on: https://go-review.googlesource.com/c/go/+/203823
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
src/cmd/compile/internal/ssa/gen/PPC64Ops.go
src/cmd/compile/internal/ssa/opGen.go
src/cmd/internal/obj/ppc64/obj9.go

index b72563b53c3ea4dfaab70c25fc10ad788e848875..f6d072346d0d603aff99a4342705daddf80c373c 100644 (file)
@@ -447,6 +447,7 @@ func init() {
                        clobberFlags:   true,
                        typ:            "Mem",
                        faultOnNilArg0: true,
+                       unsafePoint:    true,
                },
                // R31 is temp register
                // Loop code:
@@ -493,6 +494,7 @@ func init() {
                        typ:            "Mem",
                        faultOnNilArg0: true,
                        faultOnNilArg1: true,
+                       unsafePoint:    true,
                },
 
                {name: "LoweredAtomicStore8", argLength: 3, reg: gpstore, typ: "Mem", aux: "Int64", faultOnNilArg0: true, hasSideEffects: true},
index b5b2c1d406134db8d58e516a68615fc49f1dadfd..047a2a5573437eba0f29467e8bb1bfac4ed7b247 100644 (file)
@@ -24566,6 +24566,7 @@ var opcodeTable = [...]opInfo{
                argLen:         2,
                clobberFlags:   true,
                faultOnNilArg0: true,
+               unsafePoint:    true,
                reg: regInfo{
                        inputs: []inputInfo{
                                {0, 8}, // R3
@@ -24580,6 +24581,7 @@ var opcodeTable = [...]opInfo{
                clobberFlags:   true,
                faultOnNilArg0: true,
                faultOnNilArg1: true,
+               unsafePoint:    true,
                reg: regInfo{
                        inputs: []inputInfo{
                                {0, 8},  // R3
index 2a4f005592d9fda9a8e5325c9b10815430693e5f..266c982549d0cddca2386b709ea97a10df6db8a1 100644 (file)
@@ -702,6 +702,8 @@ func preprocess(ctxt *obj.Link, cursym *obj.LSym, newprog obj.ProgAlloc) {
                                        // Store link register before decrementing 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 = obj.Appendp(q, c.newprog)
                                        q.As = AMOVD
                                        q.Pos = p.Pos
@@ -710,6 +712,8 @@ func preprocess(ctxt *obj.Link, cursym *obj.LSym, newprog obj.ProgAlloc) {
                                        q.To.Type = obj.TYPE_REG
                                        q.To.Reg = REG_R29 // REGTMP may be used to synthesize large offset in the next instruction
 
+                                       q = c.ctxt.StartUnsafePoint(q, c.newprog)
+
                                        q = obj.Appendp(q, c.newprog)
                                        q.As = AMOVD
                                        q.Pos = p.Pos
@@ -727,6 +731,9 @@ 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)
+
                                }
                        } else if c.cursym.Func.Text.Mark&LEAF == 0 {
                                // A very few functions that do not return to their caller