]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: special case nowritebarrierrec for allocm
authorAustin Clements <austin@google.com>
Tue, 17 Nov 2015 22:28:35 +0000 (17:28 -0500)
committerAustin Clements <austin@google.com>
Thu, 19 Nov 2015 21:17:19 +0000 (21:17 +0000)
allocm is a very unusual function: it is specifically designed to
allocate in contexts where m.p is nil by temporarily taking over a P.
Since allocm is used in many contexts where it would make sense to use
nowritebarrierrec, this commit teaches the nowritebarrierrec analysis
to stop at allocm.

Updates #10600.

Change-Id: I8499629461d4fe25712d861720dfe438df7ada9b
Reviewed-on: https://go-review.googlesource.com/17005
Reviewed-by: Russ Cox <rsc@golang.org>
src/cmd/compile/internal/gc/dcl.go
src/runtime/proc.go

index c0326c547b4853101d32a4f40b35206fabb518bf..9b865bbee931d6ab4bb5398be25568dd761138ee 100644 (file)
@@ -1575,6 +1575,9 @@ func (c *nowritebarrierrecChecker) visitcall(n *Node) {
        if fn == nil || fn.Op != ONAME || fn.Class != PFUNC || fn.Name.Defn == nil {
                return
        }
+       if (compiling_runtime != 0 || fn.Sym.Pkg == Runtimepkg) && fn.Sym.Name == "allocm" {
+               return
+       }
        defn := fn.Name.Defn
 
        fnbest, ok := c.best[defn]
index f47c4bef5b2f3f7401a50c89b3e49b3d5bdf623a..f89669f2a165361e5323cf41efc60e416889d501 100644 (file)
@@ -1182,6 +1182,9 @@ type cgothreadstart struct {
 // Allocate a new m unassociated with any thread.
 // Can use p for allocation context if needed.
 // fn is recorded as the new m's m.mstartfn.
+//
+// This function it known to the compiler to inhibit the
+// go:nowritebarrierrec annotation because it uses P for allocation.
 func allocm(_p_ *p, fn func()) *m {
        _g_ := getg()
        _g_.m.locks++ // disable GC because it can be called from sysmon